Community discussions

MikroTik App
 
kaminzo
just joined
Topic Author
Posts: 1
Joined: Sat Nov 05, 2022 12:53 pm

Mikrotik Wireguard Client to Mikrotik Wireguard Server when traveling

Sun Dec 18, 2022 11:12 pm

Hi,

I want to take one of my Mikrotik routers with me while travelling and use it as a Wireguard client to allow my devices to connect to broadband at home. I don't want to install wireguard client directly on my laptop. Ideally, I should be able to connect my Mikrotik router to any random standard ISP router via ethernet cable while I am away. E.g. when I visit my friends, so let's assume no control over these ISP routers.

There should be no fallback to Away ISP's internet connection.

My network knowledge is shallow. I have tried approaches from multiple forum posts but need help getting my set up to work.
[x] Currently, whenever I add the following route on my Travel Mikrotik router, I lose access to WebFig and the internet.
/ip route add disabled=no dst-address=0.0.0.0/0 gateway=%wireguard-client routing-table=wireguard-table
[v] Prior to applying the above rule, I am able to ping the Home Mikrotik Router from Away Mikrotik Router.
admin-user@router-ap-back] > ping 192.168.15.1 
  SEQ HOST                                     SIZE TTL TIME       STATUS                                                                                                  
    0 192.168.15.1                               56  64 1ms276us  
... 
[v] Also, the connection from Away Phone works as expected, i.e. I get the Home ISP IP address, and I can manage the Home Mikrotik Router.

Network Diagram in travelling scenario
Network Diagram.png
Home Router relevant config
# dec/18/2022 20:55:54 by RouterOS 7.6
#
# model = RBD53iG-5HacD2HnD
/interface bridge
add admin-mac=DC:2C:6E:04:B9:C7 auto-mac=no name=bridge protocol-mode=none vlan-filtering=yes
/interface ethernet
set [ find default-name=ether1 ] mac-address=58:EF:68:7E:E2:A1
/interface wireguard
add listen-port=13263 mtu=1420 name=wireguard
/interface vlan
add interface=bridge name=base-vlan vlan-id=99
add interface=bridge name=guest-vlan vlan-id=20
add interface=bridge name=jail-vlan vlan-id=30
add interface=bridge name=trusted-vlan vlan-id=10
/interface list
add name=WAN
add name=VLAN
add name=BASE
/ip pool
add name=trusted-pool ranges=192.168.10.10-192.168.10.254
add name=guest-pool ranges=172.16.20.2-172.16.20.254
add name=jail-pool ranges=10.0.30.2-10.0.30.254
add name=base-pool ranges=192.168.0.10-192.168.0.254
/ip dhcp-server
add address-pool=trusted-pool interface=trusted-vlan name=trusted-dhcp
add address-pool=guest-pool interface=guest-vlan name=guest-dhcp
add address-pool=jail-pool interface=jail-vlan name=jail-dhcp
add address-pool=base-pool interface=base-vlan name=base-dhcp
/interface bridge port
add bridge=bridge frame-types=admit-only-untagged-and-priority-tagged interface=ether2 pvid=10
add bridge=bridge frame-types=admit-only-untagged-and-priority-tagged interface=ether3 pvid=10
add bridge=bridge frame-types=admit-only-untagged-and-priority-tagged interface=ether4 pvid=10
add bridge=bridge frame-types=admit-only-vlan-tagged interface=ether5
add bridge=bridge frame-types=admit-only-untagged-and-priority-tagged interface=base-2g-front \
    pvid=99
add bridge=bridge frame-types=admit-only-untagged-and-priority-tagged interface=trusted-5g-front \
    pvid=10
add bridge=bridge frame-types=admit-only-untagged-and-priority-tagged interface=guest-2g-front \
    pvid=20
add bridge=bridge frame-types=admit-only-untagged-and-priority-tagged interface=jail-2g-front \
    pvid=30
add bridge=bridge frame-types=admit-only-untagged-and-priority-tagged interface=trusted-2g-front \
    pvid=10
