How to connect to dn42 using Mikrotik RouterOS


  • - peer external IP
  • - your external IP
  • A private /30 range for the GRE endpoints:
  • - remote GRE IPv4 address
  • - local GRE IPv4 address
  • fd42:c644:5222:3222::40 - remote GRE IPv6 address
  • fd42:c644:5222:3222::41 - local GRE IPv6 address
  • YOUR_AS - your AS number (numbers only)
  • PEER_AS - peer AS number (numbers only)

RouterOS limitations

  • IPSec only supports IKEv1
  • OpenVPN only works in tcp mode
  • OpenVPN does not support LZO compression
  • You can't use /31 subnet for Point-to-Point (PtP) links

Also, you can't use a /32 on the GRE/PtP links. Even if you add a local route to your peer, BGP can't resolve the installed routes using "a nexthop interface". Please use any /30 on the GRE link, either from your assigned DN42 pool address or use a private address like 192.168. Please don't choose from or because they may overlap with DN42 or ChaosVPN.



First, let's add IPSec peer and encryption policy.
Peer most likely provided you with encryption details.
If not, ask them about it. Here we're gonna use aes256-sha256-modp1536

/ip ipsec peer
add address= comment=gre-dn42-peer dh-group=modp1536 \ 
enc-algorithm=aes-256 hash-algorithm=sha256 local-address= secret=PASSWORD
/ip ipsec policy
add comment=gre-dn42-peer dst-address= proposal=dn42 protocol=gre \ 
sa-dst-address= sa-src-address= src-address=


Pretty straightforward here

/interface gre
add allow-fast-path=no comment="DN42 somepeer" local-address= name=gre-dn42-peer \

IPs inside the GRE tunnel

Your peer most likely provided you with IP adresses for GRE tunnel.
As I said before, you can't use /31 for PtP links, so we will be using /30. BGP can't resolve routes if you use a /32 in the GRE link.

Add the IP your peer provided you:


/ip address
add address= interface=gre-dn42-peer network=


Here we can use /127, so it's simple:

/ipv6 address
add address=fdc8:c633:5319:3300::41/127 advertise=no interface=gre-dn42-moos

If you configured everything correctly, you should be able to ping



It's a good idea to setup filters for BGP instances, both IN (accept advertises) and OUT (send advertises)
In this example, we will be filtering IN: and
OUT: and, you really don't want to advertise this networks.
This filter will not only catch /8 or /16 networks, but smaller networks inside this subnets as well.

/routing filter
add action=discard address-family=ip chain=dn42-in prefix= prefix-length=16-32 protocol=bgp
add action=discard address-family=ip chain=dn42-in prefix= prefix-length=16-32 protocol=bgp
add action=discard address-family=ip chain=dn42-out prefix= prefix-length=16-32 protocol=bgp
add action=discard address-family=ip chain=dn42-out prefix= prefix-length=16-32 protocol=bgp

Now, if you want only DN42 connection, you can filter IN (ChaosVPN / freifunk networks):

/routing filter
add action=discard address-family=ip chain=dn42-in prefix= prefix-length=8-32 protocol=bgp


Now, for actual BGP configuration.

/routing bgp instance
set default disabled=yes
add as=YOUR_AS client-to-client-reflection=no name=bgp-dn42-somename out-filter=dn42-in \
Let's add some peers. Right now we have just one, but we still need two connections - to IPv4 and IPv6


/routing bgp peer
add comment="DN42: somepeer IPv4" in-filter=dn42-in instance=bgp-dn42-somename multihop=yes \
name=dn42-somepeer-ipv4 out-filter=dn42-out remote-address= remote-as=PEER_AS \
route-reflect=yes ttl=default
IPv6 (if needed):
/routing bgp peer
add address-families=ipv6 comment="DN42: somepeer IPv6" in-filter=dn42-in \ 
instance=bgp-dn42-somename multihop=yes name=dn42-somepeer-ipv6 out-filter=dn42-out \ 
remote-address=fd42:c644:5222:3222::40 remote-as=PEER_AS route-reflect=yes ttl=default

Also, as a note, Mikrotik doesn't deal well with BGP running over link-local addresses (the address starting with fe80). You need to use a fd42:: address in your BGP session, otherwise, BGP will not install any received route.

BGP Advertisements

You want to advertise your allocated network (most likely), it's very simple:

/routing bgp network
add network=YOUR_ALLOCATED_SUBNET synchronize=no
You can repeat that with as much IPv4 and IPv6 networks which you own.

Split DNS

Separate dns requests for dn42 tld from your default dns traffic with L7 filter in Mikrotik. Change network and LAN GW to mach your network configuration.

/ip firewall layer7-protocol
add name=DN42-DNS regexp="\\x04dn42.\\x01"
/ip firewall nat
add action=src-nat chain=srcnat comment="NAT to DN42 DNS" dst-address= dst-port=53 protocol=udp src-address= to-addresses=
add action=dst-nat chain=dstnat dst-address-type=local dst-port=53 layer7-protocol=DN42-DNS protocol=udp src-address= to-addresses= to-ports=53
Since version 6.47 have added functionality that can redirect DNS queries according to special rules. If you used to do Layer-7 rules in the firewall, now it's simple and elegant:
/ip dns static
add comment=DN42 forward-to= regexp=".*\\.dn42" type=FWD