assigning multiple IP address to one interface via dhcpd

assigning multiple IP address to one interface via dhcpd

Post by Nejat AYDI » Sun, 06 Jun 2004 02:22:49



Hi,

I wonder if it is possible to assign multiple IP addresses to
a dhcp client's interface via dhcpd (based on the interface's MAC).
If so, what would the configuration (dhcpd.conf file) on the
server side look like ?

 
 
 

assigning multiple IP address to one interface via dhcpd

Post by Ed » Mon, 07 Jun 2004 02:57:43



> Hi,

> I wonder if it is possible to assign multiple IP addresses to
> a dhcp client's interface via dhcpd (based on the interface's MAC).
> If so, what would the configuration (dhcpd.conf file) on the
> server side look like ?

The following is my personal config.  It will assign an IP depending on
the MAC.  Hope this helps.  BTW, all in the man pages...

# dhcpd.conf
#
# Configuration file for ISC dhcpd (see 'man dhcpd.conf')
#

default-lease-time 28800;
max-lease-time 43200;
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.1.255;
option routers 192.168.0.1;
option domain-name-servers 192.168.0.1, 212.10.160.1, 212.10.160.2;
# rem domain-name for nslookup probs
option domain-name "domain.com";
# added as stated in dhcpd.conf man page
ddns-update-style ad-hoc;

subnet 192.168.0.0 netmask 255.255.255.0 {
#       range 192.168.0.10 192.168.0.20;

Quote:}

host pc-1 {
        hardware ethernet 99:99:99:99:99:14;
        fixed-address 192.168.0.10;

Quote:}

host w2k {
        hardware ethernet 99:99:99:99:99:13;
        fixed-address 192.168.0.11;

Quote:}

host pc-6 {
        hardware ethernet 99:99:99:99:99:12;
        fixed-address 192.168.0.19;

Quote:}

host pc-3 {
        hardware ethernet 99:99:99:99:99:11;
        fixed-address 192.168.0.20;

Quote:}

Hope this helps,
Ed.

 
 
 

assigning multiple IP address to one interface via dhcpd

Post by Nejat AYDI » Mon, 07 Jun 2004 21:59:25




> > Hi,

> > I wonder if it is possible to assign multiple IP addresses to
> > a dhcp client's interface via dhcpd (based on the interface's MAC).
> > If so, what would the configuration (dhcpd.conf file) on the
> > server side look like ?

> The following is my personal config.  It will assign an IP depending on
> the MAC.  Hope this helps.  BTW, all in the man pages...

[...]

Sorry, this is not the answer to my question. What you have done is
to assign one IP address to one interface via dhcp, which is trivial
and I know how to do. But I want to assign *multiple* IP addresses to
one interface (ie, IP aliasing), via dhcp.

 
 
 

assigning multiple IP address to one interface via dhcpd

Post by Rudolf Potuce » Tue, 08 Jun 2004 03:09:55


Look on deja ... I have variously been looking for this and have always
discarded it as impractical even thought the solution is described out
there ... apparently there is another dhcp client that will do it but I
never tried.

  Rudolf

 [Snip]pets of what Nejat AYDIN
:>

:>
:> > Hi,
:> >
:> > I wonder if it is possible to assign multiple IP addresses to
:> > a dhcp client's interface via dhcpd (based on the interface's MAC).
:> > If so, what would the configuration (dhcpd.conf file) on the
:> > server side look like ?
:>
:> The following is my personal config.  It will assign an IP depending on
:> the MAC.  Hope this helps.  BTW, all in the man pages...

: [...]

: Sorry, this is not the answer to my question. What you have done is
: to assign one IP address to one interface via dhcp, which is trivial
: and I know how to do. But I want to assign *multiple* IP addresses to
: one interface (ie, IP aliasing), via dhcp.

--
The biggest spendings on MY credit card are Pizza ...
... and Patents.
        Rudolf, Dec. 15, 2002

 
 
 

assigning multiple IP address to one interface via dhcpd

Post by Cameron Ker » Tue, 08 Jun 2004 09:26:10



> I wonder if it is possible to assign multiple IP addresses to
> a dhcp client's interface via dhcpd (based on the interface's MAC).

Certainly, in theory, but you'll need to do a few things.

If you want to assign by MAC address, then every virtual interface must
have a distinct MAC address.

By default, aliased MAC interfaces (eth0:1 for instance) all have the
same MAC address. It appears that I can't change this (using 'ifconfig
eth0:1 hw ether NEWMACADDR'). I get 'Device or resource busy' when I
try.

It would not be a great idea to do it this way anyway, as you would need
to be very cautious as to how you allocate MAC addresses so they don't
clash. (Although changing the first three bytes should be relatively
safe).

I think a better idea may be to allocate using a DHCP name. I've never
done this before, so I can't tell you what's involved. But you would
need to run the client for each interface, so that you can tell the
client to use a different name for each interface. If the machine is
called 'bob', then you would run your dhcp client advertising a name of
'bob-eth0:1' for instance, repeating for each virtual interface.

If you're using Debian, you could put the following in
/etc/network/interfaces. You should use the dhcpcd client. I've tried
this (unsuccessfully) using dhclient, and I doubt pump is flexible
enough to allow you to specify a client-identifier on the command line.

auto eth0
iface eth0 inet dhcp

auto eth0:0
iface eth0:0 inet dhcp
    client_id bob-eth0:0

auto eth0:1
iface eth0:1 inet dhcp
    client_id bob-eth0:1

Now, let's see if I can take a crack at setting up dhcpd to use
client_id as a basis for handing out names.

Here is a relevant section (abridged) from dhcpd.conf(5)

       Host declarations are matched to actual DHCP or BOOTP clients by
       matching the dhcp-client-identifier option specified in the
       host declaration to the one supplied by the client, or, if the
       host declaration or the client does not provide a
       dhcp-client-identifier option, by matching the hardware
       parameter in the host declaration to the network hardware address
       supplied by the client. [...]

       Please be aware that only the dhcp-client-identifier option
       and the hardware address can be used to match a host
       declaration. [...]

So, given that I'm requesting the MAC-based address for eth0, and
client_id-based addresses for the aliased interfaces, this should
hopefully work.

    host bob {
            hardware ethernet 00:40:F4:6F:BB:F0;
            fixed-address bob.localdomain;
    }

    host bob-eth0_0 {
            option dhcp-client-identifier "bob-eth0:0";
            fixed-address 10.18.2.50;
    }

    host bob-eth0_1 {
            option dhcp-client-identifier "bob-eth0:1";
            fixed-address 10.18.2.51;
    }

Testing this however, is a pain. I've tried with dhclient and dhcpcd.
Neither of which was happy to configure an interface that didn't exist
at the time. Of the two, dhcpcd would probably be preferable, as it
allows for a command-line option to specify the client identifier.

When I 'ifconfig eth0:0 up', it fails (Cannot assign requested address).
Seems as if it must be given an address to be created, it's not enough
to just have it 'UP'. I consider this a bug.

dhcpcd won't even configure the interface if I configure it with a dummy
address of 127.0.0.1 first (it say's the interface has been configured
with it's old address. I wonder if it gets confused because of the
colon?

In conclusion, you probably could do it, but getting your clients to
wrangle the task correctly could take a lot of work.

--
Cameron Kerr

Empowered by Perl!