Configure Static IP and installing NTP

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.

How to Make an Ubuntu File Server With Samba

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.

ifconfig Output
ifconfig Output

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 8.8.8.8 8.8.4.4
Set DNS

There is a little trick I found somewhere online for putting name servers right into the interfaces file. Use Google’s DNS 8.8.8.8, 8.8.4.4 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 8.8.8.8, 8.8.4.4

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

Ping Google…

ping www.google.com

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 (173.194.123.51) 56(84) bytes of data.
64 bytes from lga15s47-in-f19.1e100.net (173.194.123.51): icmp_req=1 ttl=53 time=37.9 ms
64 bytes from lga15s47-in-f19.1e100.net (173.194.123.51): icmp_req=2 ttl=53 time=37.6 ms
64 bytes from lga15s47-in-f19.1e100.net (173.194.123.51): icmp_req=3 ttl=53 time=34.6 ms
64 bytes from lga15s47-in-f19.1e100.net (173.194.123.51): icmp_req=4 ttl=53 time=37.9 ms
64 bytes from lga15s47-in-f19.1e100.net (173.194.123.51): 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.

Installing NTP

Install NTP, so that the computers time can be synced with the network

sudo apt-get install ntp

Read more on ntp

Next installing SSH and connecting beyond you LAN to the outside world…

Remote Operation of Server

2 thoughts on “Configure Static IP and installing NTP

Leave a Reply

Your email address will not be published. Required fields are marked *