Setup Static IP Address in Linux Terminal

This tidbit intends on helping folks running Linux in an embedded environment to setup a static IP address. This is also applicable to full fledge desktop installations of Linux as well. It has been tested on Debian Linux, but I suspect the process is identical for most distributions. Let’s get to it…

Edit “/etc/network/interfaces” to reflect the changes you’d like to make to your IP address. For example, I would like to setup my Debian box with the IP address I have filled in all of the important information as well as seen below:

   # Used by ifup(8) and ifdown(8). See the interfaces(5) manpage or
   # /usr/share/doc/ifupdown/examples for more information.

   auto eth0
   #iface eth0 inet dhcp
   iface eth0 inet static

Then, edit the “/etc/resolv.conf” file to reflect your DNS servers (or simply use OpenDNS addresses below):


Now, reset the eth0 interface by using the command:

ifdown eth0; ifup eth0

Test the connection using the command:

ping google.com

As an additional tidbit, you can simply get an IP address via DHCP using the ‘dhclient’ or ‘pump’ command.

Feel free to donate if this post prevented any headaches! Another way to show your appreciation is to take a gander at these relative ads that you may be interested in:

There's 0 Comment So Far

Share your thoughts, leave a comment!