大网数据广告活动
服务器运维问答

What does broadcast +/- mean in /etc/network/interfaces?

· 52CE 我爱测

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 (dot…

问题原文

原帖链接 · 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> 

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2019-11-05)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。