Unable to access the router via L2TP

Hi all, I am often connecting to my router from the remote site via L2TP with IPsec VPN. I can connect access everything on my network except the router, so I looked into firewall rules to troubleshoot.

Initially I added my l2tp connection to LAN address list and it worked fine-I could access the router; however it is dynamic interface so when I disconnect from the VPN it changes to “unknown” and the problem starts all over again.

Earlier I created a rule to accept traffic dst port 500, 4500 and 1701 which allows me to connect via L2TP, but there is a rule “drop all not coming from LAN” that is preventing me from accessing the router remotely. I don’t really understand why? default gateway IP 192.168.1.1, remote IP when connected via VPN 192.168.1.2. It’s /24 network so I am on the same subset.

So to resolve a problem I placed another rule above to accept all PPP connections, which also works fine - I can access the router now but I don’t see an option to change “ppp” conections to “l2tp” only. So my question is, how to modify my firewall to allow only l2tp VPN connections without losing an ability to access the router remotely?


firewall:
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=“ACCEPT ALL PPP CONNECTIONS” in-interface=all-ppp
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

Using the same subnet for L2TP connections as the LAN does not make the connection part of the same network.

You could either:
use an L2TP server binding to give you a static interface name which can be added to the LAN interface list,
or:
add interface-list=LAN to the L2TP server PPP profile which will dynamically add/remove any L2TP interfaces to/from the interface list.

Thanks for your help, problem resolved! Could you please elaborate on why using the same subnet for L2TP as LAN does not make the connection part of the same network? Any explanation would be much appreciated as I am trying to understand more concepts of networking. Thanks!

An easy mistake to make is thinking the RJ45 on a PC/laptop is a IP connection. It isn’t, layer 3 IP packets are encapsulated in layer 2 ethernet frames sent with layer 1 signalling/coding, e.g. 10BASE-T/100BASE-TX/1000BASE-T.

The IP addressing is straightforward - if the destination IP address is within the senders subnet it is sent directly to that IP address, otherwise it is sent to the gateway IP address.

The IP-over-Ethernet encapsulation also requires a mechanism to associate IP addresses with ethernet addresses. A sender broadcasts an ARP request, which will reach all devices within that layer 2 network, asking for the ethernet address for a particular IP address, e.g. who has 192.168.1.1? When any device receives a request matching its IP address it replies with its ethernet address, e.g. 00:11:22:33:44:55 has 192.168.1.1. The sender can then send the encapsulated IP to that ethernet address.

Your L2TP connection is not part of that layer 2 network, it is a completely independent point-to-point link using PPP - hence its own interface on the Mikrotik. PPP was originally designed for serial lines but various encapsulations were evolved so the PPP frames could be transported over other networks, the name of this particular encapsulation can be misleading as the L2 part refers to transporting PPP, not the final payload. The PPP protocol itself can transport IP, IPv6 plus legacy protocols such as AppleTalk, IPX, NetBEUI.

Wikipedia is as good a starting place as any for background information, and the definitive information on the protocols is in their RFCs.

Thanks, It makes much more sense now!

Okay so I was testing it at home by connecting my laptop to the hotspot, then L2TP VPN to my router and I could access the router with no problems, I thought it is resolved by today I tried to access the router from the remote site and again It is not accessible. To be precise, I am successfully connecting via VPN, I can access proxmox on my LAN and all VMs that I am running on proxmox, but I cannot access the router, I tried webfix 80 and 443, and winbox but nothing works.

/interface pppoe-client
add add-default-route=yes disabled=no interface=ether1 name=pppoe-out1 user=
02381781825@hometelecom.com
/interface list
add comment=defconf name=WAN
add comment=defconf name=LAN
/ip pool
add name=dhcp_pool ranges=
192.168.1.20-192.168.1.198,192.168.1.200-192.168.1.254
/ip dhcp-server
add address-pool=dhcp_pool interface=bridge lease-time=8h name=dhcp1
/ppp profile
set *FFFFFFFE interface-list=LAN
/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
/ipv6 settings
set max-neighbor-entries=15360
/interface l2tp-server server
set enabled=yes use-ipsec=required
/interface list member
add comment=defconf interface=bridge list=LAN
add comment=defconf interface=ether1 list=WAN
/ip address
add address=192.168.2.2/24 disabled=yes interface=ether1 network=192.168.2.0
add address=192.168.1.1/24 interface=bridge network=192.168.1.0
/ip arp
add address=192.168.1.250 comment=PI-HOLE interface=bridge mac-address=
C2:D9:CC:F4:B4:A6
add address=192.168.1.199 comment=PROXMOX interface=bridge mac-address=
A8:1E:84:43:09:36
add address=192.168.1.19 comment=EVENG interface=bridge mac-address=
56:F3:78:9A:76:75
add address=192.168.1.132 comment=R1 interface=bridge mac-address=
50:00:00:01:00:00
add address=192.168.1.133 comment=R2 interface=bridge mac-address=
50:00:00:02:00:00
add address=192.168.1.134 comment=R3 interface=bridge mac-address=
50:00:00:03:00:00
/ip cloud
set ddns-enabled=yes
/ip dhcp-server lease
add address=192.168.1.134 client-id=1:50:0:0:3:0:0 mac-address=
50:00:00:03:00:00 server=dhcp1
add address=192.168.1.133 client-id=1:50:0:0:2:0:0 mac-address=
50:00:00:02:00:00 server=dhcp1
add address=192.168.1.132 client-id=1:50:0:0:1:0:0 mac-address=
50:00:00:01:00:00 server=dhcp1
add address=192.168.1.250 client-id=
ff:ca:53:9:5a:0:2:0:0:ab:11:d5:5c:eb:ef:6c:a:c2:4e mac-address=
C2:D9:CC:F4:B4:A6 server=dhcp1
/ip dhcp-server network
add address=192.168.1.0/24 dns-server=192.168.1.1 gateway=192.168.1.1
/ip dns
set allow-remote-requests=yes servers=8.8.8.8
/ip dns static
add address=192.168.1.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=drop chain=input comment=“defconf: drop invalid” connection-state=
invalid
add action=accept chain=input comment=“L2TP VPN PORTS” dst-port=500,4500,1701
protocol=udp
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 out-interface=pppoe-out1
add action=src-nat chain=srcnat src-address=192.168.1.2 to-addresses=
192.168.1.1
/ip service
set telnet disabled=yes
set ftp disabled=yes
set www disabled=yes
set www-ssl disabled=no
set api disabled=yes
set api-ssl disabled=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=
!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
/ppp secret
add local-address=192.168.1.1 name=adam remote-address=192.168.1.2 service=
l2tp
/system clock
set time-zone-name=Europe/London
/system identity
set name=MikroTik-hAPax2
/system note
set show-at-login=no
/tool mac-server
set allowed-interface-list=LAN
/tool mac-server mac-winbox
set allowed-interface-list=LAN