[SOLVED] Share L2TP/IPsec VPN on local network
by giusdbg from LinuxQuestions.org on (#5135M)
I need to share a L2TP/IPsec VPN connection with the other PC on the local network.
PC1
with internet and L2TP/IPsec VPN connection
with NetworkManager to configure network connections
ethernet interface enp0s31f6
internet interface enp0s20f0u8
L2TP/IPsec VPN interface ppp0
PC1 correctly accesses both the internet and the VPN.
PC2
Other pc in the local network
When I disable the VPN on PC1
PC1
Code:route
Destination Gateway Genmask Flags Metric Ref Use Iface
default _gateway 0.0.0.0 UG 101 0 0 enp0s20f0u8
192.168.0.0 0.0.0.0 255.255.255.0 U 100 0 0 enp0s31f6
192.168.8.0 0.0.0.0 255.255.255.0 U 101 0 0 enp0s20f0u8
or
ip route show
default via 192.168.8.1 dev enp0s20f0u8 proto dhcp metric 101
192.168.0.0/24 dev enp0s31f6 proto kernel scope link src 192.168.0.254 metric 100
192.168.8.0/24 dev enp0s20f0u8 proto kernel scope link src 192.168.8.100 metric 101
PC2 accesses both the local network and the internet.
When I activate the VPN on PC1
PC1
Code:route
Destination Gateway Genmask Flags Metric Ref Use Iface
default 0.0.0.0 0.0.0.0 U 50 0 0 ppp0
default _gateway 0.0.0.0 UG 101 0 0 enp0s20f0u8
10.2.2.189 0.0.0.0 255.255.255.255 UH 50 0 0 ppp0
93-39-246-242.i _gateway 255.255.255.255 UGH 101 0 0 enp0s20f0u8
192.168.0.0 0.0.0.0 255.255.255.0 U 100 0 0 enp0s31f6
192.168.8.0 0.0.0.0 255.255.255.0 U 101 0 0 enp0s20f0u8
_gateway 0.0.0.0 255.255.255.255 UH 101 0 0 enp0s20f0u8
or
ip route show
default dev ppp0 proto static scope link metric 50
default via 192.168.8.1 dev enp0s20f0u8 proto dhcp metric 101
10.2.2.189 dev ppp0 proto kernel scope link src 10.2.2.200 metric 50
93.39.246.242 via 192.168.8.1 dev enp0s20f0u8 proto static metric 101
192.168.0.0/24 dev enp0s31f6 proto kernel scope link src 192.168.0.254 metric 100
192.168.8.0/24 dev enp0s20f0u8 proto kernel scope link src 192.168.8.100 metric 101
192.168.8.1 dev enp0s20f0u8 proto static scope link metric 101
PC2 only accesses the local network, and cannot access the internet or the VPN.
It seems to me that with the VPN activated, PC1 accesses the internet through the VPN.
This would explain why PC2 cannot even access the internet.
How can I solve the problem of using the VPN on PC2?
It is possible to ensure that the internet traffic of PC1 and PC2 does not pass through the VPN?


PC1
with internet and L2TP/IPsec VPN connection
with NetworkManager to configure network connections
ethernet interface enp0s31f6
internet interface enp0s20f0u8
L2TP/IPsec VPN interface ppp0
PC1 correctly accesses both the internet and the VPN.
PC2
Other pc in the local network
When I disable the VPN on PC1
PC1
Code:route
Destination Gateway Genmask Flags Metric Ref Use Iface
default _gateway 0.0.0.0 UG 101 0 0 enp0s20f0u8
192.168.0.0 0.0.0.0 255.255.255.0 U 100 0 0 enp0s31f6
192.168.8.0 0.0.0.0 255.255.255.0 U 101 0 0 enp0s20f0u8
or
ip route show
default via 192.168.8.1 dev enp0s20f0u8 proto dhcp metric 101
192.168.0.0/24 dev enp0s31f6 proto kernel scope link src 192.168.0.254 metric 100
192.168.8.0/24 dev enp0s20f0u8 proto kernel scope link src 192.168.8.100 metric 101
PC2 accesses both the local network and the internet.
When I activate the VPN on PC1
PC1
Code:route
Destination Gateway Genmask Flags Metric Ref Use Iface
default 0.0.0.0 0.0.0.0 U 50 0 0 ppp0
default _gateway 0.0.0.0 UG 101 0 0 enp0s20f0u8
10.2.2.189 0.0.0.0 255.255.255.255 UH 50 0 0 ppp0
93-39-246-242.i _gateway 255.255.255.255 UGH 101 0 0 enp0s20f0u8
192.168.0.0 0.0.0.0 255.255.255.0 U 100 0 0 enp0s31f6
192.168.8.0 0.0.0.0 255.255.255.0 U 101 0 0 enp0s20f0u8
_gateway 0.0.0.0 255.255.255.255 UH 101 0 0 enp0s20f0u8
or
ip route show
default dev ppp0 proto static scope link metric 50
default via 192.168.8.1 dev enp0s20f0u8 proto dhcp metric 101
10.2.2.189 dev ppp0 proto kernel scope link src 10.2.2.200 metric 50
93.39.246.242 via 192.168.8.1 dev enp0s20f0u8 proto static metric 101
192.168.0.0/24 dev enp0s31f6 proto kernel scope link src 192.168.0.254 metric 100
192.168.8.0/24 dev enp0s20f0u8 proto kernel scope link src 192.168.8.100 metric 101
192.168.8.1 dev enp0s20f0u8 proto static scope link metric 101
PC2 only accesses the local network, and cannot access the internet or the VPN.
It seems to me that with the VPN activated, PC1 accesses the internet through the VPN.
This would explain why PC2 cannot even access the internet.
How can I solve the problem of using the VPN on PC2?
It is possible to ensure that the internet traffic of PC1 and PC2 does not pass through the VPN?