Linux Networking Configuration Tutorial

This Linux tutorial covers TCP/IP networking, network administration and system configuration basics. Linux can support multiple network devices.

DNS Server

Domain Resolution Configuration Files: The following files configure the system so that host names can be resolved. This is required when one will ssh to a host name eg. or point an email client to

The system must be able to resolve the host names to IP addresses so that the network connection can be made.

  • File: /etc/resolv.conf – host name resolver configuration file to define server responsible for name resolution
search  - Name of your domain or ISP's domain if using their name server
nameserver XXX.XXX.XXX.XXX - IP address of primary name server
nameserver XXX.XXX.XXX.XXX - IP address of secondary name server

This configures Linux so that it knows which DNS server will be resolving domain names into IP addresses. If using DHCP client, this will automatically be sent to you by the ISP and loaded into this file as part of the DHCP protocol. If using a static IP address, ask the ISP or check another machine on your network.
Red Hat/Fedora GUI: /usr/sbin/system-config-network (select tab “DNS”). File: /etc/hosts– locally resolve node names to IP addresses by explicit definition  localhost.localdomain  localhost 
XXX.XXX.XXX.XXX   node-name

Note when adding hosts to this file, place the fully qualified name first. (It helps send mail identify your server correctly) i.e.:

    XXX.XXX.XXX.XXX  superserver

This informs Linux of local systems on the network which are not handled by the DNS server. (or for all systems in your LAN if you are not using DNS or NIS)

The file format for the hosts file is specified by RFC 952.

Red Hat/Fedora configuration GUI: /usr/sbin/system-config-network (select tab “Hosts”). File: /etc/nsswitch.conf– System Databases and Name Service Switch configuration file. Define the cascading priority of name re solvers

hosts:   files dns nisplus nis
  • This example tells Linux to first resolve a host name by looking at the local hosts file (/etc/hosts), then if the name is not found look to your DNS server as defined by /etc/resolv.conf and if not found there look to your NIS server. In the past this file has had the following names: /etc/nsswitch.conf, /etc/svc.conf, /etc/netsvc.conf, … depending on the distribution.

Note that device configuration information can be found in the auto generated file /etc/udev/rules.d/70-persistent-net.rules

Red Hat

Fedora / Red Hat Network Configuration Files:

Files which hold the Linux system network configuration:

  • /etc/sysconfig/network Red Hat network configuration file used by the system during the boot process.
  • File: /etc/sysconfig/network-scripts/ifcfg-eth0
    Configuration settings for your first Ethernet port (0). Your second port is eth1.
  • File:
    • /etc/modprobe.conf (kernel 2.6)
    • /etc/modules.conf (kernel 2.4)
    • (or for older systems: /etc/conf.modules)Example statement for Intel Ethernet card:
alias eth0 eepro100

Modules for other devices on the system will also be listed. This tells the kernel which device driver to use if configured as a loadable module. (default for Red Hat)

GUI Red Hat

Fedora / Red Hat Network GUI Configuration Tools:

The following GUI tools edit the system configuration files. There is no difference in the configuration developed with the GUI tools and that developed by editing system configuration files directly. TCP/IP Ethernet configuration:

  • Network configuration:
    /usr/sbin/system-config-network (FC-2/3) GUI shown here —>
    /usr/bin/redhat-config-network (/usr/bin/neat) (RH 7.2+ FC-1)
  • Text console configuration tool:
    /usr/sbin/system-config-network-tui (Text User Interface (TUI) for Fedora Core 2/3)
    /usr/bin/redhat-config-network-tui (RH 9.0 – FC-1)
  • Text console network configuration tool.
    First interface only – eth0: /usr/sbin/netconfig
  • /usr/bin/netcfg (GUI) (last available with RH 7.1)
Gnome Desktop:
  • Gnome Desktop Network Configuration
    /usr/bin/gnome-network-preferences (RH 9.0 – FC-3)
    Proxy configuration. Choose one of three options:
    1. Direct internet connection
    2. Manual proxy configuration (specify proxy and port)
    3. Automatic proxy configuration (give URL)

Assigning an IP address:

Computers may be assigned a static IP address or assigned one dynamically. Typically a server will require a static IP while a workstation will use DHCP (dynamic IP assignment).

The Linux server requires a static IP so that those who wish to use its resources can find the system consistently.

It is more easily found if the IP address does not change and is static.

This is not important for the Linux client workstation and thus it is easier to use an automated Dynamic Host Configuration Protocol (DHCP) for IP address assignment.

Static IP on Ubuntu

Static IP address assignment:

Choose one of the following methods:

  • Command Line: There are two commands which can assign an IP address, IP (current practice) and if config (current and legacy).

ip command:

/sbin/ip link   # show list of network interfaces
/sbin/ip addr add broadcast dev eth0
/sbin/ip addr show

[Potential Pitfall]: Avoid the following error by executing the command as root or use sudo:

RTNETLINK answers: Operation not permitted

if config command:

/sbin/ifconfig -a   # show list of network interfaces even if down
/sbin/ifconfig eth0 net mask broadcast
/sbin/ifconfig      # no arguments defaults to showing the current IP configuration

[Potential Pitfall]: Avoid the following error by executing the command as root or use sudo:

SIOCSIFADDR: Operation not permitted
SIOCSIFFLAGS: Operation not permitted
SIOCSIFNETMASK: Operation not permitted
SIOCSIFBRDADDR: Operation not permitted
SIOCSIFFLAGS: Operation not permitted
  • Network address by convention would be the lowest:
    Broadcast address by convention would be the highest:
    The gateway router can be anything, but following convention: Note: the highest and lowest addresses are based on the net-mask. The previous example is based on a net-mask of
  • Red Hat / Fedora GUI tools:
    • /usr/bin/neat Gnome GUI network administration tool. Handles all interfaces. Configure for Static IP or DHCP client.
      (First available with Red Hat 7.2.)
    • /usr/bin/netcfg (Handles all interfaces) (last available in Red Hat 7.1)
  • Red Hat / Fedora Console tools:
    • /usr/sbin/system-config-network-tui (Text User Interface)
    • /usr/sbin/netconfig (Only seems to work for the first network interface eth0 but not eth1,…)
  • Directly edit configuration files/scripts. See format below.

The IP and if config commands do NOT store this configuration permanently. Upon reboot this information is lost. Manually add the network configuration to the system configuration files to have them persist:

  • Red Hat/Fedora/CentOS: /etc/sysconfig/network-scripts/ifcfg-eth0 for the first NIC, ifcfg-eth1 for the second, etc
  • Ubuntu/Debian: /etc/network/interfaces as shown below.

Any other commands you may want to add to the system boot sequence can be added to the end of the file /etc/rc.d/rc.local

The commands netcfg and net config make permanent changes to system network configuration files located in /etc/sysconfig/network-scripts/, so that this information is retained and used upon system boot.

The IANA has allocated IP addresses in the range of to for private networks.

[Potential Pitfall]: You assign an IP address and the network connection still does not work?

  • Your system settings may not be compatible with your router configuration
  • You still may need to add a route (see Route configuration below)
  • Firewall rules may be blocking network traffic. Test by flushing all firewall rules: iptables -F
  • Your system or your network may not be configured to use your upstream network

Helpful tools:

  • Network Calculators: Sub net mask calculator, node calculator, mask inverter, …
  • IP sub net calculator