我想在内核路由表中添加一个范围在 224.0.0.0 – 239.255.255.255 内的 IP(多播 228.0.0.4),因此我使用了
sudo route -nv add -net 228.0.0.4 -interface eth0
但它给了我:
root@macavity:/home/gaiz# route -nv add -net 228.0.0.4 -interface eth0
route: invalid option -- 'i'
route: invalid option -- 't'
route: invalid option -- 'r'
route: invalid option -- 'f'
route: invalid option -- 'a'
route: invalid option -- 'c'
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)
我的路线表:
root@macavity:/home/gaiz# netstat -r
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
default dsldevice.lan 0.0.0.0 UG 0 0 0 wlan0
192.168.1.0 * 255.255.255.0 U 0 0 0 wlan0
以及我当前的网络配置信息
root@macavity:/home/gaiz# ifconfig -a
eth0 Link encap:Ethernet HWaddr 24:b6:fd:4a:15:ca
inet6 addr: fe80::26b6:fdff:fe4a:15ca/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:268 errors:0 dropped:0 overruns:0 frame:0
TX packets:107 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:16136 (16.1 KB) TX bytes:15102 (15.1 KB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:2444 errors:0 dropped:0 overruns:0 frame:0
TX packets:2444 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:393755 (393.7 KB) TX bytes:393755 (393.7 KB)
wlan0 Link encap:Ethernet HWaddr e0:06:e6:79:60:49
inet addr:192.168.1.64 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::e206:e6ff:fe79:6049/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:92082 errors:0 dropped:0 overruns:0 frame:0
TX packets:63686 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:112279263 (112.2 MB) TX bytes:8760358 (8.7 MB)
答案1
恐怕我不太了解多播,但您的命令的问题在于“-interface”。它应该看起来像这样:
sudo route -nv add -net 228.0.0.4 dev eth0
从man route
页面上看,有一个例子:
route add -net 224.0.0.0 netmask 240.0.0.0 dev eth0
This is an obscure one documented so people know how to do it.
This sets all of the class D (multicast) IP routes to go via
"eth0". This is the correct normal configuration line with a
multicasting kernel.