multiple ip via dhcp

Gerald Combs gerald at zing.org
Sun Jun 13 16:49:16 CDT 2004


Kendrick-LUG wrote:
> I am wondering if there is a way to set up the lo to have a mac addr and
> use it to pick up the other 3 ip addreses for my boxes.
> I am wanting to get 3 to 4 ip's being used via dhcp since dhclient wont
> allow multiple ip's via one card.
> I want to use the mac's of the internal network and set it up so that i
> could have services on eth1 mac a  server   do most serving of stuff but
> some private stuf be on lo(orth eth1:1) 2 and 3 mac b and c wich
> corospond with the 2 work stations.  yet keep the 2 ws on private lan.

As far as I know, you can't assign a MAC address to a loopback interface
(at least not easily).  MAC (Media Access Control) addresses are used to
identify pieces of hardware on a network, and they can only be applied
to a few specific media types.  You can apply MAC addresses to Ethernet,
802.11, Token Ring, and FDDI interfaces, but not PPP, SLIP, or loopbacks.

DHCP uses a field called the "client identifier" to hold a unique key
for each client.  Normally this contains the client's MAC address, but
it can be any string.  You can grab multiple DHCP leases using the same
MAC address as long as you use a unique client identifier for each lease.

You say you're running "dhclient", so I assume you mean the ISC DHCP
client.  Are you sure it won't grab multiple addresses?  According to
the dhclient.conf man page, you should be able to use something like:

    interface "eth0:1" {
        send dhcp-client-identifier "myhost-eth0:1";
    }

    interface "eth0:2" {
        send dhcp-client-identifier "myhost-eth0:2";
    }

My machine runs "dhcpcd" (Gentoo's default) instead of "dhclient", so I
can't test this here.  Dhclient let me do the following, however:

    mkdir /tmp/eth0:1 /tmp/eth0:2
    dhcpcd -I myhost-eth0:1 -L /tmp/eth0:1 eth0:1
    dhcpcd -I myhost-eth0:2 -L /tmp/eth0:2 eth0:2

"-I" specifies the client identifier.  "-L" specifies a client config
directory, which must be unique for each lease.  I ended up with the
following:

eth0:1    Link encap:Ethernet  HWaddr 00:E0:18:E5:38:88
          inet addr:192.168.0.87 Bcast:192.168.0.255 Mask:255.255.255.0
          UP BROADCAST NOTRAILERS RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:7526 errors:0 dropped:0 overruns:0 frame:0
          TX packets:7709 errors:0 dropped:0 overruns:0 carrier:7709
          collisions:0 txqueuelen:100
          RX bytes:6108371 (5.8 Mb)  TX bytes:1137653 (1.0 Mb)
          Interrupt:10 Memory:ed800000-ed801080

eth0:2    Link encap:Ethernet  HWaddr 00:E0:18:E5:38:88
          inet addr:192.168.0.88 Bcast:192.168.0.255 Mask:255.255.255.0
          UP BROADCAST NOTRAILERS RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:7526 errors:0 dropped:0 overruns:0 frame:0
          TX packets:7709 errors:0 dropped:0 overruns:0 carrier:7709
          collisions:0 txqueuelen:100
          RX bytes:6108371 (5.8 Mb)  TX bytes:1137653 (1.0 Mb)
          Interrupt:10 Memory:ed800000-ed801080




More information about the Kclug mailing list