Hi everyone,
I just got myself my first Mkrotik Router and wanted to move my wireguard VPN from a dedicated server to the router. But I cant get it to work.
My problem is very similar to the one described here: http://forum.mikrotik.com/t/wireguard-on-one-of-multiple-wan-interfaces/169843/1 but I have not been able to fix it, and after two days of trying different approaches the configuration might be a total mess now.
FYI the second WAN (ether2) should only be used for WG. The use case for WG is accessing service in the Lan from remote laptops and phones (mail, rdp, internal websites etc.). Using it as a secure tunnel for browsing the internet would be bonus.
My setup:
/interface/ print
Flags: R - RUNNING; S - SLAVE
Columns: NAME, TYPE, ACTUAL-MTU, L2MTU, MAX-L2MTU, MAC-ADDRESS
# NAME TYPE ACTUAL-MTU L2MTU MAX-L2MTU MAC-ADDRESS
0 R ether1 ether 1500 1598 8156 78:9A:18:21:F9:58 <= Connection to ADSL-Router
1 R ether2 ether 1500 1598 8156 78:9A:18:21:F9:59 <= Direct ISP Connection with public static IP
2 RS ether3 ether 1500 1598 8156 78:9A:18:21:F9:5A <= LAN Switch
3 S ether4 ether 1500 1598 8156 78:9A:18:21:F9:5B
4 S ether5 ether 1500 1598 8156 78:9A:18:21:F9:5C
5 S ether6 ether 1500 1598 8156 78:9A:18:21:F9:5E
6 S ether7 ether 1500 1598 8156 78:9A:18:21:F9:5F
7 S ether8 ether 1500 1598 8156 78:9A:18:21:F9:60
8 S ether9 ether 1500 1598 8156 78:9A:18:21:F9:61
9 S ether10 ether 1500 1598 8156 78:9A:18:21:F9:62
10 S sfp1 ether 1500 1600 8158 78:9A:18:21:F9:5D
;;; defconf
11 R bridge bridge 1500 1598 78:9A:18:21:F9:59
12 R wireguard1 wg 1420
Adresses:
/ip/address/ print
Flags: D - DYNAMIC
Columns: ADDRESS, NETWORK, INTERFACE
# ADDRESS NETWORK INTERFACE
;;; defconf
0 192.168.1.254/24 192.168.1.0 bridge
1 [Our-public-IP]/30 xx.yy.zz.128 ether2
2 10.23.5.1/24 10.23.5.0 wireguard1
3 D 192.168.2.4/24 192.168.2.0 ether1 <= assigned via dhcp from adsl router
wireguard:
/interface wireguard
add listen-port=34081 mtu=1420 name=wireguard1
/interface wireguard peers
add allowed-address=10.23.5.107/32,fc00:23:5::107/128 comment=CG-Phone interface=wireguard1 persistent-keepalive=25s public-key="mHptTViD+kONfL5y97Z2d3+xxxxxxxxxxxxxxxxxxxxx"
firewall rules:
/ip firewall filter
add action=accept chain=input comment="Accept WireGuard on Port 34081" dst-port=34081 log=yes log-prefix=wg_in protocol=udp
add action=accept chain=input comment="defconf: accept established,related,untracked" connection-state=established,related,untracked
add action=drop chain=input comment="defconf: drop invalid" connection-state=invalid
add action=accept chain=input comment="defconf: accept ICMP" protocol=icmp
add action=accept chain=input comment="defconf: accept to local loopback (for CAPsMAN)" dst-address=127.0.0.1
add action=drop chain=input comment="defconf: drop all not coming from LAN" in-interface-list=!LAN
add action=accept chain=forward comment="defconf: accept in ipsec policy" ipsec-policy=in,ipsec
add action=accept chain=forward comment="defconf: accept out ipsec policy" ipsec-policy=out,ipsec
add action=fasttrack-connection chain=forward comment="defconf: fasttrack" connection-state=established,related hw-offload=yes
add action=accept chain=forward comment="defconf: accept established,related, untracked" connection-state=established,related,untracked
add action=drop chain=forward comment="defconf: drop invalid" connection-state=invalid
add action=drop chain=forward comment="defconf: drop all from WAN not DSTNATed" connection-nat-state=!dstnat connection-state=new in-interface-list=WAN log=yes log-prefix=DROPPED
/ip firewall mangle
add action=mark-packet chain=prerouting connection-mark=no-mark dst-port=34081 in-interface=ether2 log-prefix=MARK-PACK new-packet-mark=wg passthrough=yes protocol=udp
add action=mark-connection chain=prerouting log-prefix=MARK-CONN new-connection-mark=from-vpn packet-mark=wg passthrough=yes
add action=mark-routing chain=prerouting connection-mark=from-vpn log-prefix=MARK-ROUTE new-routing-mark=wgtab passthrough=no
/ip firewall nat
add action=masquerade chain=srcnat comment="defconf: masquerade" ipsec-policy=out,none out-interface-list=WAN
Routing:
/routing table
add disabled=no fib name=wgtab
/routing rule
add action=lookup-only-in-table disabled=no dst-address=0.0.0.0/0 routing-mark=wgtab src-address=0.0.0.0/0 table=wgtab
Tell me if anything is missing.