如何使用 1.1.1.35 作为网关以通过以下配置访问 2.2.2.168/29 (.248)?我可以 ping 1.1.1.35,所以它是可以访问的。当我跟踪它时,它使用网关 1.1.1.1。
# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 1.1.1.1 0.0.0.0 UG 0 0 0 eth1
10.30.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
10.40.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
10.50.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
192.168.200.100 10.40.2.1 255.255.255.255 UGH 0 0 0 eth0
192.168.200.101 10.40.2.1 255.255.255.255 UGH 0 0 0 eth0
192.168.200.102 10.40.2.1 255.255.255.255 UGH 0 0 0 eth0
1.1.1.0 0.0.0.0 255.255.255.224 U 0 0 0 eth1
# ip route list
default via 1.1.1.1 dev eth1
10.30.2.0/24 dev eth0 scope link
10.40.2.0/24 dev eth0 proto kernel scope link src 10.40.2.36
10.50.2.0/24 dev eth0 scope link
192.168.200.100 via 10.40.2.1 dev eth0
192.168.200.101 via 10.40.2.1 dev eth0
192.168.200.102 via 10.40.2.1 dev eth0
1.1.1.0/27 dev eth1 proto kernel scope link src 1.1.1.10
eth0 Link encap:Ethernet HWaddr .....
inet addr:10.40.2.36 Bcast:10.40.2.255 Mask:255.255.255.0
eth1 Link encap:Ethernet HWaddr .....
inet addr:1.1.1.10 Bcast:1.1.1.31 Mask:255.255.255.224
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
root@mymachine:~# route add -net 2.2.2.168 netmask 255.255.255.248 gateway 1.1.1.35
SIOCADDRT: Network is unreachable
traceroute to 1.1.1.35 (1.1.1.35), 30 hops max, 60 byte packets
1 1.1.1.1 (1.1.1.1) 0.224 ms 0.207 ms 0.194 ms
2 * * *
3 * * *
PING 1.1.1.35 (1.1.1.35) 56(84) bytes of data.
64 bytes from 1.1.1.35: icmp_seq=1 ttl=63 time=0.362 ms