Find the answer to your Linux question:
Results 1 to 4 of 4
The interfaces file looks like below: Code: auto lo iface lo inet loopback auto eth0 iface eth0 inet static address 192.168.0.130 netmask 250.255.255.0 gateway 192.168.0.254 As you can see the ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Dec 2011
    Posts
    5

    What does ifup do when “interfaces” file has an invalid netmask?


    The interfaces file looks like below:
    Code:
    auto lo
    iface lo inet loopback
    
    auto eth0
    iface eth0 inet static
        address 192.168.0.130
        netmask 250.255.255.0
        gateway 192.168.0.254
    As you can see the netmask address is sort of invalid. (250 instead of 255) The problem is when I use the following code to get the current IP address and netmask:

    Code:
    ioctl(iSock, SIOCGIFADDR, &stIFReq);
    ioctl(iSock, SIOCGIFNETMASK, &stIFReq);
    It always returns "72,0,xxx,xxx" (the last two octets seem to change depending on the device, but always constant for the same device) on both ioctl functions. I wonder if this is some sort of error code or bug during ifup. I would like to know what type of checking ifup does on netmasks/ip addresses and what does it do if the address is judged as invalid.

    What steps can be taken to recover from a "bad" netmask address setting and maybe run a default "255.255.255.0" address?

    Thanks.

    Additional info:
    Linux version 2.6.35.3, running on an ARM cpu embedded system
    BusyBox v1.18.5
    [ifup] is not a script but a C program on the system

  2. #2
    Linux Enthusiast
    Join Date
    Jan 2005
    Location
    Saint Paul, MN
    Posts
    645
    Actually 250 is a valid netmask value, and it could work in the upper octet as well. However, in networking it keeps things much simpler to use the complete upper bits as net mask bits. In the late 90s I worked at a company that used a couple if upper bits for host addressing (each was a gateway machine in separate locations. In your case the "gateway" and your netmask will not work together.

  3. #3
    Just Joined!
    Join Date
    Dec 2011
    Posts
    5
    Yes, 250 is not actually invalid. I just used the term because whenever it is set as such, or any value with a discontinued bits of 1's, it seems to be judged as invalid by ifup. Is there anyway to prevent ifup from judging it as invalid? Or is there any reason why it is passed down as an error?

  4. #4
    Linux Enthusiast
    Join Date
    Jan 2005
    Location
    Saint Paul, MN
    Posts
    645
    Are you doing:

    Code:
    ifup eth0 192.168.0.130  netmask=250.255.255.0 broadcast=197.168.0.255
    route add gw 192.168.0.254 eth0

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •