Linux Static IP Address Setup  BACK

The easiest way to set up Linux networking is by using the installation script for your Linux distribution.  The installation script will ask for all required information and configure the network accordingly.  If you have already installed Linux on your system and need to change the network configuration, then follow the steps below.  

Note that the procedures described here are only for static IP address installations; they will not work for dynamic IP addresses.  If you have a dynamic IP address, then either purchase and install a home router/firewall which is PPPoE capable (most of them are), or download and install a free PPPoE client following its instructions.

Step 1: Determining Network Parameters

There are six critical parameters required to connect any computer to the internet and have it function properly. They are as follows:

IP Address
Subnet Mask
Network Address
Broadcast Address
Gateway (Router) Address
Name Server Addresses

The IP address is the globally unique address of your computer. When you receive DSL Static IP Address service your IP address will be provided to you. An IP address consists of four numbers seperated by periods, or "dots", and each number can be from zero to 255. An example of an IP address is "".

The Subnet Mask defines the boundary of the immediate network. Hosts outside of the immediate network cannot be reached without sending requests for them to the Gateway. Like the IP address, it consists of four numbers seperated by periods, except the first number will always be 255. Your Subnet Mask will be "".

The Network Address is the lowest possible address on the immediate network. It can be derived from the IP address and Subnet Mask. The Broadcast Address is the highest possible address on the immediate network and it, too, can be derived from the IP address and Subnet Mask. To calculate your network address use the first three numbers of your IP address and substitute zero for the last number. For example, if your IP address is, then your network address will be The Broadcast address is similar, except it will end in 255 instead of zero. Therefore, in the previous example, the broadcast address would be

The Gateway Address, or Router Address, is the IP address of the router which is connected to the immediate network. Traffic destin for remote networks, those which are not within the immediate network, are sent to the gateway. The gateway will then see to it that the traffic is sent along the correct path to its destination. For Internet Frontier DSL subscribers the gateway address is the same as the IP address except that the last number will be one. For example, if your IP address is then your gateway address will be

The Name Server is a computer which will translate Domain Names, such as www.ifn.net, to IP addresses, such as Without it you can still be on The Internet, you just can't find anything. Your name server address should have been provided with your IP address.

Step 2: Setting up

All Unix and Linux systems keep their most basic host name to IP address associations in /etc/hosts.  Log in as root and, using your prefered text editor, edit /etc/hosts.  At a minimum the following entries should be present:

Note that should be replaced with your static IP address and my_hostname should be replaced with the name of your system.

Step 3: Setting up /etc/resolv.conf

All Unix and Linux systems configure their resolvers with the /etc/resolv.conf file.  This file tells the resolver where its name servers are.  As the root user edit this file; it should contain the following lines:


Note that and should be replaced with your nameserver IP addresses.

Step 4: Setting up your interface

One of the most significant differences between Linux distributions is how they manage network interfaces.  Below are some examples of how interfaces are configured in various Linux distributions.  If your Linux distribution is not one of those mentioned, then you may need to do some research to find out how it is done.

A word of caution: Different versions of the same Linux distribution may handle network configuration differently.  Check the documentation for your distribution and version if these instructions do not work for you.


Network interfaces are defined in /etc/sysconfig/network-scripts/ifcfg-interface_name where interface-name is the name of the interface (typically eth0).  A sample eth0 interface configuration file is as follows:


You will also have to configure your gateway (a.k.a. "default route", a.k.a. "router") in /etc/sysconfig/network and tell the startup scripts to bring the interface(s) up at boot time.  Here is an example:


The domain name (member.ifn.net in this example) can be omitted, though this may cause problems with other programs such as sendmail.  It is probably best to leave it as it appears here, unless of course you have registered your own domain name.


All of the interface configurations on a Debian system are stored in a single file, along with your gateway: /etc/network/interfaces.  Here is a sample interfaces file:

# /etc/network/interfaces -- configuration file for ifup(8), ifdown(8)

# The loopback interface
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static


Slackware Linux does not have an interface management structure.  It depends on startup scripts to run ifconfig and route directly, typically out of /etc/rc.d/rc.inet1.  In the the below sample section from rc.inet1 the network parameters are stored as variables; the parts of the program which actually run ifconfig and route have been omitted:

#! /bin/sh
# rc.inet1      This shell script boots up the base INET system.
# Version:      @(#)/etc/rc.d/rc.inet1  2.00    10/06/1999


# Attach the loopback device.
/sbin/ifconfig lo
/sbin/route add -net netmask lo

# IF YOU HAVE AN ETHERNET CONNECTION, use these lines below to configure the
# eth0 interface.

# Edit these values to set up a static IP address:
IPADDR=""   # REPLACE with YOUR IP address!
NETMASK="" # REPLACE with YOUR netmask!
NETWORK=""   # REPLACE with YOUR network address!
BROADCAST=""       # REPLACE with YOUR broadcast address, if you
                        # have one. If not, leave blank and edit below.
GATEWAY=""   # REPLACE with YOUR gateway address!

Any Unix System

If you are working with a Linux distribution not covered above, if you have another Unix variant (Soalris, HP/UX, BSD, etc.) or if the above instructions did not work, then try the following commands. They should work on any Linux/Unix system, and will have to be placed in the system startup files.

ifconfig eth0 broadcast netmask
route add default gw netmask metric 1

Step 5: Restart Linux networking 

In most cases you can get your network configurations loaded without rebooting.  If that does not work then a simple reboot should get it working.  Try running the below startup/shutdown scripts (as root) with the parameter "restart" for the appropriate Linux distributions:


/etc/rc.d/init.d/inet restart


/etc/init.d/networking restart


/etc/rc.d/rc.inet1 restart