Tuesday, May 7, 2024
15
rated 0 times [  15] [ 0]  / answers: 1 / hits: 54883  / 2 Years ago, tue, april 12, 2022, 6:17:59

We can use multiple IP addresses for a single interface in Linux (eg. eth0:0, eth0:1). But can we use DHCP and static IP at the same time? eth0:1 should have a static IP address and eth0:0 should be configured using DHCP.



How can we accomplish both?


More From » network-manager

 Answers
3

Yes, this can be done. However, you would usually use eth0 and eth0:0 for this instead of eth0:0 and eth0:1. You could set up your /etc/network/interfaces file like this:



auto lo eth0 eth0:0
iface lo inet loopback

iface eth0 inet dhcp

iface eth0:0 inet static
address ...
netmask ...


You probably don't want to set a gateway on the eth0:0 interface because that could conflict with the gateway settings you get from DHCP. If you enter manual settings in /etc/network/interfaces you will want to make sure network-manager is not trying to manage your settings. This is covered here.


[#25814] Tuesday, April 12, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ipentainer

Total Points: 112
Total Questions: 113
Total Answers: 113

Location: Guernsey
Member since Tue, Jul 6, 2021
3 Years ago
;