我正在从旧的networking工具转换我的脚本:
ifconfig eth0 192.168.2.1 netmask 255.255.255.0
到iproute2:
ip link set eth0 up ip addr add 192.168.2.1/24 dev eth0
我注意到新的命令默认不会设置广播地址。
什么是:
1: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP link/ether 1c:6f:65:c5:d6:d7 brd ff:ff:ff:ff:ff:ff inet 192.168.2.1/24 brd 192.168.2.255 scope global eth0
就是现在:
1: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP link/ether 1c:6f:65:c5:d6:d7 brd ff:ff:ff:ff:ff:ff inet 192.168.2.1/24 scope global eth0
我可以将广播地址添加到ip addr命令,但我不知道是否需要它? 首先,这个广播地址如何以及在哪里使用? 如果没有设置,可能会破坏什么? 其次,看起来路由表默认情况下仍然有正确的条目:
# ip route show table local dev eth0 scope link broadcast 192.168.2.0 proto kernel src 192.168.2.1 broadcast 192.168.2.255 proto kernel src 192.168.2.1
我甚至不能testing它,因为现在没有人回复ping -b 。
无需手动设置广播地址,从IPnetworking和子网掩码自动确定。