HOWTo Network interface configuration in Linux

 # /etc/sysconfig/network-scripts/ifcfg-eth#

The system reads the network interface files 
during the boot process to determine which 
interfaces to bring up and how to configure them. 
The file name format of the network interface 
configuration file is 
/etc/sysconfig/network-scripts/ifcfg-eth#. 
So if you want to configure the interface eth0, 
the file to be edited is /etc/sysconfig/network-scripts/ifcfg-eth0.

Below is a sample eth0 interface configuration file.

# cat /etc/sysconfig/network-scripts/ifcfg-enp134s1f0 
TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV4_FAILURE_FATAL=no
NAME=eth0
UUID=...
ONBOOT=yes
HWADDR=0e:a5:1a:b6:fc:86
IPADDR0=172.31.24.10
PREFIX0=23
GATEWAY0=172.31.24.1
DNS1=192.168.154.3
DNS2=10.216.106.3
DOMAIN=example.com
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes

A description of some of these configuration parameters follows:
TYPE=device_type: The type of network interface device
BOOTPROTO=protocol: Where protocol is one of the following:

  • none: No boot-time protocol is used.
  • bootp: Use BOOTP (bootstrap protocol).
  • dhcp: Use DHCP (Dynamic Host Configuration Protocol).

DEFROUTE|IPV6_DEFROUTE=answer: Where answer is one of the following:

  • yes: This interface is set as the default route for IPv4|IPv6 traffic.
  • no: This interface is not set as the default route.

IPV6INIT=answer: Where answer is one of the following:

  • yes: Enable IPv6 on this interface. If IPV6INIT=yes, the following parameters could also be set in this file:
    1. IPV6ADDR=IPv6 address
    2. IPV6_DEFAULTGW=The default route through the specified gateway
  • no: Disable IPv6 on this interface.

IPV4_FAILURE_FATAL|IPV6_FAILURE_FATAL=answer: Where answer is one of the following:

  • yes: This interface is disabled if IPv4 or IPv6 configuration fails.
  • no: This interface is not disabled if configuration fails.

ONBOOT=answer: Where answer is one of the following:

  • yes: This interface is activated at boot time.
  • <strong<no< strong=””>: This interface is not activated at boot time.</strong<no<>

HWADDR=MAC-address: The hardware address of the Ethernet device
IPADDRN=address: The IPv4 address assigned to the interface
PREFIXN=N: Length of the IPv4 netmask value
GATEWAYN=address: The IPv4 gateway address assigned to the interface. Because an interface can be associated with several combinations of IP address, network mask prefix length, and gateway address, these are numbered starting from 0.
DNSN=address: The address of the Domain Name Servers (DNS)
DOMAIN=DNS_search_domain: The DNS search domain

Additional Network Configuration Files

In addition to the individual network interface configuration files in the /etc/sysconfig/network-scripts directory, there are other, more global network configuration files. These files are:

  • /etc/hosts
  • /etc/resolv.conf
  • /etc/sysconfig/network
  • /etc/nsswitch.conf

1. /etc/hosts

This file associates host names with IP addresses. It resolves or looks up, an IP address when the hostname is known. Larger networks would use Domain Name Service (DNS) to perform this resolution. Even if using DNS, include in this file a line specifying the IP address of the loopback device (127.0.0.1) as localhost.localdomain. A sample /etc/hosts file follows. The first column contains the IP address. The second column is the fully qualified hostnames. Additional columns contain hostname aliases:

# cat /etc/hosts
127.0.0.1    localhost.localdomain   localhost
192.0.2.101  host01.example.com.     host01

2. /etc/resolv.conf

The resolver configuration file provides access to DNS. This file usually has at least two lines, one line specifying the IP address of a DNS server (or name server) and the other specifying the search domain. The following example shows three name servers and the search domain:

# cat /etc/resolv.conf 
search example.com 
nameserver 192.168.154.2 
nameserver 172.168.106.3 
nameserver 193.32.3.252

3. /etc/sysconfig/network

