Static IP configuration

Michael Senizaiz trellph at gmail.com
Fri Feb 3 16:20:24 CET 2012


I've read the documentation as well as the source code.  It appears FAI
does not support Static network booting to the NFS root when a DHCP server
isn't available on that subnet.  Additionally the documentation is wrong
for setting static IP's, as well as inconsistent with other parts of the
code.

1.  Static IP address syntax

The doc says:
ip=<client-ip>:<server-ip>:<gw-ip>:<netmask>:<hostname>:<device>:<autoconf>

However this still tries to DHCP.  If I set this and have it do a non-nfs
installation the /etc/network/interfaces on the host gets written as

iface <IPADDR> inet static
   address (just blank)

So it's putting the IP where the DEVICE should be, and not setting an IP.

The code uses the /bin/ipconfig in the initrd.

Strings shows that this actually reads in the ip= variables as:
DEVICE:IPV4ADDR:IPV4BROADCAST:IPV4NETMASK:IPV4GATEWAY:IPV4DNS0:IPV4DNS1:HOSTNAME:DNSDOMAIN:NISDOMAIN:ROOTSERVER:ROOTPATH:filename

This should be consistent so if you are doing DHCP and the server doesn't
set some vars you can do ip=eth0:::::::HOST::NIS:ROOTSERVER:PATH:filename

Also, the code does this:

        for ifline in ${parsed}
        do
                ifname="$(echo ${ifline} | cut -f1 -d ':')"
                ifaddress="$(echo ${ifline} | cut -f2 -d ':')"
                ifnetmask="$(echo ${ifline} | cut -f3 -d ':')"
                ifgateway="$(echo ${ifline} | cut -f4 -d ':')"

So ip=DEVICE:IPADDR:MASK:GATEWAY here.  Not DEV:IP:BROADCAST:MASK:GW as
above.  If static works I'm not certain some variables would be set
correctly.

2. DHCP Issues
However, if I do an NFS install it still tries to DHCP.  I set the 'nodhcp'
flag, and it still tries to dhcp.

Looking at the code it unsets the DHCP flag, but ipconfig doesn't seem care
about this.  There should be a separate stanza for device configuration
depending on the DHCP flag to configure the device statically.

Additionally, the 'nodhcp' flag kind of gets overwritten with this in the
scripts/live and forces DHCP even if nodhcp and a static IP are set :

        # sort of compatibility with netboot.h from linux docs
        if [ -z "${NETBOOT}" ]
        then
                if [ "${ROOT}" = "/dev/nfs" ]
                then
                        NETBOOT="nfs"
                        export NETBOOT
                elif [ "${ROOT}" = "/dev/cifs" ]
                then
                        NETBOOT="cifs"
                        export NETBOOT
                fi

Then in the networking script:

       if [ -z "${NETBOOT}" ] || [ -n "${DHCP}" ]
        then
                # default, dhcp assigned
                method="dhcp"
        else
                # make sure that the preconfigured interface would not get
reassigned by dhcp
                # on startup by ifup script - otherwise our root fs might
be disconnected!
                method="manual"
        fi

And it doesn't try to set statically if using /dev/nfs like above

if [  -z "${NETBOOT}" -a -n "${STATICIP}" -a "${STATICIP}" != "frommedia" ]
then
        parsed=$(echo "${STATICIP}" | sed -e 's/,/ /g')

        for ifline in ${parsed}
        do
                ifname="$(echo ${ifline} | cut -f1 -d ':')"


As we can see here if we use NFS it forces DHCP per the above.

This tells FAI that - hey, if you are doing a network install, it HAS to be
DHCP.  No bueno.

I'll be modifying my code on this end (hacking).  Let me know if I'm
missing something and need to change my config for a static network isntall.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.uni-koeln.de/pipermail/linux-fai/attachments/20120203/0bf7becf/attachment.html>


More information about the linux-fai mailing list