/ip neighbor discovery-settings
set discover-interface-list=BASE lldp-med-net-policy-vlan=1
/interface bridge vlan
add bridge=bridge tagged=bridge,ether5 vlan-ids=20
add bridge=bridge tagged=bridge,ether5 vlan-ids=30
add bridge=bridge tagged=bridge,ether5 vlan-ids=10
add bridge=bridge tagged=bridge,ether5 vlan-ids=99
/interface list member
add interface=ether1 list=WAN
add interface=wireguard list=VLAN
add interface=trusted-vlan list=VLAN
add interface=guest-vlan list=VLAN
add interface=jail-vlan list=VLAN
add interface=base-vlan list=BASE
add interface=base-vlan list=VLAN
/interface wireguard peers
add allowed-address=192.168.15.11/32 comment=phone endpoint-port=13263 interface=wireguard \
    public-key="123"
add allowed-address=192.168.15.1/24 comment=mikrotik-client endpoint-port=13263 interface=\
    wireguard public-key="xyz"
/ip address
add address=192.168.15.1/24 interface=wireguard network=192.168.15.0
add address=192.168.10.1/24 interface=trusted-vlan network=192.168.10.0
add address=172.16.20.1/24 interface=guest-vlan network=172.16.20.0
add address=10.0.30.1/24 interface=jail-vlan network=10.0.30.0
add address=192.168.0.1/24 interface=base-vlan network=192.168.0.0
/ip cloud
set ddns-enabled=yes
/ip dhcp-client
add comment=defconf dhcp-options=clientid interface=ether1
/ip dhcp-server network
add address=10.0.30.0/24 dns-server=192.168.0.1 gateway=10.0.30.1
add address=172.16.20.0/24 dns-server=192.168.0.1 gateway=172.16.20.1
add address=192.168.0.0/24 dns-server=192.168.0.1 gateway=192.168.0.1
add address=192.168.10.0/24 dns-server=192.168.0.1 gateway=192.168.10.1
/ip dns
set allow-remote-requests=yes
/ip dns static
add address=192.168.0.1 name=router
/ip firewall filter
add action=accept chain=input comment="accept established,related" connection-state=\
    established,related
add action=accept chain=input comment=wireguard dst-port=13263 protocol=udp
add action=accept chain=forward comment="WireGuard for NET" in-interface=wireguard out-interface=\
    ether1 src-address=192.168.88.0/24
add action=accept chain=input comment="Allow VLAN" in-interface-list=VLAN
add action=accept chain=input comment="Allow Base_Vlan Full Access" in-interface=base-vlan
add action=drop chain=input disabled=yes dst-port=53 in-interface=ether1 protocol=udp
add action=drop chain=input disabled=yes dst-port=53 in-interface=ether1 protocol=tcp
add action=accept chain=forward comment="Allow Estab & Related" connection-state=\
    established,related
add action=accept chain=forward comment="VLAN Internet Access only" connection-state=new \
    in-interface-list=VLAN out-interface-list=WAN
add action=drop chain=forward comment=Drop
add action=drop chain=input comment=Drop
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=drop chain=input comment="defconf: drop all not coming from BASE (was set to LAN)" \
    in-interface-list=!BASE
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
/ip firewall nat
add action=masquerade chain=srcnat comment="Default masquerade" out-interface-list=WAN
add action=masquerade chain=srcnat dst-address=192.168.0.0/24 src-address=192.168.0.0/24
/ip service
set telnet disabled=yes
set ftp disabled=yes
set api disabled=yes
set api-ssl disabled=yes
/ip smb
set domain=home
/ip ssh
set strong-crypto=yes
/ipv6 firewall address-list
add address=::/128 comment="defconf: unspecified address" list=bad_ipv6
add address=::1/128 comment="defconf: lo" list=bad_ipv6
add address=fec0::/10 comment="defconf: site-local" list=bad_ipv6
add address=::ffff:0.0.0.0/96 comment="defconf: ipv4-mapped" list=bad_ipv6
add address=::/96 comment="defconf: ipv4 compat" list=bad_ipv6
add address=100::/64 comment="defconf: discard only " list=bad_ipv6
add address=2001:db8::/32 comment="defconf: documentation" list=bad_ipv6
add address=2001:10::/28 comment="defconf: ORCHID" list=bad_ipv6
add address=3ffe::/16 comment="defconf: 6bone" list=bad_ipv6
/ipv6 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 ICMPv6" protocol=icmpv6
add action=accept chain=input comment="defconf: accept UDP traceroute" port=33434-33534 protocol=\
    udp
