A
A
Alex Efros2012-12-25 18:25:49
linux
Alex Efros, 2012-12-25 18:25:49

Does it make sense to manually specify broadcast for interfaces?

I decided to stop using net-tools and iproute2 at the same time and moved my scripts from
ifconfig eth0 192.168.2.1 netmask 255.255.255.0to

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

But upon careful comparison of the result, it turned out that the second option does not set broadcast.
It 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
became:
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

Of course, I can add it with pens to ip addr, but the question arose: is it even necessary? And if so, to whom and for what? Moreover, it seems to have prescribed routing like this:
# 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

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
EvilMan, 2012-12-26
@EvilMan

There is not much difference, the main thing is that broadcast routes are present in the local table. But here you need to look at the situation: I saw examples of dhcp server autoconfiguration scripts that dropped it (dhcp server) without a broadcast address on the interface.
You can also use a structure like this:

ip addr add 192.168.2.1/24 brd + dev eth0

In this case, the broadcast address will be calculated automatically.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question