ifconfig doesn't show a valid broadcast address
I'm sort of new at linux networking. I set the ip address of an interface (eth1) as follows...
/sbin/ip link set eth1 down
/sbin/addr addr add 130.30.5.15/24 dev eth1
/sbin/ip link set eth1 up
However, when I type ifconfig
I get...
eth1 Link encap:Ethernet HWaddr 00:0E:0C:E5:F0:B5
inet addr:130.30.5.3 Bcast:0.0.0.0 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:96945 errors:0 dropped:0 overruns:0 frame:0
TX packets:2466 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:6460544 (6.1 Mb) TX bytes:164386 (160.5 Kb)
Base address:0x2000 Memory:b8800000-b8820000
Why is the broadcast 0.0.0.0? Does this mean it will just use the default broadcast (130.30.5.255)? Or is there some way I need to set it? I've tried using this interface but I can't ping any other devices on the network.
Solution 1:
change your call to:
/sbin/ip addr add 130.30.5.15/24 broadcast 130.30.5.255 dev eth1
to get the broadcast correct, guessing 130.30.5.255
is your correct broadcast address.
but be aware that the ip address will vanish with the next reboot. you have to specify it in an interface file to make it permanent. in suse it is e.g. /etc/sysconfig/network/ifcfg-eth1
. there are normally also some gui tools to do the network configuration, in suse it is yast
, in redhat it is system-config-network
.
Solution 2:
I think the correct answer for the question should be:
ip addr add 130.30.5.15/24 brd + dev eth1
This is how iproute2 defines the broadcast address for the network interface.