This file specifies global network settings. For example, you can specify the default gateway in this file:

# cat /etc/sysconfig/network 
GATEWAY=192.168.2.1

4. /etc/nsswitch.conf

This file is the system databases and name service switch configuration file. It provides sources for common configuration databases and name resolution mechanisms. Entries in this file identify the database name in the first field, then a colon, and then a list of possible resolution mechanisms in the second field. The order in which the mechanisms are listed determines the order in which queries on the specified database are resolved.

The following example indicates that host name resolution is attempted first by querying local files, that is, /etc/hosts, and then by querying the DNS server if the host name is not resolved:

# cat /etc/nsswitch.conf 
...
hosts: files dns
...

What’s inside this eBook?

This book contains 28 chapters with a total of 464 pages, which covers all official exam objectives for the RHCSA and RHCE exams based on Red Hat Enterprise Linux 7, including:

RHCSA Section (chapters 1 to 15)

  1. Chapter 1: Learn Essential Commands & System Documentation
  2. Chapter 2: How to Perform File and Directory Management
  3. Chapter 3: Manage Users and Groups
  4. Chapter 4: Text File Editing and Analyze
  5. Chapter 5: Learn Process Management
  6. Chapter 6: Configure and Encrypt System Storage
  7. Chapter 7: Learn Access Control Lists and Mount Network NFS Shares
  8. Chapter 8: Secure and Enable Network Services
  9. Chapter 9: Setting Up Web and FTP
  10. Chapter 10: Linux Package Management, Cron Scheduling and Monitoring Logs
  11. Chapter 11: Manage Firewall and Network Traffic
  12. Chapter 12: Automate Installations Using Kickstart
  13. Chapter 13: Learn Access Control Essentials with SELinux
  14. Chapter 14: Setting Up LDAP-based Authentication
  15. Chapter 15: Host Virtualization and Guest Administration
  16. RHCE Section (chapters 1 to 13)

    1. Chapter 1: Setup Static Network Routing
    2. Chapter 2: Kernel and Network Management
    3. Chapter 3: Monitor and Generate System Activity Reports
    4. Chapter 4: Automate Tasks Using Shell Scripts
    5. Chapter 5: System Log Management
    6. Chapter 6: Setup Network File Sharing with Clients
    7. Chapter 7: Setup Network Sharing with Client Authentication
    8. Chapter 8: HTTPS and NSS Implementation on Web Servers
    9. Chapter 9: Simple Mail Transfer Protocol (SMTP)
    10. Chapter 10: Cofigure Cache-only DNS Server
    11. Chapter 11: Network Bonding or Teaming NIC
    12. Chapter 12: iSCSI Target Initiator Setup
    13. Chapter 13: MariaDB Installation, Configuration and Usage

    Each chapter explains important topics and relevant exam objectives in the beginning and ends with a summary followed by questions and answers.

    For that reason, we present you with the opportunity to buy this ebook for $39.99 as a limited offer. With your purchase, you will help support CompTIAbible.com so that we can continue bringing you high-quality articles for free on a daily basis as always.

Ron Jagannathan has written 54 articles

Ronan is a Caffeine dependent life-form from Planet Earth who wants to be a Jedi Knight of cloud computing. A man of mystery and power, whose power is exceeded only by his mystery. Quantum Physicist, TransHumanist, Systems Architect, Unix Administrator, Artificial Intelligence, Machine Learning and DIY Gadget enthusiast. Believes that the Universe has a high probability of being a simulation.
But he's real and hopefully some of his readers are too.
email: Ron.Jagannathan@gmail.com ph: 202 355 5205
https://www.linkedin.com/in/ronjagan/
My Famous Quotes:
“In a Unix Universe, God is known by a four letter word called root. To err is human...to really foul requires you to be root.. err.. god.” ― Ron Jagannathan

Github: github.com/ronjag
Linkedin: linkedin.com/in/ronjagan/

“Quotes found on the Internet are not always accurate.” ― Abraham Lincoln

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>