One of the first steps when configuring a server post-install is to set up a static IP address. A resource that I followed to remember how to do it is this is The following instructions will vary widely based on your router, this is just a guideline.
The following is the mods to the network config file using the nano editor, you can use pico or vi, or if you really want to you could move the file off the computer using ftp and put it back if you prefer. But I figure it is best to edit most things in place.
But make a backup first on a critical file like this one
sudo cp /etc/network/interfaces /etc/network/interfaces.bak
then edit the file…
sudo nano /etc/network/interfaces
I found the broadcast and netmask from using the ifconfig command. The router address (gateway), I knew from installing the router, look it up in your router admin page. The network is the same address as the gateway with the last digit set to zero, in my case at least. The address is what I want the static IP to be for this server, 10 works OK, 192.168.1.1 is the router add a zero and you’ve got the server.
For me I commented out the line for dhcp added the
iface eth0 inet static
…and added the right values for address ( my static IP), netmask, network, broadcast and gateway…
# This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). # The loopback network interface auto lo iface lo inet loopback # The primary network interface auto eth0 # iface eth0 inet dhcp iface eth0 inet static address 192.168.1.10 netmask 255.255.255.0 network 192.168.1.0 broadcast 192.168.1.255 gateway 192.168.1.1 # nameservers dns-nameservers 18.104.22.168 22.214.171.124
There is a little trick I found somewhere online for putting name servers right into the interfaces file. Use Google’s DNS 126.96.36.199, 188.8.131.52 or use the ones provided by your ISP. You can usually find your ISP’s name-servers by looking at your router settings.
dns-nameservers 184.108.40.206, 220.127.116.11
After the static IP is set restart the network…
sudo service networking restart
or if the machine is rebooted r the changes will take effect.
Verify All is Well
use ctrl-c to stop the pinging. It should give this kind of output if all is well…
erick@ubuntuserver:/etc/samba$ ping www.google.com PING www.google.com (18.104.22.168) 56(84) bytes of data. 64 bytes from lga15s47-in-f19.1e100.net (22.214.171.124): icmp_req=1 ttl=53 time=37.9 ms 64 bytes from lga15s47-in-f19.1e100.net (126.96.36.199): icmp_req=2 ttl=53 time=37.6 ms 64 bytes from lga15s47-in-f19.1e100.net (188.8.131.52): icmp_req=3 ttl=53 time=34.6 ms 64 bytes from lga15s47-in-f19.1e100.net (184.108.40.206): icmp_req=4 ttl=53 time=37.9 ms 64 bytes from lga15s47-in-f19.1e100.net (220.127.116.11): icmp_req=5 ttl=53 time=37.5 ms ^C --- www.google.com ping statistics --- 5 packets transmitted, 5 received, 0% packet loss, time 4006ms rtt min/avg/max/mdev = 34.649/37.151/37.961/1.272 ms
or run the update and upgrade commands used in the earlier installation post, again to see if all is well they should complete without error.
sudo apt-get update
sudo apt-get upgrade
Since you executed them earlier ( see previous post) not much will happen but it is a good validation that the static IP is working correctly.
Install NTP, so that the computers time can be synced with the network
sudo apt-get install ntp