Static Ip results in no internet connection in CentOS 6.5 (Basic Server)

20,966

Solution 1

In virtualBox, the static ip does not work with a NAT connection. Switching to "Bridged Adapter" fixed this.

Solution 2

You still need to add:

GATEWAY=192.168.1.1 DNS1=8.8.8.8 DNS2=192.168.1.1

to your /etc/sysconfig/network-scripts/ifcfg-eth0 file. It worked for me!

Share:
20,966

Related videos on Youtube

Don Rhummy
Author by

Don Rhummy

Updated on September 18, 2022

Comments

  • Don Rhummy
    Don Rhummy over 1 year

    I am unable to get an internet connection with my static IP setup.

    Here's my relevant files:

    /etc/sysconfig/network

    NETWORKING=yes
    HOSTNAME=localhost.myserver
    GATEWAY=192.168.1.1
    

    /etc/sysconfig/network-scripts/ifcfg-eth0

    DEVICE=eth0
    BOOTPROTO=none
    HWADDR=XX:XX:XX:XX:XX:XX
    TYPE=Ethernet
    UUID=xxxxxxx-xxxxxx-xxxx-xxxx-xxxxxxxx
    BROADCAST=192.168.1.255
    IPADDR=192.168.1.44
    NETMASK=255.255.255.0
    NETWORK=192.168.1.0
    ONBOOT=yes  
    

    /etc/resolve.conf

    search myserver
    nameserver 192.168.1.1
    nameserver 8.8.8.8
    

    ifconfig shows 192,168.1.44 (just like it should)

    route -n shows:

    Destination       Gateway           genmask                 flag     Metric           Ref    Use    Iface
    192.168.1.0      0.0.0.0            255.255.255.0           U        0                0      0      eth0
    169.254.0.0      0.0.0.0            255.255.0.0             U        1002             0      0      eth0
    0.0.0.0          192.168.1.1        0.0.0.0.                UG       0                0      0      eth0
    

    When I ping the gateway I get:

    PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
    From 192.168.1.44 icmp_seq=1 Destination Host Unreachable
    From 192.168.1.44 icmp_seq=2 Destination Host Unreachable
    From 192.168.1.44 icmp_seq=3 Destination Host Unreachable
    

    When I ping google, it just hangs until finally saying unknown host.

    What's wrong?

    • davidgo
      davidgo over 10 years
      Does it work with dynamic IP addresses ? Also, what does arp -an show you ? The problem is most likely in the physical path between the box and gateway. (Can you describe your setup a bit better ?)
    • Don Rhummy
      Don Rhummy over 10 years
      @davidgo I set VirtualBox to "BridgedAdapter" and now it works. It was not working with "NAT"
  • Rafee
    Rafee over 8 years
    thanks, this worked for me too. on CentOS 7 in XenServer