Today's Question:  What are you most afraid of as a programmer?        GIVE A SHOUT

Technical Article => Operating System =>  Linux/Unix

Configure static IP for Linux

  sonic0002      2017-07-08 08:39:58      462    0    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
address 192.168.56.150
netmask 255.255.255.0
gateway 192.168.56.1
broadcast 192.168.56.255

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.

LINUX NETWORK STATIC IP

  SAVE AS PDF   MARK AS READ   MARK AS IMPORTANT

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

  RELATED


  0 COMMENT


No comment for this article.


  WRITE ARTICLE

Just before completing page loading

By sonic0002