Ubuntu Static IP
Regarding Ubuntu Static IP is mostly a straight forward thing. I wouldn’t think it should be needed on a rented VPS. As they mostly get their IP addresses assigned. Anyway, here is how we do Ubuntu Static IP.
First we need to edit the network interface.
sudo vim /etc/network/interfaces
Change the line:
iface eth0 inet dhcp
iface eth0 inet static
And then add (in this example we use the ip 192.168.1.151)
network 192.168.1.0 # Optional
broadcast 192.168.1.255 # Optional
To exit VIM, press ESC and then type wq and then press enter to save the file.
Now your network interface is configured to use a static ip.
It is still not active. To activate the static ip you will need to reboot or restart the network interface.
In Ubuntu this will have to be done like this:
sudo ifdown eth0 && sudo ifup eth0
Take notice of the both sudo. And you need to issue both commands at once if your are doing this via ssh or any other remote terminal. If not the network interface will go down, and so will your connection.
So this is how to Ubuntu Static Ip.