用route添加主机路由所碰到的问题?
这是我的已有的路由表
[root@crazy etc]# route
Kernel IP routing table
Destin[/COLOR]ation G[/COLOR]ateway Genmask Flags Metric Ref Use Iface
192.168.16.0 * 255.255.255.0 U 0 0 0 eth0
169.254.0.0 * 255.255.0.0 U 0 0 0 eth0
127.0.0.0 * 255.0.0.0 U 0 0 0 lo
default 192.168.16.1 0.0.0.0 UG 0 0 0 eth0
假如想添加一条经由192.168.16.100至192.168.18.1这台主机的路由,应该如何添加?
这是我添加的过程,但是报错了,好像是提醒netmask出错
[root@crazy etc]# route add -host 192.168.18.1 netmask 255.255.255.0 gw 192.168.16.100
route: netmask 000000ff doesn't make sense with host route
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 '-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)
我试着将netmask改为0.0.0.0,结果成功了,用rotue查看了一下,
[root@crazy etc]# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.18.1 192.168.16.100 255.255.255.255 UGH 0 0 0 eth0
192.168.16.0 * 255.255.255.0 U 0 0 0 eth0
169.254.0.0 * 255.255.0.0 U 0 0 0 eth0
127.0.0.0 * 255.0.0.0 U 0 0 0 lo
default 192.168.16.1 0.0.0.0 UG 0 0 0 eth0
有一个疑问,难道添加主机路由时netmask一定要设为0.0.0.0吗?(原本C类网的netmask不是一般为255.255.255.0吗?)