https://unix.stackexchange.com/questions/222054/how-can-i-use-linux-as-a-gateway
我以此为基础,可以 ping 通另一个网关 10.0.0.1,但即使这是计算机 A 上的默认网关,对外界的请求也不会进一步转发。
假设我有一台带有 2 个接口的计算机 A:
wlp2s0b1: 10.0.0.100
enp1s0f0: 192.168.0.100
计算机 B 具有:
eth0: 192.168.0.101
现在我可以 ping 10.0.0.1,但流量似乎没有传到外面。我无法访问 10.0.0.1 设备上的任何配置
设备上的路由:
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 192.168.0.100 0.0.0.0 UG 0 0 0 eth0
192.168.0.0 * 255.255.255.0 U 0 0 0 eth0
网关1上的路由:
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 10.0.0.1 0.0.0.0 UG 600 0 0 wlp2s0b1
10.0.0.0 0.0.0.0 255.255.255.0 U 600 0 0 wlp2s0b1
192.168.0.0 0.0.0.0 255.255.255.0 U 100 0 0 enp1s0f0
Iptables网关1:
Chain INPUT (policy ACCEPT 9841 packets, 3893K bytes)
pkts bytes target prot opt in out source destination
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
6 504 ACCEPT all -- enp1s0f0 wlp2s0b1 anywhere anywhere
6 504 ACCEPT all -- wlp2s0b1 enp1s0f0 anywhere anywhere state RELATED,ESTABLISHED
Chain OUTPUT (policy ACCEPT 13103 packets, 1261K bytes)
pkts bytes target prot opt in out source destination