How to Set A Static IP On Ubuntu

You are here:
< Back

Set A Static IP On Ubuntu

Source: https://www.howtoforge.com/linux-basics-set-a-static-ip-on-ubuntu

Step 1: Configure the network interface

In this step you will manually configure your network interface by editing the following files using your preferred text editor(nano gedit vi). For the purpose of this example I am using the “nano” editor. You can edit the appropriate file by entering the following command into the terminal:

You can copy and paste directly from this line.

sudo nano /etc/network/interfaces

Enter your root password, once your prefered editor opens the file you can see…

If you have more than one network card, please be sure to make changes to the correct network interface.

Statically configured network cards will have a section like:

If you use “nano” editor, type Ctrl+x to save changes.

Save modified buffer (ANSWERING “No” WILL DESTROY CHANGES) ?

<—Type “y”

File Name to Write: interfaces

<—ENTER

Here is an example:

Step 2: Configure the DNS servers

Changes in /etc/resolv.conf are required only on Systems with Ubuntu < 14.04, for newer Ubuntu versions the nameservers get configured in the /etc/network/interfaces file.

a) Ubuntu versions < 14.04

In this step you will manually configure your dns configuration file.

sudo nano /etc/resolv.conf

Once your editor opens the file you want to enter the following information…

If you use “nano” editor, type Ctrl+x to save changes.

Save modified buffer (ANSWERING “No” WILL DESTROY CHANGES) ?

<—Type “y”

File Name to Write: resolv.conf

<—ENTER

Here is an example:

b) Ubuntu versions > 14.04

Open the /etc/network/interfaces file again and add a line dns-nameservers 8.8.8.8 right after the gateway line.

sudo nano /etc/network/interfaces

The nameservers 8.8.8.8 and 8.8.4.4 are provided by Google for public use, so you can use them in your network configuration.

If you use “nano” editor, type Ctrl+x to save changes.

Save modified buffer (ANSWERING “No” WILL DESTROY CHANGES) ?

<—Type “y”

File Name to Write: interfaces

<—ENTER

Step 3: Restart networking

Manually restart your network interface with the new settings.

For Ubuntu < 14.04 use the networking init script:

sudo /etc/init.d/networking restart

This should return a result that looks like the following:

*Reconfiguring network interfaces… [OK]

For Ubuntu versions > 14.04 use systemctl instead:

systemctl restart ifup@eth0

At this point you can check if the settings are correct:

ifconfig

If everything is correct you will get this result.

eth0      Link encap:Ethernet  direcciónHW 00:33:27:46:2v:34
Direc. inet:192.168.1.101  Difus.:0.0.0.0  Másc:255.255.255.0

See you…

Previous How to install Webmin on Ubuntu 16.04
Next NextCloud or OwnCloud – smbclient not installed for CIFS/SMB external mounts