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

Issues related to configuring your network
Post Reply
cmiksis
Posts: 1
Joined: 2020/05/27 11:56:41

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

Post by cmiksis » 2020/05/27 12:13:24

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

User avatar
jlehtone
Posts: 2943
Joined: 2007/12/11 08:17:33
Location: Finland

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

Post by jlehtone » 2020/05/27 13:36:46

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?

User avatar
TrevorH
Forum Moderator
Posts: 29172
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

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

Post by TrevorH » 2020/05/27 14:16:49

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...
CentOS 6 will die in November 2020 - migrate sooner rather than later!
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 is dead, do not use it.
Full time Geek, part time moderator. Use the FAQ Luke

User avatar
jlehtone
Posts: 2943
Joined: 2007/12/11 08:17:33
Location: Finland

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

Post by jlehtone » 2020/05/27 19:28:15

Apparently combo is possible without any alias:
http://www.szakmeister.net/blog/2017/ju ... -ip-nmcli/

Post Reply

Return to “CentOS 8 - Networking Support”