Different broadcast address when adding new IP

Tristan

Verified User
Joined
Feb 11, 2005
Messages
590
Location
The Netherlands
Hi there,

does anyone know why I have a different broadcast address for all IP's added through DA? For example if I add xxx.xxx.138.35 through the admin panel, ifconfig will give me back:

Code:
eth0      Link encap:Ethernet  HWaddr 00:3A:4F:8D:2A:9C
          inet addr:xxx.xxx.138.34  Bcast:xxx.xxx.138.[B]255[/B]  Mask:255.255.255.128
          inet6 addr: fe80::130:48af:fa8d:1a9c/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:15916904 errors:0 dropped:0 overruns:0 frame:0
          TX packets:7813789 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100
          RX bytes:23378203328 (21.7 GiB)  TX bytes:557723675 (531.8 MiB)
          Base address:0x4000 Memory:e0200000-e0220000

eth0:0    Link encap:Ethernet  HWaddr 00:3A:4F:8D:2A:9C
          inet addr:xxx.xxx.138.35  Bcast:xxx.xxx.138.[B]127[/B]  Mask:255.255.255.128

Shouldn't eth0:0 be using the same broadcast address?
 
Hello,

The broadcast address is determined by mashing the IP and the netmask together by doing a logical boolean "and" between them among other things. If you want to check the code we use to set it up, it's in:

/usr/local/directadmin/scripts/addip

under the getBroadcast() function.

eg:
Code:
getBroadcast() {

        IP1=`echo $1 | cut -d. -f1`;
        IP2=`echo $1 | cut -d. -f2`;
        IP3=`echo $1 | cut -d. -f3`;
        IP4=`echo $1 | cut -d. -f4`;

        NM1=`echo $2 | cut -d. -f1`;
        NM2=`echo $2 | cut -d. -f2`;
        NM3=`echo $2 | cut -d. -f3`;
        NM4=`echo $2 | cut -d. -f4`;

        BC1=$((($IP1 & $NM1) | (255 & ~$NM1)));
        BC2=$((($IP2 & $NM2) | (255 & ~$NM2)));
        BC3=$((($IP3 & $NM3) | (255 & ~$NM3)));
        BC4=$((($IP4 & $NM4) | (255 & ~$NM4)));

        BROADCAST="$BC1.$BC2.$BC3.$BC4";
}

John
 
tristan,

Because you've munged your IP#s there's now way to determine what the proper broadcast address should be.

The broadcast address should always be the highest address in your network. Your network is configured by your upstream provider and if they're subnetting properly DA should be able to figure it out.

Jeff
 
Hi Guys,

sorry about that, I actually forgot to change the broadcast ip address (of the main server ip) on this server when moving it to the datacenter, the correct broadcast address actually was xxx.xxx.138.127 since netmask was 255.255.255.128 and ip was at xxx.xxx.138.35. Maybe I shouldn't install servers this late any more in the future. Thanks for your replies though.

Regards,

Tristan
 
Back
Top