Linux – responsible of setting up the default broadcast address

busyboxlinuxnetworking

The broadcast address is apparently misconfigured on some (old) Linux embedded device that I setup (but that I don't own anymore) because it doesn't match the expected value given the IP address and the netmask (for example, it has a broadcast of 192.168.70.255 instead of 192.168.71.255 for 192.168.70.243/255.255.254.0). It runs a kernel 2.4.31 with busybox 0.60.5. The network configuration is simply done with that shell snippet:

ifconfig eth0 $IPADDR netmask $NETMASK
if [ -n "$GATEWAY" ]; then
    route add default gw $GATEWAY
fi

Thus the broadcast address is not explicitely configured. The question is: what is responsible of this bad behaviour? Is it busybox's ifconfig that doesn't set the broadcast address correctly or is it the kernel that set it up badly?

Note: it's possible that none of them are responsible but something else gets in the way in the boot process (and reconfigures it badly) as the device runs user-specific software that I don't know. I will follow up with more info once I have them.

Best Answer

Starting investigations on the topic I discovered with strace that changing the broadcast address with ifconfig leads to a supplementary ioctl() call (SIOCSIFBRDADDR - Set InterFace BRoadcast ADDRess) that doesn't appear in the normal trace when you leave out the broadcast parameter. So it looks like that ifconfig doesn't deal with the broadcast address in the default case and leave that up to the kernel.