Page 1 of 1

Can you have a Static IP on a primary interface and use DHCP on a secondary interface?

Posted: 2020/05/27 12:13:24
by cmiksis
I was wondering if there is a way to configure an Ethernet interface such that the base interface (in my case it's enp9s0) uses a static interface, while the secondary interface enp9s0:0 uses DHCP.

If both interfaces use a static IP it does work. However, as soon as one of the interfaces is set to use DHCP, the interface does not show up.

This is for IPv4 on Centos 8 if this matters.

thanks in advance!
Chuck

Re: Can you have a Static IP on a primary interface and use DHCP on a secondary interface?

Posted: 2020/05/27 13:36:46
by jlehtone
enp9s0:0 is an alias interface.
https://www.kernel.org/doc/html/latest/ ... alias.html writes:
IP-aliases are an obsolete way to manage multiple IP-addresses/masks per interface.
It also writes: "Newer tools such as iproute2". Iproute2 has been in use two decades now ...

NetworkManager can configure multiple IP addresses to one connection, although I'm not sure about the DHCP + statics combo.


A much bigger issue is that your question sounds like a XY problem http://xyproblem.info/

What do you actually try to achieve?

Re: Can you have a Static IP on a primary interface and use DHCP on a secondary interface?

Posted: 2020/05/27 14:16:49
by TrevorH
I would suspect that it might be possible to do the opposite and have a DHCP address on the main interface and then add a static alias...

Re: Can you have a Static IP on a primary interface and use DHCP on a secondary interface?

Posted: 2020/05/27 19:28:15
by jlehtone
Apparently combo is possible without any alias:
http://www.szakmeister.net/blog/2017/ju ... -ip-nmcli/