Sunday, September 3, 2017
Ubuntu 14 04 Server Static IP
Ubuntu 14 04 Server Static IP
By default, Ubuntu 14.04 server sets the network interface using DHCP. In most cases this is eth0, but could vary. To set that interface using a static IP address, the interfaces file needs to be edited. At the console type the command in bold to open the nano editor. (Replace nano with your editor of choice). For this exercise we are going to give the server a static IP of 10.0.1.5 in a 24-bit network.
user@server:/# nano /etc/network/interfaces
Find this line:
iface eth0 inet dhcp
and change dhcp to static, then append the following lines after:
address 10.0.1.5
netmask 255.255.255.0
network 10.0.1.0
broadcast 10.0.1.255
gateway 10.0.1.1
dns-nameservers 10.0.1.2
The last line can be replaced with a public DNS server such as Google, or OpenDNS. In this, I chose my private DNS server running a simple Bind9 instance in my network. The interfaces file can be saved and exited. Next the nameservers need to be added to the resolv.conf file located at /etc/resolv.conf
user@server:/# nano /etc/resolv.conf
Add the nameservers of your choice, public or private, or a combination of both, as well as a search domain if you have one, or you can make up one.
nameserver 10.0.1.2
nameserver 10.0.1.3
search network.domain
Save the file and exit. The last step is to add the server name to the hosts file.
user@server:/# nano /etc/hosts
10.0.1.5 ubuntu-srv.network.domain ubuntu-srv
Save and exit. The final step is to restart the network service for the server to get the new IP address.
user@server:/# sudo ifdown eth0 && sudo ifup eth0
Thats all, from another computer on the local network you should be able to ping the servers static IP address if all went well and there were no errors.
download file now