Network Configuration file
In our tutorial how to configure IP in linux we learnt how to configure IP using nmtui, network manager tool plus we also discussed about script file /etc/sysconfig/network-scripts/ifcfg-enp0s3. In this tutorial we will discuss about other network configuration files and will revise how to configure /etc/sysconfig/network-scripts/ifcfg-enp0s3.All these are important network configuration files. Network Services in linux are managed through the several configuration files. These files control determine whether networking is started during the system boot process or not. You will need to know these files to troubleshoot networking issues.
File 1: /etc/init.d/network
/etc/init.d/ directory store script files.
We can run the scripts directly, or use the service command to start/stop. If the network interface is deactvated by mistake or there is error in configuration then please good start will be check these files first. We can execute script directly by using /etc/init.d/network status or systemctl status network.
File 2: /etc/sysconfig/network
This file contains global configuration settings, specifies routing and host information for all network interfaces. It is used to contain directives which have global effect and is not specific to any interface. By default this file is empty as per your requirement of networking you need to add below directives; For more information about this file click here
NETWORKING= [yes] [no]
If directive NETWORKING is set to no then the /etc/init.d/network script does not activate any device. It must be set to yes in order to start networking.
HOSTNAME=faraz, where hostname(faraz) is the hostname of your server.
GATEWAY= Ip Address , IP address of the remote network gateway –if available.
File 3: /etc/sysconfig/network-scripts
This directory contains executable files based on a series of text command. These files are basically scripts based on ifup and ifdown commands customized for the network device type.
File 4: /etc/sysconfig/network-scripts/ifcfg-enp0s3
This file contain configuration for enp0s3 first network adapter, ifcfg-enp0s3 file is used to configure first Ethernet network adapter as per you requirement of network (By default it’s DHCP) . If you want to assign fix/static IP address then edit that interface adapter with below directives;
IPADDR Static IP address.
NETMASK Network mask or subnet mask.
GATEWAY IP address of the default gateway.
ONBOOT (by default it’s no) specify whether the device is activated during boot process.
NAME Common name for the device.
HWADDR Hardware address of network device also known as MAC/Physical address.
NM_CONTROLLED Specify that network interface should be control by the network manager service or not. If it is set to yes make sure that network manager in running position.
BOOTPROTO How IP address would be configured DHCP(default) or Static(manually assigning fix IP).
File 5: /etc/hosts
Hosts file is used to resolve hostnames. It can also be used to resolve hostnames on small networks where there is no DNS Server. By default file hold a line identifies the IP address of the loopback device (127.0.0.1) as localhost.localdomain.
File 6: /etc/resolv.conf
Resolve.conf file identifies the IP address of DNS servers and search domain. Except configured to do otherwise, the network begin that script.
Once again thanks for visiting this tutorial and hope you have enjoyed and learnt. Please subscribe to our newsletter