Hello everyone,I have a problem with Wireguard connectivity on RouterOS with multiple WAN ports would appreciate help!
I have two different ISP accounts used as uplinks and both get a public IP after PPPOE dialup,and use RouterOS as a router with a 192.168.124.0/23 subnet.
When both ISP accounts are online at the same time, I can only connect to the wireguard on RouterOS through the IP assigned by one of the ISPs, and when I access it through the other ISP’s IP, the client prompts a handshake failure,client logs are below.
2023-11-23 22:08:37.841 [NET] peer(H1WC…Xrzs) - Sending handshake initiation
2023-11-23 22:08:42.848 [NET] peer(H1WC…Xrzs) - Sending handshake initiation
2023-11-23 22:08:48.052 [NET] peer(H1WC…Xrzs) - Handshake did not complete after 5 seconds, retrying (try 2)
2023-11-23 22:08:48.054 [NET] peer(H1WC…Xrzs) - Sending handshake initiation
2023-11-23 22:08:53.157 [NET] peer(H1WC…Xrzs) - Handshake did not complete after 5 seconds, retrying (try 3)
2023-11-23 22:08:53.158 [NET] peer(H1WC…Xrzs) - Sending handshake initiation
2023-11-23 22:08:58.394 [NET] peer(H1WC…Xrzs) - Handshake did not complete after 5 seconds, retrying (try 4)
But when only any ISP account is online, I can successfully connect to RouterOS via its IP.
I’ve tried reducing the MTU value of wireguard, or marking wireguard traffic according to the different ISPs it comes from and setting up routing table rules, none of it works.
Here is my configuration about pppoe-client,interface and dhcp-server.
/interface pppoe-client
add add-default-route=yes disabled=no interface=eth1 name=pppoe_ha-ct password=pwd1 user=user1
add add-default-route=yes disabled=no interface=eth0.22 max-mtu=1492 name= pppoe_ha-cu password=pwd2 user=user2
/interface bridge
add name=lan
/interface bridge port
add bridge=lan interface=eth2
add bridge=lan interface=eth3
/ip pool
add name=dhcp_pool0 ranges=192.168.124.2-192.168.125.254
/ip dhcp-server
add address-pool=dhcp_pool0 interface=lan lease-time=10m name=dhcp1
/interface list
add name=wan_ha_cu
add name=LAN
add name=wan_ha_ct
add name=WAN
/interface list member
add interface=lan list=LAN
add interface=pppoe_ha-cu list=WAN
add interface=pppoe_ha-ct list=WAN
add interface=pppoe_ha-cu list=wan_ha_cu
add interface=pppoe_ha-ct list=wan_ha_ct
/ip dhcp-server network
add address=192.168.124.0/23 dns-server=192.168.126.3 gateway=192.168.124.1
/ip address
add address=192.168.124.1/23 interface=lan network=192.168.124.0
add address=192.168.204.1/23 interface=wireguard1 network=192.168.204.0
/ip dhcp-server network
add address=192.168.124.0/23 dns-server=192.168.126.3 gateway=192.168.124.1
Here is firewall configuration.
/ip firewall filter
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=accept chain=input comment="Allow OpenVPN" dst-port=51149 protocol=udp
add action=accept chain=input comment="allow wireguard" dst-port=52789 log-prefix=wireguard1 protocol=udp
add action=accept chain=forward comment="defconf: accept established,related, untracked" connection-state=established,related,untracked
add action=accept chain=input log=yes port=52789 protocol=udp
add action=fasttrack-connection chain=forward comment="defconf: fasttrack" connection-state=established,related hw-offload=yes
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
add action=drop chain=input comment="drop all coming from ha_ct" in-interface=pppoe_ha-ct
add action=drop chain=input comment="drop all coming from ha_cu" in-interface=pppoe_ha-cu
add action=drop chain=input comment="drop upnp from ds920" dst-port=1900 protocol=udp src-address=192.168.125.1
add action=drop chain=input comment="drop upnp from ds920" dst-port=2828 protocol=tcp src-address=192.168.125.1
/ip firewall mangle
add action=mark-connection chain=input comment="mark wireguard from ct" dst-port=52789 in-interface=pppoe_ha-ct new-connection-mark=wireguard_ct_52789_conn passthrough=no protocol=udp
add action=mark-routing chain=output comment="routing wireguard from ct mark" connection-mark=wireguard_ct_52789_conn log=yes log-prefix=wg-ct-out new-routing-mark=wg-ct-out passthrough=no
add action=mark-connection chain=input comment="mark wireguard from cu" dst-port=52789 in-interface=pppoe_ha-cu new-connection-mark=wireguard_cu_52789_conn passthrough=no protocol=udp
add action=mark-routing chain=output comment="routing wireguard from cu mark" connection-mark=wireguard_cu_52789_conn log=yes log-prefix=wg-cu-out new-routing-mark=wg-cu-out passthrough=no
add action=mark-connection chain=input comment=cu-in in-interface=pppoe_ha-cu new-connection-mark=cu-in passthrough=yes
add action=mark-routing chain=output comment=cu-out connection-mark=cu-in new-routing-mark=cu-out passthrough=yes
add action=mark-connection chain=input comment=ct-in in-interface=pppoe_ha-ct new-connection-mark=ct-in passthrough=yes
add action=mark-routing chain=output comment=ct-out connection-mark=ct-in new-routing-mark=ct-out passthrough=yes
add action=mark-connection chain=prerouting comment="mark ds920 ovpn from ct" dst-port=41194 in-interface=pppoe_ha-ct new-connection-mark=ovpn_ct_41194_conn passthrough=yes protocol=udp
add action=mark-routing chain=prerouting comment="routing ds920 ovpn from ct mark" connection-mark=ovpn_ct_41194_conn new-routing-mark=ct-out passthrough=no src-address=192.168.125.1
add action=mark-connection chain=prerouting comment="mark ds920 ovpn from cu" dst-port=41194 in-interface=pppoe_ha-cu new-connection-mark= ovpn_cu_41194_conn passthrough=yes protocol=udp
add action=mark-routing chain=prerouting comment="routing ds920 ovpn from cu mark" connection-mark=ovpn_cu_41194_conn new-routing-mark=cu-out passthrough=no src-address=192.168.125.1
add action=mark-connection chain=prerouting comment="mark bt" dst-address-type=!local in-interface=lan new-connection-mark=bt passthrough=yes protocol=udp src-address=192.168.124.10 src-address-list="" src-port=63000,63001
add action=mark-routing chain=prerouting comment="routing bt mark" connection-mark=bt in-interface=lan new-routing-mark=bt passthrough=yes
add action=mark-connection chain=prerouting comment="https443_out_prerouting mark" dst-port=443 in-interface=lan new-connection-mark=https443 passthrough=yes protocol=tcp
add action=mark-routing chain=prerouting comment="https443_out mark route" connection-mark=https443 in-interface=lan new-routing-mark=cu-out passthrough=yes
add action=change-mss chain=forward comment="defconf: fix IPv4 mss for WAN" new-mss=clamp-to-pmtu passthrough=yes protocol=tcp tcp-flags=syn
/ip firewall nat
add action=masquerade chain=srcnat out-interface=pppoe_ha-ct
add action=masquerade chain=srcnat out-interface=pppoe_ha-cu
add action=dst-nat chain=dstnat comment=ovpn dst-port=41194 in-interface-list=WAN log=yes protocol=udp to-addresses=192.168.125.1 to-ports=41194
add action=dst-nat chain=dstnat dst-port=23333 in-interface-list=WAN protocol=tcp to-addresses=192.168.125.1 to-ports=23333
add action=dst-nat chain=dstnat dst-port=65432 in-interface-list=WAN protocol=tcp to-addresses=192.168.125.1 to-ports=65432
add action=endpoint-independent-nat chain=srcnat comment=FullCone_Nat dst-port=!41194 protocol=udp randomise-ports=yes
add action=endpoint-independent-nat chain=dstnat protocol=udp randomise-ports=yes
route.
/routing table
add disabled=no fib name=cu-out
add disabled=no fib name=ct-out
add disabled=no fib name=bt
add disabled=no fib name=wg-cu-out
add disabled=no fib name=wg-ct-out
add disabled=no fib name=wg
/ip route
add disabled=no distance=1 dst-address=0.0.0.0/0 gateway=pppoe_ha-cu pref-src="" routing-table=main scope=30 suppress-hw-offload=no target-scope=10
add disabled=no distance=10 dst-address=0.0.0.0/0 gateway=pppoe_ha-ct pref-src="" routing-table=main scope=30 suppress-hw-offload=no target-scope=10
add disabled=no distance=1 dst-address=0.0.0.0/0 gateway=pppoe_ha-ct pref-src="" routing-table=ct-out scope=30 suppress-hw-offload=no target-scope=10
add disabled=no distance=1 dst-address=0.0.0.0/0 gateway=pppoe_ha-cu pref-src="" routing-table=cu-out scope=30 suppress-hw-offload=no target-scope=10
add disabled=no distance=1 dst-address=0.0.0.0/0 gateway=pppoe_ha-ct routing-table=bt suppress-hw-offload=no
add disabled=no distance=1 dst-address=0.0.0.0/0 gateway=pppoe_ha-ct pref-src="" routing-table=wg-ct-out scope=30 suppress-hw-offload=no target-scope=10
add disabled=no distance=1 dst-address=0.0.0.0/0 gateway=pppoe_ha-cu pref-src="" routing-table=wg-cu-out scope=30 suppress-hw-offload=no target-scope=10
/routing rule
add action=lookup-only-in-table disabled=no interface=pppoe_ha-ct routing-mark=wg-ct-out table=wg-ct-out
add action=lookup-only-in-table disabled=no interface=pppoe_ha-ct routing-mark=wg-cu-out table=wg-cu-out
and wireguard.
/interface wireguard
add listen-port=52789 mtu=1400 name=wireguard1 private-key="mC****="
/interface wireguard peers
add allowed-address=192.168.204.2/32 interface=wireguard1 private-key="YN*=" public-key="5A*="
add allowed-address=192.168.204.3/32 interface=wireguard1 private-key="yB*=" public-key="LS*="
Looking forward to your help,thanks!