问题原文
原帖链接 · karlsebal · CC BY-SA 4.0
In man interfaces for /etc/network/interfaces on Debian:
The static Method
This method may be used to define Ethernet interfaces with statically allocated IPv4 addresses.
Options
broadcast
broadcast_address
Broadcast address (dotted quad, + or -). Default value: "+"
What do + and - mean here?
已采纳解答
原帖链接 · A.B · CC BY-SA 4.0
On Linux, when using the ip address command, which ifupdown does use on Debian 10 (and 9 and perhaps a few former versions), rather than the ifconfig command, + and - for broadcast mean, after separating the network part of the IPv4 address (with a /xx address, the first xx bits, which will be left untouched) and the host part of the IP address (the remaining 32-xx bits) to set all host bits to resp 1 and 0 for + and - when computing the broadcast address. It's also possible to choose any arbitrary IP in this network to be used as broadcast (that's the dotted quad option). The resulting IP chosen from any of the 3 previous ways will be the reserved destination IP that (at least on Ethernet interfaces) will be associated to the broadcast link layer address (so ff:ff:ff:ff:ff:ff on Ethernet).
Here are a few examples:
# ip link add name test type dummy
# ip link set test up
# ip address add 192.0.2.5/24 broadcast + dev test
# ip address add 198.51.100.20/28 broadcast - dev test
# ip address add 203.0.113.130/24 broadcast 203.0.113.100 dev test
# ip -4 address show dev test
4: test: <BROADCAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default qlen 1000
inet 192.0.2.5/24 brd 192.0.2.255 scope global test
valid_lft forever preferred_lft forever
inet 198.51.100.20/28 brd 198.51.100.16 scope global test
valid_lft forever preferred_lft forever
inet 203.0.113.130/24 brd 203.0.113.100 scope global test
valid_lft forever preferred_lft forever
# ip route get 203.0.113.100
broadcast 203.0.113.100 dev test src 203.0.113.130 uid 0
cache <local,brd>
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
