Linux Networking – Is It Necessary to Manually Set the Interface Broadcast Address?

iproute2linux

I'm converting my scripts from old net-tools:

ifconfig eth0 192.168.2.1 netmask 255.255.255.0

to iproute2:

ip link set eth0 up
ip addr add 192.168.2.1/24 dev eth0

and I notice that the new commands do not set the broadcast address by default.

What was:

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

is now:

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

I can add the broadcast address to ip addr command, but I wonder if it is needed at all?
First of all, how and where is this broadcast address used? What might break if it is not set?
Second of all, it looks like the routing table still has the correct entries by default:

# 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 

I cannot even test it because nowadays no one replies to ping -b.

Best Answer

There is no need to set the broadcast address manually, it is determined automatically from the IP network and subnet mask.