My CentOS VPS got many IP addresses that I'd like to add to the eth0 network interface.

Currently eth0 only got 1 IPv4 address and its other ones doesn't show up.

My searching gives me terms like IP Alias but that doesn't seem to apply to CentOS. The CentOS Wiki doesn't really show how it's done.

cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0:0

Now you can edit the new file ifcfg-eth0:0 and specify the network settings of the virtual interface.

How do I manually add IPv4 IP addresses to a physical network interface in CentOS 7?

  • The Wiki tip you link to does explains how to add to add IP addresses to a network device that persists across reboots. The Wiki could be more verbose and explanatory but the information is there. Can you edit the question to highlight the part(s) you're having trouble with. – Anthony Geoghegan Oct 8 '17 at 12:47
  • 1
    Done. You can now edit the file. Yes, very much aware that the file is editable, but what to put in it? @AnthonyGeoghegan – Mikael Dúi Bolinder Oct 11 '17 at 23:34
  • 1
    Cool. I've upvoted your question. I was going to add an answer based on referencing the documentation at access.redhat.com/documentation/en-us/red_hat_enterprise_linux/… but it looks like Hunter's answer meets your needs. – Anthony Geoghegan Oct 12 '17 at 0:18
  • Well, @AnthonyGeoghegan, you link covers more ways of doing it (like scripting). – Mikael Dúi Bolinder Oct 12 '17 at 0:49

Create a configuration file called ifcfg-<interface name>:0 in /etc/sysconfig/network-scripts/

The syntax of the configuration will be like this :


Then restart the service and you should be good to go.

service network restart
  • What if the gateway is assigned through DHCP? – Mikael Dúi Bolinder Oct 11 '17 at 16:15
  • 1
    Comment out the line which says GATEWAY in your config. – Hunter.S.Thompson Oct 11 '17 at 16:16
  • I am sure the issue is me but not seeing how/why. Using the above template, plug-in necessary values 'service network restart' expected results, but does not persist across boot. 'systemctl restart network' seems to have no effect. Any thoughts? – terary Jul 4 '18 at 1:47
ip a add dev enp3s0
  • 2
    You can make this answer even more useful by adding a link to the man page of ip and by describing what each of the flags are used for in this case. – user1794469 Jan 22 '19 at 15:38
  • 4
    Isn't this command just adding it temporarily? – Mikael Dúi Bolinder Jan 25 '19 at 13:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.