Using DHCP to get multiple IP addresses on single NIC on RedHat

2


I am trying to obtain multiple IP addresses using the ISC dhclient supplied with Red Hat Enterprise Linux 5 in order to provide the IPs to multiple applications, which will run on separate virtual interfaces (such as eth0:1, eth0:2) other than the some running on the physical interface.

For this, I have created files in the path "/etc/sysconfig/network-scripts/ifcfg-eth0:", where N is for aliasing.

The content of the files for virtual interfaces are similar to eth0 and as follows:

    DEVICE=eth0:1
    BOOTPROTO=dhcp
    HWADDR=xx:xx:xx:xx:xx:xx
    ONBOOT=yes
    TYPE=Ethernet
    USERCTL=no
    IPV6INIT=no
    PEERDNS=yes

Here the value of HWADDR is the value of the MAC address of the NIC and same as that in eth0.

Other than that, for the DHCP client to accept multiple IPs on the single NIC, I am using a custom client identifier field for the virtual interfaces in the "/etc/dhclient.conf" file, it's content are as follows:

    send dhcp-lease-time 3600;
    require subnet-mask, domain-name-servers;
    timeout 60;
    retry 60;
    select-timeout 5;
    interface "eth0"{
    send dhcp-client-identifier "1:xx:xx:xx:xx:xx:xx";
    }
    interface "eth0:1" {
    send dhcp-client-identifier "1:xx:xx:xx:xx:xx:xx-eth01"; 
    }
    interface "eth0:2" {
    send dhcp-client-identifier "1:xx:xx:xx:xx:xx:xx-eth02";
    }
    initial-interval 2;

But during the boot time, IP for only eth0, that is the physical interface is successfully obtained from the DHCP server during the boot time and the following message is displayed

   Determining IP information for eth0... done. 

while for the virtual interfaces,the following error is shown at the boot time:

   error in ifcfg-eth0:1: didn't specify device or ipaddr
   error in ifcfg-eth0:2: already seen ipaddr in ifcfg-eth0:1

And eventually, the dhcp lease file is also created only for eth0, not the virtual interfaces.

For reference, I am providing the link where such application is assumed to be complete (https://serverfault.com/questions/363695/using-dhcp-with-multi-homed-nics/363700#363700) and other than that, the dhclient itself has a "-I" option to provide custom client identifier with the command line (which also doesn't work).

Kindly help.

Thanks and regards for valuable inputs.

Abisks

Posted 2014-03-12T12:02:34.520

Reputation: 21

Are you sure your DHCP server understands / obeys dhcp-client-identifier option? – Tero Kilkanen – 2014-03-12T15:05:19.137

@TeroKilkanen, yes, because the physical interface is able to get the IP address. – Abisks – 2014-03-13T03:42:53.943

I don't think that gives any guarantees that the server understands the dhcp-client-identifier option. It means only that the server hands out one IP address per physical MAC address. – Tero Kilkanen – 2014-03-13T05:53:43.980

@TeroKilkanen Can you suggest me the changes to be taken care of on the server in order to make it understand the dhcp-client-identifier option. Thanks for the response. – Abisks – 2014-03-13T11:57:20.097

Unfortunately I don't know more about the required configuration. – Tero Kilkanen – 2014-03-13T12:05:37.403

No answers