add action=accept chain=input comment="defconf: accept DHCPv6-Client prefix delegation." dst-port=\
    546 protocol=udp src-address=fe80::/10
add action=accept chain=input comment="defconf: accept IKE" dst-port=500,4500 protocol=udp
add action=accept chain=input comment="defconf: accept ipsec AH" protocol=ipsec-ah
add action=accept chain=input comment="defconf: accept ipsec ESP" protocol=ipsec-esp
add action=accept chain=input comment="defconf: accept all that matches ipsec policy" \
    ipsec-policy=in,ipsec
add action=drop chain=input comment="defconf: drop everything else not coming from LAN" \
    in-interface-list=!*2000011
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 packets with bad src ipv6" src-address-list=\
    bad_ipv6
add action=drop chain=forward comment="defconf: drop packets with bad dst ipv6" dst-address-list=\
    bad_ipv6
add action=drop chain=forward comment="defconf: rfc4890 drop hop-limit=1" hop-limit=equal:1 \
    protocol=icmpv6
add action=accept chain=forward comment="defconf: accept ICMPv6" protocol=icmpv6
add action=accept chain=forward comment="defconf: accept HIP" protocol=139
add action=accept chain=forward comment="defconf: accept IKE" dst-port=500,4500 protocol=udp
add action=accept chain=forward comment="defconf: accept ipsec AH" protocol=ipsec-ah
add action=accept chain=forward comment="defconf: accept ipsec ESP" protocol=ipsec-esp
add action=accept chain=forward comment="defconf: accept all that matches ipsec policy" \
    ipsec-policy=in,ipsec
add action=drop chain=forward comment="defconf: drop everything else not coming from LAN" \
    in-interface-list=!*2000011
/ipv6 nd
set [ find default=yes ] disabled=yes
/system identity
set name=router-ap-front
/system ntp server
set enabled=yes manycast=yes use-local-clock=yes
/tool bandwidth-server
set enabled=no
/tool mac-server
set allowed-interface-list=none
/tool mac-server mac-winbox
set allowed-interface-list=BASE
/tool mac-server ping
set enabled=no

Travel Router relevant config
# dec/18/2022 20:49:51 by RouterOS 7.6
#
# model = RBD53iG-5HacD2HnD
/interface bridge
add admin-mac=DC:2C:6E:09:83:75 auto-mac=no comment=defconf name=bridge
/interface wireguard
add listen-port=13263 mtu=1420 name=wireguard-client
/interface list
add comment=defconf name=WAN
add comment=defconf name=LAN
/ip pool
add name=default-dhcp ranges=192.168.88.10-192.168.88.254
/ip dhcp-server
add address-pool=default-dhcp interface=bridge name=defconf
/routing table
add disabled=no fib name=wireguard-table
/interface bridge port
add bridge=bridge comment=defconf interface=ether2
add bridge=bridge comment=defconf interface=ether3
add bridge=bridge comment=defconf interface=ether4
add bridge=bridge comment=defconf interface=ether5
add bridge=bridge comment=defconf interface=wifi1
add bridge=bridge comment=defconf interface=wifi2
/ip neighbor discovery-settings
set discover-interface-list=LAN
/interface list member
add comment=defconf interface=bridge list=LAN
add comment=defconf interface=ether1 list=WAN
/interface wireguard peers
add allowed-address=0.0.0.0/0 endpoint-address=<home-mk-ddns> endpoint-port=13263 \
    interface=wireguard-client persistent-keepalive=5s public-key=\
    "abc"
/ip address
add address=192.168.88.1/24 comment=defconf interface=bridge network=192.168.88.0
add address=192.168.15.2/24 interface=wireguard-client network=192.168.15.0
/ip cloud
set ddns-enabled=yes
/ip dhcp-client
add comment=defconf interface=ether1
/ip dhcp-server network
add address=192.168.88.0/24 comment=defconf dns-server=192.168.88.1 gateway=192.168.88.1
/ip dns
set allow-remote-requests=yes servers=192.168.88.1
/ip dns static
add address=192.168.88.1 comment=defconf name=router.lan
/ip firewall filter
add action=accept chain=input comment="defconf: accept established,related,untracked" \
    connection-state=established,related,untracked
