实践网络命令之route

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
$ route -h
Usage: route [-nNvee] [-FC] [<AF>]           List kernel routing tables
       route [-v] [-FC] {add|del|flush} ...  Modify routing table for AF.

       route {-h|--help} [<AF>]              Detailed usage syntax for specified AF.
       route {-V|--version}                  Display version/author and exit.

        -v, --verbose            be verbose
        -n, --numeric            don't resolve names
        -e, --extend             display other/more information
        -F, --fib                display Forwarding Information Base (default)
        -C, --cache              display routing cache instead of FIB

  <AF>=Use -4, -6, '-A <af>' or '--<af>'; default: inet
  List of possible address families (which support routing):
    inet (DARPA Internet) inet6 (IPv6) ax25 (AMPR AX.25) 
    netrom (AMPR NET/ROM) ipx (Novell IPX) ddp (Appletalk DDP) 
    x25 (CCITT X.25) 

1
2
3
4
5
6
7
$ route add
Usage: inet_route [-vF] del {-host|-net} Target[/prefix] [gw Gw] [metric M] [[dev] If]
       inet_route [-vF] add {-host|-net} Target[/prefix] [gw Gw] [metric M]
                              [netmask N] [mss Mss] [window W] [irtt I]
                              [mod] [dyn] [reinstate] [[dev] If]
       inet_route [-vF] add {-host|-net} Target[/prefix] [metric M] reject
       inet_route [-FC] flush      NOT supported
1
2
3
4
5
6
7
8
# route add default gw 140.207.91.161
# route add -net 192.168.0.0 netmask 255.255.255.0 gw 192.168.1.1
# route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.1.1
# route add -net 192.168.168.0 netmask 255.255.255.0 gw 192.168.1.1
# route add -net 192.168.0.0 netmask 255.255.255.0 gw 192.168.1.10

# route add -net 192.168.168.0 netmask 255.255.255.0 eth0
# route add -net 192.168.1.0/24 eth1