Change VM from DHCP to Static IP
Jul 20, 2015Dan Iverson
Steps to change DHCP configuration to a static IP, if the VM was originally configured using DHCP. I’ve had to look this up a few times so I’m documenting it here.
Edit the network adapter
- Edit the following file as root user
/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0 BOOTPROTO=static HWADDR=00:1A:A0:B2:B2:5B ONBOOT=yes IPADDR=192.168.0.xxx NETMASK=255.255.255.0 NETWORK=192.168.0.255
And save the file
Edit the hosts file
- Also edit the host file in etc as root user.
/etc/hosts
Do not edit these two lines which is given as default
127.0.0.1 localhost.localdomain localhost ::1 localhost6.localdomain6 localhost6
Add this at the end of the file
192.168.0.xxx aaapum.psadmin.io aapum
Restart the network services
- Restart the network using this command.
service network restart
Note: This was originally posted by Dan Iverson and has been transferred from a previous platform. There may be missing comments, style issues, and possibly broken links. If you have questions or comments, please contact [email protected].