Estamos tentando resolver esse problema de roteamento aparentemente simples por dias. Estamos tentando encaminhar o tráfego através de um túnel OpenVPN. Especificamente, o tráfego para 10.0.1.136 deve ser roteado através de nossa interface de túnel. Assim, adicionamos a rota "10.0.1.0/24 via 10.0.2.1 dev tun0 métrica 101" via ip route. No entanto, como você pode ver abaixo, se fizermos um "ip route get 10.0.1.136", a interface eth0 será selecionada.
Nós tentamos:
O que estamos perdendo? Há algum problema óbvio em nossa tabela de roteamento?
xx@xx:~$ ip route
default via 192.168.10.150 dev eth0
10.0.0.2 via 10.0.2.1 dev tun0 metric 101
10.0.1.0/24 via 10.0.2.1 dev tun0 metric 101
10.0.2.0/24 dev tun0 proto kernel scope link src 10.0.2.50
169.254.0.0/16 dev eth0 scope link metric 1000
172.16.0.0/16 via 172.16.0.100 dev tap0
192.168.10.0/24 dev eth0 proto kernel scope link src 192.168.10.100
192.168.20.0/24 via 192.168.10.1 dev eth0
xx@x:~$ sudo ip route get 10.0.1.136
10.0.1.136 via 192.168.10.150 dev eth0 src 192.168.10.100
cache
xx@xx:~$ ifconfig
eth0 Link encap:Ethernet HWaddr 44:8a:5b:57:a7:68
inet addr:192.168.10.100 Bcast:192.168.10.255 Mask:255.255.255.0
inet6 addr: fe80::468a:5bff:fe57:a768/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:711182 errors:0 dropped:237 overruns:0 frame:0
TX packets:715366 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:88619834 (88.6 MB) TX bytes:86802607 (86.8 MB)
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:12623 errors:0 dropped:0 overruns:0 frame:0
TX packets:12623 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1388042 (1.3 MB) TX bytes:1388042 (1.3 MB)
tap0 Link encap:Ethernet HWaddr 16:20:92:30:1c:9d
inet addr:172.16.0.100 Bcast:172.16.0.255 Mask:255.255.255.0
inet6 addr: fe80::1420:92ff:fe30:1c9d/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:4759 errors:0 dropped:183 overruns:0 frame:0
TX packets:6654 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:500
RX bytes:497307 (497.3 KB) TX bytes:469035 (469.0 KB)
tun0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
inet addr:10.0.2.50 P-t-P:10.0.2.50 Mask:255.255.255.0
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:264830 errors:0 dropped:0 overruns:0 frame:0
TX packets:259659 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:21013005 (21.0 MB) TX bytes:23064408 (23.0 MB)