BGP & DNS server on MikroTik
1.6K
/interface bridge
add name=bridge-docker
/interface veth
add address=172.20.0.2/24,172.20.0.3/24,172.20.0.4/24 gateway=172.20.0.1 gateway6="" name=veth2-bgpdns
/interface list member
add interface=veth2-bgpdns list=LAN
/interface bridge port
add bridge=bridge-docker interface=veth2-bgpdns
/ip address
add address=172.20.0.1/24 interface=bridge-docker network=172.20.0.0
/container envs
add key=DNSTAP name=bgpdns value=172.20.0.3
add key=DNSTAP_SECONDIP name=bgpdns value=172.20.0.4
add key=UPSTREAM name=bgpdns value=dns.google
add key=UPSTREAM_IP name=bgpdns value=8.8.8.8
add key=BIRD name=bgpdns value=172.20.0.2
add key=FALLBACK_UPSTEAM name=bgpdns value=1
add key=SECOND_TUNNEL name=bgpdns value=1
add key=ROUTE name=bgpdns value=192.168.50.1
add key=ROUTE_SECOND name=bgpdns value=192.168.60.1
add key=TTL name=bgpdns value=720h
/container mounts
add dst=/data name=storage src=/storage
/container
add envlist=bgpdns remote-image=oneevil/dns-server:latest interface=veth2-bgpdns logging=yes \
mounts=storage root-dir=containers/dns start-on-boot=yes workdir=/
/routing bgp connection
add as=65010 disabled=no local.address=172.20.0.1 .role=ebgp multihop=yes \
name=bgp remote.address=172.20.0.2/32 .as=64515 .port=179 router-id=\
172.20.0.1 routing-table=main
/ip dns
set servers=172.20.0.2
add address=172.20.0.2/24,172.20.0.3/24,172.20.0.4/24 gateway=172.20.0.1 gateway6="" name=veth2-bgpdns
The IP addresses assigned to the interface (comma-separated). Three IP addresses are required if multiple routes are configured, else if you use one routes needed two IP addresses. This allows different next-hop addresses to be set for each list of domains.
Note: Multiple IP addresses are needed for configuring multiple
next-hopaddresses for different domain lists when using multiple routes.
Below are the environment variables used to configure the network settings:
| Variable | Description |
|---|---|
DNSTAP | The first IP address of the local DNS server configured with dns-server. |
DNSTAP_SECONDIP | The second IP address of the local DNS server with dns-server (optional). |
Note: Parameters marked as optional can be omitted if you are using a single route.
Below are the key-value pairs used to configure the DNS container:
| Key | Value Example | Description |
|---|---|---|
UPSTREAM | dns.google | The domain name of the upstream DNS provider (optional). |
UPSTREAM_IP | 8.8.8.8 | The IP address of the upstream DNS provider (optional). |
BIRD | 172.20.0.2 | IP address used for the BGP routing daemon (bgp-server). |
FALLBACK_UPSTEAM | 1 | Enables fallback to secondary upstream DNS (1 = enabled). |
SECOND_TUNNEL | 1 | Enables second tunnel interface (1 = enabled). |
ROUTE | 192.168.50.1 | The IP address of the gateway used for routing. |
ROUTE_SECOND | 192.168.60.1 | Secondary gateway IP for routing (used if multiple routes are configured). |
TTL | 720h | Storage time of the route received through the domain name (optional). |
Note: Parameters marked as optional can be omitted if you are using a single route.
The container includes the following mount configuration:
add dst=/data name=storage src=/storage
This mount point (/data) contains two folders:
staticstatic_secondEach of these folders contains .txt files with static routing rules.
.txt)route 64.233.165.94/32 reject;
route 35.207.188.57/32 reject;
route 35.207.81.249/32 reject;
route 35.207.171.222/32 reject;
route 195.62.89.0/24 reject;
route 66.22.192.0/18 reject;
route 64.71.8.96/29 reject;
route 34.0.240.0/22 reject;
route 12.129.184.160/29 reject;
Note: You can include multiple
.txtfiles in each folder. All valid route entries will be processed automatically.
This mount point (/data) contains two files:
domains.txtdomains_second.txt.txt)example.com
example1.com
After modifying the files in the static and/or static_second folders, it is necessary to apply the changes for them to take effect.
Restart the container:
Using the container's shell (recommended):
/container shell 0
# birdc configure
Content type
Image
Digest
sha256:0c61ca3e7…
Size
17.5 MB
Last updated
over 1 year ago
docker pull oneevil/bgpdns-server