1

I've just set up a static IP Address for my CentOS Machine using the following settings in /etc/sysconfig/network-scripts/ifcfg-eth0

#eth0 Config 
#IPv4 

DEVICE="eth0" 
NM_CONTROLLED="yes" 
ONBOOT=yes 
HWADDR=*get from ifconfig* 
TYPE=Ethernet 
BOOTPROTO=static 
NAME="System eth0" 
IPADDR=10.0.0.66 
NETMASK=255.255.255.0
GATEWAY=10.0.0.2
DNS1=8.8.8.8
DNS2=8.8.4.4

That's all working but when I reboot the machine I can't connect to the network and I see it's because it doesn't have the gateway which is 10.0.0.2

I tried to add it as well with /etc/sysconfig/network

NETWORKING=yes 
NETWORKING_IPV6=no 
HOSTNAME=centos66

When I reboot I see that the hostname is now centos66 but it still doesn't have the gateway?

Anyone know what I'm doing wrong and how to fix this?

UPDATE

The DNS had to be added which fixed the issues, I'll leave this here for whoever might be helped by it

  • 1
    why don't you put GATEWAY=10.0.0.2 in /etc/sysconfig/network-scripts/ifcfg-eth0 ? – taliezin May 18 '15 at 8:22
  • I'll try that and see if it works – TheLovelySausage May 18 '15 at 8:33
  • It seems to get me one step closer I think – TheLovelySausage May 18 '15 at 8:44
  • 1
    Is your resolv.conf ok? You can put also DNS in your config. E.g DNS1=x.x.x.x DNS2=xx.xx.xx.xx – taliezin May 18 '15 at 8:59
  • 1
    Oh wow the DNS fixed it, thanks so much taliezin, could you post your solution as an answer so I can choose it as the right one? – TheLovelySausage May 18 '15 at 9:17

Your Answer

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

Browse other questions tagged or ask your own question.