I originally had this requirement after creating a new persistent linux virtual machine in OVM that needed static addressing. This is just standard linux setup, though, and can be adapted to both virtual and physical machines.
Turn on Networking
# sudo vi /etc/sysconfig/network
Make sure networking is enabled and configure the hostname.
Configure the Network Interface
# sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0
Here is a sample config for static IPs.
HWADDR=00:30:48:56:A6:2E TYPE=Ethernet BOOTPROTO=none IPADDR=192.168.1.10 GATEWAY=192.168.1.0 PREFIX=24 DEFROUTE=yes IPV4_FAILURE_FATAL=no IPV6INIT=no NAME=eth0 DEVICE=eth0 ONBOOT=yes
HWADDR value is just the MAC address of the VM, which I got from the OVM console. The
PREFIX value relates to the network mask; eg. a value of 24 equates to a mask of
255.255.255.0. Disabling IPV6 is optional.
Configure DNS Servers
I also edit /etc/resolv.conf and setup DNS servers there. TBH, I’m not sure if this is necessary or redundant with ipcgf-eth0
# sudo vi /etc/resolv.conf
Configure similar to the following:
search yourcompany.com nameserver 192.168.1.254 nameserver 188.8.131.52 nameserver 184.108.40.206
Finally, Restart Networking
# sudo systemctl network restart
You can verify that networking is working properly with the following commands
# ifconfig eth0 # ip a s eth0 # ip r # route -n # ping 192.168.1.254 # ping google.com