assigning a static IP on ubuntu

To assign a static IP you need to edit /etc/network/interfaces

The current entry will look something like
auto eth0
iface eth0 inet dhcp
You will need you need to change this to:
auto eth0
iface eth0 inet static
address 10.253.0.50
netmask 255.255.255.0
network 10.253.0.0
gateway 10.253.0.1
dns-nameservers 8.8.8.8

Then restart networking sudo service networking restart

Set your IP address changes in /etc/network/interfaces. Example:
auto eth0
iface eth0 inet static

:)

address 192.168.1.128
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
Don’t give your DNS configurations in /etc/resolv.conf because while we restart the server sometimes the configuration get erased.
So use vim /etc/resolvconf/resolv.conf.d/base (while updating configs in this it doesn’t get removed)
example:
search (domain name)
nameserver 8.8.8.8
nameserver 8.8.4.4
Save and then restart your server, this fixed my static issue!

About Damon Luong

San Jose, California
This entry was posted in ubuntu. Bookmark the permalink.