Re: How to configure a DHCP + (2nd) Static address (eg on eth0+eth0:0)?



On Tue, 2015-09-29 at 12:16 -0400, Derek Atkins wrote:
Hi,

I've got an esoteric NM question.  I've got two distinct networks that
share an ethernet fabric (poor man's vlans).  I have a F22 server that I
want to put on both networks.  It's currently configured to use DHCP for
the primary network (and my DHCP server provides a static address).

AFAICT there's really no way to get DHCP to provide two addresses, so
I'd like to set up a secondary IP statically using nmcli (I did say this
was a server, right?)

Correct.  DHCPv4 cannot provide more than one IP address.  (DHCPv6 can,
however).

Basically I want to automate NM doing, effectively:

  ifconfig eth0:0 192.168.x.y

Don't do this with interface aliases; the kernel is perfectly capable of
using more than one address on the same interface.  Simply do:

ip addr add 192.168.x.y/24 dev eth0

and magically you'll have two.

I know I can add a second IP to eth0 via:

  nmcli con mod "Wired connection 1" +ipv4.addresses "192.168.x.y/24"

This is exactly what you do.  Keep the ipv4.method = "auto" however,
that's how DHCP gets signaled.

But I have no idea how this would interact with the primary address
being obtained by DHCP.

What should happen is that DHCP will provide everything it currently
does, including the primary IP address, gateway, DNS, etc, and the only
change will be that a second IP address is added to the interface.  You
won't see this address with ifconfig though, because it's stupid.
Use /sbin/ip to see it.

Dan



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]