linux配置路由:
1、 [root@localhost ~]# route add -net 192.168.10.0 netmask 255.255.255.0 gw 192.168.10.1
     SIOCADDRT: No such process //网关指定错误,下一跳必须可达


2、 [root@localhost ~]# route add -net 192.168.10.0 netmask 255.255.255.0 gw 10.43.85.1
    [root@localhost ~]# route -n
    Kernel IP routing table
    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
    2.2.2.0                 0.0.0.0         255.255.255.0   U     0      0        0 eth2
    192.168.10.0    10.43.85.1      255.255.255.0   UG    0      0        0 eth5
3、指定转发接口配置//没有办法穿过局域网
    [root@localhost ~]# route add -net 192.168.10.0 netmask 255.255.255.0
    SIOCADDRT: No such device
    [root@localhost ~]# route add -net 192.168.10.0 netmask 255.255.255.0 dev eth5
    [root@localhost ~]# route -n
    Kernel IP routing table
    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
    2.2.2.0              0.0.0.0         255.255.255.0   U     0      0        0 eth2
    192.168.10.0    0.0.0.0         255.255.255.0   U     0      0        0 eth5
    ....
    [root@localhost ~]# route
    Kernel IP routing table
    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
    2.2.2.0              *               255.255.255.0   U     0      0        0 eth2
    192.168.10.0    *               255.255.255.0   U     0      0        0 eth5

    缺省网关没有办法穿过局域网:

    [root@localhost ~]# route add -net 10.43.42.199 netmask 255.255.255.255 dev eth5
    [root@localhost ~]# route
    Kernel IP routing table
    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
    10.43.42.199    *               255.255.255.255 UH    0      0        0 eth5
    2.2.2.0              *               255.255.255.0   U     0      0        0 eth2

   10.0.0.0        10.43.85.1      255.0.0.0       UG    0      0        0 eth5  //有效网关
    ..........
    [root@localhost ~]# ping 10.43.42.199
    PING 10.43.42.199 (10.43.42.199) 56(84) bytes of data.
    From 10.43.85.162 icmp_seq=1 Destination Host Unreachable
    From 10.43.85.162 icmp_seq=2 Destination Host Unreachable
    ........
    --- 10.43.42.199 ping statistics ---
    15 packets transmitted, 0 received, +12 errors, 100% packet loss, time 14529ms
    pipe 3
    [root@localhost ~]# route del -net 10.43.42.199 netmask 255.255.255.255
    [root@localhost ~]# ping 10.43.42.199
    PING 10.43.42.199 (10.43.42.199) 56(84) bytes of data.
    64 bytes from 10.43.42.199: icmp_seq=1 ttl=59 time=0.397 ms
......

Logo

更多推荐