CentOS instructions
Posted: Mon Jun 13, 2011 12:36 pm
To change the IPs in CentOS, log in to your server through SSH or the "VNC Console" page in the control panel, and then use the nmtui command for a menu-driven system. You can use enter to select the "eth0" interface, then use tab and enter to move between fields and make the necessary edits.
If this is unavailable, you can edit the IPs by hand. If you need to edit the main IP for the machine after a location change,
If you need to delete an IP, find its corresponding ifcfg-eth0:x file and delete it.
If you need to add an IP on top of your existing assignments,
If this is unavailable, you can edit the IPs by hand. If you need to edit the main IP for the machine after a location change,
- Open the file /etc/sysconfig/network-scripts/ifcfg-eth0 in your favorite text editor (if you are new to text editing on Linux, we recommend installing nano with yum install nano and then running the command nano /etc/sysconfig/network-scripts/ifcfg-eth0).
- You should see your primary IP and netmask (from the "IP list" control panel page) in this file. Edit the IPADDR= and NETMASK= fields to match your new IP address.
- Save the file and exit.
- Open /etc/sysconfig/network in your text editor.
- Edit the GATEWAY= field to match the gateway of the IP you entered above.
- Save the file and exit.
- Reboot the VDS with the "reboot" command.
If you need to delete an IP, find its corresponding ifcfg-eth0:x file and delete it.
If you need to add an IP on top of your existing assignments,
- Look for the highest numbered /etc/sysconfig/network-scripts/ifcfg-eth0:x file.
- Create a new file called /etc/sysconfig/network-scripts/ifcfg-eth0:y, where y is one higher than x.
- Place these lines in the file:
newip and newnetmask need to match the assignment information we gave you.DEVICE=eth0:y
BOOTPROTO=static
IPADDR=newip
NETMASK=newnetmask
ONBOOT=yes - Save the file and exit.
- If necessary, edit /etc/sysconfig/network to set a new gateway (note that you should only ever list one gateway -- if you already have one for an existing IP address that you are also keeping, you should retain it).
- Reboot the VDS with the "reboot" command.