Skip to main content

Setting a Static IP in Ubuntu

· 3 min read

Just recently I had to set up a few workstations for developer work. I installed them with Ubuntu 9.04 (Jaunty Jackalope). I had originally installed them with 9.10 (Karmic Koala) but for some bloody reason, Eclipse, both Ganymede and Gallileo, don’t work on Koala. Anyway, that’s another story for another time.

So the workstations are used for Web development, each has to have a static IP address. Being a small outfit, we don’t have a DNS server. Therefore we need to set each machine’s IP address as static. I thought that it could easily be done with the Network Manager tool in the menu bar, but I was wrong.

So in Ubuntu’s Network Manager, there is an option to set the machine to use a static IP address. As far as setting the IP address of the machine, it worked fine. But what didn’t work out was that the gateway for the machine could not be entered through the Network Manager’s interface.

To be exact, the Network Manager does provide an option to enter the route for the machine to take, but the problem was that whatever you set there is not actually saved. So on the command line when I type “ip route”, the gateway doesn’t show up.

In effect, it means that I was able to set up a static IP address in Ubuntu, but it meant that I could not access any external websites.

The resolution that I had found that still uses Network Manager is to continue to use Network Manager to assign a static IP address. The connection that uses the assigned IP address has to be set to NOT connect automatically while the static address connection should be set to connect automatically.

This way, the connection that is used when the machine is booted up will be the one that uses the static IP address. What about the problem with the gateway? To solve the missing gateway problem, I created a bash file: / etc/network/ifup.d/static-route

This file is made executable and contains the following:


ip route add default via

What this file does is to assign a gateway for the machine when the network interface is brought up, which is when the machine is booted up. This way, I get to use the static IP address and solve the gateway issue. Note that the bash file placed in this folder does not apply when you switch a connection in Network Manager.