题
当我在充当路由器的ubuntu台式计算机上启动VPN时,所连接的子网失去Internet连接,但仍可访问(LAN)。理想情况下,我想知道如何在VPN处于活动状态时通过VPN隧道路由来使连接的子网重新获得Internet访问。
语境
我具有以下网络布局:
我的VirtualBox虚拟机在eth0上的子网172.16.0.0/20。
eth0:0上的子网192.168.0.0/24,它连接到可以访问Internet的网关192.168.0.1。
这显示在/ etc / network / interfaces文件中:
auto lo
iface lo inet loopback
# This is the subnet dedicated to VB
auto eth0
iface eth0 inet static
address 172.16.0.1
netmask 255.255.0.0
gateway 192.168.0.164
dns-nameservers 8.8.8.8
# normal DHCP internet
auto eth0:0
iface eth0:0 inet static
address 192.168.0.164
netmask 255.255.255.0
dns-nameservers 8.8.8.8
gateway 192.168.0.1
伪装通过eth0:0转发eth0上的数据包,并且正常的Internet连接正常。但是,当我在此路由器上启动我的VPN隧道时,eth0子网上的VM失去了Internet连接(但路由器仍然存在)。
下面是隧道处于活动状态时ifconfig的输出:
eth0 Link encap:Ethernet HWaddr 00:1f:bc:01:c3:ab
inet addr:172.16.0.1 Bcast:172.16.255.255 Mask:255.255.0.0
inet6 addr: fe80::21f:bcff:fe01:c3ab/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:165426 errors:0 dropped:0 overruns:0 frame:0
TX packets:182601 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:208264321 (208.2 MB) TX bytes:16660945 (16.6 MB)
Interrupt:16
eth0:0 Link encap:Ethernet HWaddr 00:1f:bc:01:c3:ab
inet addr:192.168.0.164 Bcast:192.168.0.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:16
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:381963 errors:0 dropped:0 overruns:0 frame:0
TX packets:381963 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:22755054 (22.7 MB) TX bytes:22755054 (22.7 MB)
tun0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
inet addr:10.8.0.10 P-t-P:10.8.0.9 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
我怀疑该解决方案将与路由表有关。当隧道处于活动状态时,它将显示以下内容:
Destination Gateway Genmask Flags Metric Ref Use Iface
default 10.8.0.9 128.0.0.0 UG 0 0 0 tun0
default 192.168.0.1 0.0.0.0 UG 100 0 0 eth0
10.8.0.0 10.8.0.9 255.255.255.0 UG 0 0 0 tun0
10.8.0.9 * 255.255.255.255 UH 0 0 0 tun0
37.139.23.49 192.168.0.1 255.255.255.255 UGH 0 0 0 eth0
128.0.0.0 10.8.0.9 128.0.0.0 UG 0 0 0 tun0
link-local * 255.255.0.0 U 1000 0 0 eth0
172.16.0.0 * 255.255.0.0 U 0 0 0 eth0
192.168.0.0 * 255.255.255.0 U 0 0 0 eth0
隧道不活动时的以下内容:
Destination Gateway Genmask Flags Metric Ref Use Iface
default 192.168.0.1 0.0.0.0 UG 100 0 0 eth0
link-local * 255.255.0.0 U 1000 0 0 eth0
172.16.0.0 * 255.255.0.0 U 0 0 0 eth0
192.168.0.0 * 255.255.255.0 U 0 0 0 eth0
Vms的Virtualbox配置:
VM /etc/network/interfaces
文件之一:
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet static
address 172.16.0.3
netmask 255.255.0.0
network 172.16.0.0
broadcast 172.16.255.255
gateway 172.16.0.1
dns-nameservers 8.8.8.8