I've just assigned my CentOS machine with a static IP address using the /etc/sysconfig/network-scripts/ifcfg-eth0 which has the following lines and seems to be working
#eth0 config DEVICE="eth0" NM_CONTROLLED="yes" ONBOOT=yes HWADDR=*hardware address here* TYPE=Ethernet BOOTPROTO=static NAME="System eth0" IPADDR=10.0.0.66 NETMASK=255.255.255.0
when i use ifconfig I see that ip address is 10.0.0.66, however when I try to assign a gateway with /etc/sysconfig/network
NETWORKING=yes NETWORKING_IPV6=no HOSTNAME=centosVM GATEWAY=10.0.0.2
It doesn't seem to be working, when I use route -n I see that the gateway is 10.0.0.0
How do I set the gateway to work like my static IP?
I've just found that if I run dhclient it works. When I check the /etc/resolv.conf it has the nameserver 10.0.0.2 which I want.
I don't know why this fixes it but is there a way that I don't have to run dhclient every time? It doesn't seem right it should have the nameserver in the resolv.conf on boot?