Re: assigning multiple IP address to one interface via dhcpd
From: Cameron Kerr (cameron.kerr_at_paradise.net.nz)
Date: 06/07/04
- Next message: Cameron Kerr: "Re: about rpc shutdown windows xp"
- Previous message: JSH: "Trouble Installing Linux/Cisco VPN Client Has anyone had trouble compiling the linux cisco vpn client? Here is the output of the install script: # uname -rviosm Linux 2.4.22-1.2188.nptl #1 Wed Apr 21 20:19:18 EDT 2004 x86_64 x86_64 GNU/Linux"
- In reply to: Nejat AYDIN: "assigning multiple IP address to one interface via dhcpd"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 7 Jun 2004 12:26:10 +1200
Nejat AYDIN <nejataydin@superonline.com> wrote:
> 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 cameron.kerr@paradise.net.nz : http://nzgeeks.org/cameron/ Empowered by Perl!
- Next message: Cameron Kerr: "Re: about rpc shutdown windows xp"
- Previous message: JSH: "Trouble Installing Linux/Cisco VPN Client Has anyone had trouble compiling the linux cisco vpn client? Here is the output of the install script: # uname -rviosm Linux 2.4.22-1.2188.nptl #1 Wed Apr 21 20:19:18 EDT 2004 x86_64 x86_64 GNU/Linux"
- In reply to: Nejat AYDIN: "assigning multiple IP address to one interface via dhcpd"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|