Network configuration – Static IP on Linux

Most probably, one of the first setting you want to do will be to assign a static IP of our server among your local network and start configuring your router and domain name.

Networks explanation

Indeed, if you start to install services (Like a website, a torrent client, a jukebox, etc…), you have to make sure all the ports are open and redirected to the correct machine and your domain name is well configured.

But to do so, you need first to make sure the IP of your server will not change. Hence you need to set a static IP into the /etc/network/interfaces file.


<pre class="lang:default decode:true">sudo nano /etc/network/interfaces

and mine is the following:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static

The part that interest us is iface eth0 inet static and then set the address IP you want (Usually or depending on your router configuration) while the netmask is always the same.

After modification, just save (CTRL+X then Y) and restart your network

sudo /etc/init.d/networking restart


Don’t know your IP?

If you don’t know your local IP address on your server or the gateway, you could check the current automatic (DHCP) configuration.

Just type:

sudo ifconfig

and you should have something similar to that:

eth0      Link encap:Ethernet  HWaddr 50:e5:49:36:be:6e  
          inet addr:  Bcast:  Mask:
          inet6 addr: fe80::52e5:49ff:fe36:be6e/64 Scope:Link
          RX packets:20171368 errors:0 dropped:0 overruns:0 frame:0
          TX packets:42393767 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:9008655783 (8.3 GiB)  TX bytes:56675394936 (52.7 GiB)
          Interrupt:41 Base address:0xe000

My local IP address is then

And for the gateway, it is most of the case if your IP is and will be is your IP is


Loves to discover web-based apps to install on his own server@home and write articles about it


Add a comment