add action=accept chain=input dst-port=13263 protocol=udp
add action=accept chain=forward comment="Wireguard for net" disabled=yes dst-address=\
    192.168.88.0/24 in-interface=wireguard-client src-address=192.168.0.0/24
add action=accept chain=forward disabled=yes dst-address=192.168.0.0/24 out-interface=\
    wireguard-client src-address=192.168.88.0/24
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
/ip firewall nat
add action=masquerade chain=srcnat comment="defconf: masquerade" ipsec-policy=out,none \
    out-interface-list=WAN
/ip route
add disabled=no distance=1 dst-address=192.168.15.0/24 gateway=wireguard-client pref-src="" \
    routing-table=main suppress-hw-offload=no
/ipv6 firewall address-list
add address=::/128 comment="defconf: unspecified address" list=bad_ipv6
add address=::1/128 comment="defconf: lo" list=bad_ipv6
add address=fec0::/10 comment="defconf: site-local" list=bad_ipv6
add address=::ffff:0.0.0.0/96 comment="defconf: ipv4-mapped" list=bad_ipv6
add address=::/96 comment="defconf: ipv4 compat" list=bad_ipv6
add address=100::/64 comment="defconf: discard only " list=bad_ipv6
add address=2001:db8::/32 comment="defconf: documentation" list=bad_ipv6
add address=2001:10::/28 comment="defconf: ORCHID" list=bad_ipv6
add address=3ffe::/16 comment="defconf: 6bone" list=bad_ipv6
/ipv6 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 ICMPv6" protocol=icmpv6
add action=accept chain=input comment="defconf: accept UDP traceroute" port=33434-33534 protocol=\
    udp
add action=accept chain=input comment="defconf: accept DHCPv6-Client prefix delegation." dst-port=\
    546 protocol=udp src-address=fe80::/10
add action=accept chain=input comment="defconf: accept IKE" dst-port=500,4500 protocol=udp
add action=accept chain=input comment="defconf: accept ipsec AH" protocol=ipsec-ah
add action=accept chain=input comment="defconf: accept ipsec ESP" protocol=ipsec-esp
add action=accept chain=input comment="defconf: accept all that matches ipsec policy" \
    ipsec-policy=in,ipsec
add action=drop chain=input comment="defconf: drop everything else not coming from LAN" \
    in-interface-list=!LAN
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 packets with bad src ipv6" src-address-list=\
    bad_ipv6
add action=drop chain=forward comment="defconf: drop packets with bad dst ipv6" dst-address-list=\
    bad_ipv6
add action=drop chain=forward comment="defconf: rfc4890 drop hop-limit=1" hop-limit=equal:1 \
    protocol=icmpv6
add action=accept chain=forward comment="defconf: accept ICMPv6" protocol=icmpv6
add action=accept chain=forward comment="defconf: accept HIP" protocol=139
add action=accept chain=forward comment="defconf: accept IKE" dst-port=500,4500 protocol=udp
add action=accept chain=forward comment="defconf: accept ipsec AH" protocol=ipsec-ah
add action=accept chain=forward comment="defconf: accept ipsec ESP" protocol=ipsec-esp
add action=accept chain=forward comment="defconf: accept all that matches ipsec policy" \
    ipsec-policy=in,ipsec
add action=drop chain=forward comment="defconf: drop everything else not coming from LAN" \
    in-interface-list=!LAN
/ipv6 nd
set [ find default=yes ] disabled=yes
/routing rule
add action=lookup disabled=no src-address=192.168.88.0/24 table=wireguard-table
/system identity
set name=router-ap-back
/tool mac-server
set allowed-interface-list=LAN
/tool mac-server mac-winbox
set allowed-interface-list=LAN
My setup when I am at home
At home, I use two hAP ac3 as a router/wireless AP and a wireless AP, respectively. I have 4 VLANs (base, trusted, guest and jail) created based on these posts:
viewtopic.php?t=143620#p706998
viewtopic.php?t=143620#p706999
You do not have the required permissions to view the files attached to this post.

Who is online

Users browsing this forum: gigabyte091, lurker888 and 62 guests