Today's Question:  What weekend projects have you created?        GIVE A SHOUT

Technical Article => Operating System =>  Linux/Unix

Configure static IP for Linux

  sonic0002      2017-07-08 08:39:58      1,116    0

When a Linux server is running, it has to have an IP so that other machines can talk to it. It is often desired that the server would own a static IP so that every time other machines want to connect to it, the same IP address would be used. This is extremely useful when there are virtual machines installed on a host machine where the virtual machine would start and stop now and then. 

To configure static IP address for a Linux server, the /etc/network/interfaces needs to be updated. Assuming there is a host only network is created for a network interface named eth1. The configuration would look like

auto eth1
iface eth1 inet static

Here the interface for eth1 needs to be defined with static specified. This means this will be a static IP. Other options are available as well such as dhcp and loopback

Next, need to specify the IP address to be configured. This will be the IP address other machines would connect to. Thereafter, some standard configuration should be defined such as netmask, gateway, dns-nameservers etc. But the address is the most important one.

After saving this configuration, the changes could be applied by running below commands.

  1. Login as root or a user with sudo privilege
  2. Run sudo ifdown eth1 to bring down the desired network interface
  3. Run sudo ifup eth1 to bring up the desired network interface

Now check the whether the configuration takes effect using ifconfig -a command.

Sometimes if you found that you cannot ping public domains after restarting the server, please check whether you have the correct DNS servers configured. You may also want to add your own DNS servers in /etc/network/interfaces with below line:



Share on Facebook  Share on Twitter  Share on Google+  Share on Weibo  Share on Reddit  Share on Digg  Share on Tumblr 



No comment for this article.


Ask ads

By sonic0002
When I search something on, the first page which I can see is full of ads. Is this or is it