William Jiang

JavaScript,PHP,Node,Perl,LAMP Web Developer – http://williamjxj.com; https://github.com/williamjxj?tab=repositories

CentOS: network configuration files

We can use centos’ commands like chkconfig, service, hostname, uname to access system config and resource; Here I list 4 files regarding on networking configuration.

1. /etc/hosts

The main purpose of this file is to resolve hostnames that cannot be resolved any other way. It can also be used to resolve hostnames on small networks with no DNS server. Regardless of the type of network the computer is on, this file should contain a line specifying the IP address of the loopback device (127.0.0.1) as localhost.localdomain. For example:
127.0.0.1 localhost.localdomain localhost
192.168.0.1 localhost.cloud.com example.com
192.168.0.2 other_virtual_machine.com

2. /etc/resolv.conf

This file specifies the IP addresses of DNS servers and the search domain. Unless configured to do otherwise, the network initialization scripts populate this file. For more information, refer to the resolv.conf man page (man resolv.conf).
nameserver 192.168.1.10
nameserver 192.168.1.254

3. /etc/sysconfig/network

This file specifies routing and host information for all network interfaces. For example:
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=localhost.cloud.com
GATEWAY=192.168.1.254

4. /etc/sysconfig/network-scripts/ifcfg-<interface-name>

For each network interface, there is a corresponding interface configuration script. Each of these files provide information specific to a particular network interface.

[root@localhost network-scripts]# cat ifcfg-eth0
DEVICE=eth0 BOOTPROTO=static HWADDR=12:34:EF:B9:68:F4 IPADDR=192.168.0.1 NETMASK=255.255.255.0 ONBOOT=yes

Interface Configuration Files are usually named ifcfg-<name>, where <name> refers to the name of the device that the configuration file controls.

One of the most common interface files is ifcfg-eth0, which controls the first Ethernet network interface card or NIC in the system. In a system with multiple NICs, there are multiple ifcfg-eth<X> files (where <X> is a unique number corresponding to a specific interface). Because each device has its own configuration file, an administrator can control how each interface functions individually.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: