Ubuntu – Setting up a static IP address (public) in Ubuntu

ip addressnetworkingUbuntu

I have a business class internet connection and need to setup a static ip address for a machine. I did a search online and only find how to setup static local ip addresses (like 192.168..). I tried the same technique, and only setup the ip address and netmask, but after restart networking the computer could not connect to the outside world.

This is what I did:

1) edit /etc/network/interfaces
iface eth0 inet static
address 173.10.xxx.xx
netmask 255.255.255.252

2) edit /etc/resolv.conf
search wp.comcast.net
nameserver xx.xx.xx.xxx
nameserver xx.xx.xx.xxx

3) restart network
sudo /etc/init.d/networking restart

Now the last step didn't report error, ifconfig shows the ip address was set, but this server cannot connect to outside world, ping google.com and reports "unknown host google.com".

Any ideas?

Best Answer

You are missing a default route.

In ubuntu, you'll need:

 gateway <IP of default route>

Here is /etc/network/interfaces on my system (with a private IP, but there is no difference):

auto eth0
iface eth0 inet static
    address 10.22.16.2
    netmask 255.255.255.0
    network 10.22.16.0
    broadcast 10.22.16.255
    gateway 10.22.16.1
    # dns-* options are implemented by the resolvconf package, if installed
    dns-nameservers 10.21.1.21
    dns-search example.com