openvpn 部分子网不可用

openvpn 部分子网不可用

我的“家庭”网络出了问题……我已经绞尽脑汁了一整天,但仍然找不到解决方案。更糟糕的是,我真的无法确定问题的根源 ;(

我有 3 个子网,配置在 3 个不同的服务器上,位于不同的位置:

10.123.45.0/24 - 位置 A

$ ip route list
default via _PUBLIC_IP_ dev enp7s1  metric 2 
10.0.0.0/24 via 10.123.50.5 dev tun0 
10.123.45.0/24 dev br0  proto kernel  scope link  src 10.123.45.1 
10.123.50.0/24 via 10.123.50.5 dev tun0 
10.123.50.5 dev tun0  proto kernel  scope link  src 10.123.50.6 
_PUBLIC_NETWORK_ dev enp7s1  proto kernel  scope link  src _PUBLICK_GW_  metric 2 
127.0.0.0/8 dev lo  scope host 

$ sudo ifconfig tun0
tun0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST>  mtu 1500
    inet 10.123.50.6  netmask 255.255.255.255  destination 10.123.50.5
    unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 100  (UNSPEC)
    RX packets 58491  bytes 33386378 (31.8 MiB)
    RX errors 0  dropped 0  overruns 0  frame 0
    TX packets 68994  bytes 33653956 (32.0 MiB)
    TX errors 0  dropped 28 overruns 0  carrier 0  collisions 0

10.123.50.0/24 - VPS - OpenVPN 服务器

$ ip route list
default via _PUBLIC_IP_ dev eth0 
10.0.0.0/24 via 10.123.50.2 dev tun0 
10.123.45.0/24 via 10.123.50.2 dev tun0 
10.123.50.0/24 via 10.123.50.2 dev tun0 
10.123.50.2 dev tun0  proto kernel  scope link  src 10.123.50.1 
_PUBLIC_NETWORK_ dev eth0  proto kernel  scope link  src _PUBLIC_GW_

$ ifconfig tun0
tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
      inet addr:10.123.50.1  P-t-P:10.123.50.2  Mask:255.255.255.255                                           
      UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1                                               
      RX packets:307740 errors:0 dropped:0 overruns:0 frame:0                                                  
      TX packets:309435 errors:0 dropped:0 overruns:0 carrier:0                                                
      collisions:0 txqueuelen:100                                                                              
      RX bytes:20958272 (19.9 MiB)  TX bytes:66356464 (63.2 MiB)

10.0.0.0/24 - 位置 B

$ ip route list
default via _PUBLIC_IP_ dev eth0 
10.0.0.0/24 dev br0  proto kernel  scope link  src 10.0.0.1 
10.123.45.0/24 via 10.123.50.9 dev tun0 
10.123.50.0/24 via 10.123.50.9 dev tun0 
10.123.50.9 dev tun0  proto kernel  scope link  src 10.123.50.10 
169.254.0.0/16 dev eth0  scope link  metric 1000 
_PUBLIC_NETWORK_ dev eth0  proto kernel  scope link  src _PUBLIC_GW_

$ ifconfig tun0
tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
      inet addr:10.123.50.10  P-t-P:10.123.50.9  Mask:255.255.255.255
      UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1
      RX packets:37791 errors:0 dropped:0 overruns:0 frame:0
      TX packets:37122 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:100 
      RX bytes:7688111 (7.3 MiB)  TX bytes:2624779 (2.5 MiB)

由于某种原因,我无法从 VPS - OpenVPN 服务器和位置 A 访问 IP > 10.0.0.10 的主机

$ ping 10.0.0.12
PING 10.0.0.12 (10.0.0.12) 56(84) bytes of data.
--- 10.0.0.12 ping statistics ---
3 packets transmitted, 0 received, 100% packet loss, time 1999ms

从位置 A 执行 ping 操作可使所有 IP <= 10.0.0.10 的主机正常运行。从位置 B 的服务器执行 ping 操作可使所有 10.0.0.x 中的主机正常运行。

$ ping 10.0.0.10
PING 10.0.0.10 (10.0.0.10) 56(84) bytes of data.
64 bytes from 10.0.0.10: icmp_seq=1 ttl=62 time=59.2 ms
64 bytes from 10.0.0.10: icmp_seq=2 ttl=62 time=56.9 ms
64 bytes from 10.0.0.10: icmp_seq=3 ttl=62 time=57.3 ms
--- 10.0.0.10 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 56.998/57.861/59.230/0.998 ms

当我从位置 B 和 VPS ping 到 A 时,它对所有主机都有效

$ ping 10.123.45.132
PING 10.123.45.132 (10.123.45.132) 56(84) bytes of data.
64 bytes from 10.123.45.132: icmp_seq=1 ttl=63 time=461 ms
64 bytes from 10.123.45.132: icmp_seq=2 ttl=63 time=252 ms
64 bytes from 10.123.45.132: icmp_seq=3 ttl=63 time=416 ms
...

从 tcpdump 角度来看,位置 B 的服务器上发生了以下情况:

$ tcpdump -i br0 src 10.0.0.11 or dst 10.0.0.11 -vv

当我从位置 B 网络 10.0.0.0/24 ping 时,在这种情况下从 10.0.0.1 ping 10.0.0.11

nostromo > 10.0.0.11: ICMP echo request, id 19025, seq 1, length 64
21:52:56.910174 IP (tos 0x0, ttl 64, id 16522, offset 0, flags [none], proto ICMP (1), length 84)
10.0.0.11 > nostromo: ICMP echo reply, id 19025, seq 1, length 64
21:52:57.908878 IP (tos 0x0, ttl 64, id 2419, offset 0, flags [DF],  proto ICMP (1), length 84)
nostromo > 10.0.0.11: ICMP echo request, id 19025, seq 2, length 64
21:52:57.909110 IP (tos 0x0, ttl 64, id 16523, offset 0, flags [none],  proto ICMP (1), length 84)
10.0.0.11 > nostromo: ICMP echo reply, id 19025, seq 2, length 64
21:52:58.907874 IP (tos 0x0, ttl 64, id 2543, offset 0, flags [DF],  proto ICMP (1), length 84)
nostromo > 10.0.0.11: ICMP echo request, id 19025, seq 3, length 64

没关系,我收到了回复

当我在 tcpdump 中从位置 A 10.123.45.0/25 网络 ping 时,我得到:

10.123.45.2 > 10.0.0.11: ICMP echo request, id 8621, seq 17, length 64
21:52:14.645318 IP (tos 0x0, ttl 62, id 2554, offset 0, flags [DF], proto ICMP (1), length 84)
10.123.45.2 > 10.0.0.11: ICMP echo request, id 8621, seq 18, length 64
21:52:15.643949 IP (tos 0x0, ttl 62, id 3048, offset 0, flags [DF],  proto ICMP (1), length 84)
10.123.45.2 > 10.0.0.11: ICMP echo request, id 8621, seq 19, length 64

没有回应,但是为什么???

桥梁配置:

地点 A:

bridge_br0="enp5s0"
config_br0="10.123.45.1/24"
brctl_br0="setfd 0 sethello 10 stp off"

地点 B:

auto br0
iface br0 inet static
bridge_ports eth1
bridge_stp off       
bridge_waitport 0    
bridge_fd 0          
address 10.0.0.1
netmask 255.255.255.0
broadcast 10.0.0.255

我依靠您的智慧,请帮忙。

相关内容