Network Configuration File

Source: Internet
Author: User
Tags echo 7 domain name server
Network Configuration File-Linux Enterprise Application-Linux server application information. The following is a detailed description. In linux, TCP/IP networks are configured through several text files. You need to edit these files to complete the networking. The important network configuration files in the system are:

◆/Etc/sysconfig/network
◆/Etc/HOSTNAME
◆/Etc/hosts
◆/Etc/services
◆/Etc/host. conf
◆/Etc/nsswitch. conf
◆/Etc/resolv. conf
◆/Etc/rc. d/init. d/network

Next we will describe these files one by one. These files can be modified during system running without starting or stopping any daemon, the change takes effect immediately (except/etc/sysconfig/network ). In addition, these files support comments starting with "#". Each file has one in Part 1 of the UNIX manual page and can be obtained using the man command.

◆/Etc/sysconfig/network settings
This file is used to specify network configuration information on the server, including parameters for controlling network-related file and daemon behavior. The following is an example file:

NETWORKING = yes
HOSTNAME = machine1
GATEWAY = 210.34.6.2
FORWARD_IPV4 = yes
GATEWAYDEV =

NETWORK = yes/no indicates whether the NETWORK is configured;
HOSTNAME = hostname indicates the Host Name of the server;
GATEWAY = gw-ip indicates the ip address of the Network GATEWAY;
FORWARD_IPV4 = yes/no whether IP Forwarding is enabled;
GAREWAYDEV = gw-dev gw-dw indicates the gateway device name, such as eth0;
To be compatible with some old software, the "/etc/HOSTNAME" file should have the same host name as HOSTNAME = hostname.

◆/Etc/HOSTNAME Host Name

This file contains the Host Name of the system, including the full domain name, such:

192.168.0.1 machine1.domain machine1

This file is obtained from the HOSTNAME line in the file/etc/sysconfig/network at startup and is used to set the Host Name of the system at startup.

◆/Etc/hosts ing between IP addresses and host names

/Etc/hosts contains the ing between IP addresses and host names, as well as the host name alias. The design of IP addresses makes it easy for computers to recognize, but it is hard for people to remember them, to solve this problem, the/etc/hosts file is created. The following is an example file:

127.0.0.1 machine1 localhost. localdomain localhost
192.168.1.100 machine7
192.168.1.101 otherpc otheralias

In this example, the local machine name is machine1, otherpc also has the alias otheralias, which can point to otheralias .. Once the network configuration file of the machine is configured, restart the network to make the modification take effect. Run the following command to restart the network:

/Etc/rc. d/init. d/network restart

The/etc/hosts file usually contains the host name, localhost, and system alias frequently used by the system administrator. Sometimes it takes a long time to telnet to a linux machine, you can add the IP address and Host Name of the customer's machine in "/etc/hosts" to reduce the login wait time. Without a Domain Name Server, all network programs on the system query the file to resolve the IP address corresponding to a host name. Otherwise, other host names are generally resolved using DNS, the DNS Client configuration is in the file/etc/resolv. conf.

◆/Etc/services

/Etc/services contains the ing between the service name and the port number. Many system programs need to use this file. The following are the first lines of the default/etc/services during RedHat installation:

Tcpmux 1/tcp # TCP port service multiplexer
Echo 7/tcp
Echo 7/udp
Discard 9/tcp sink null
Discard 9/udp sink null
Listen at 11/tcp users

The leftmost column is the host service name, the middle column is the port number, "/" is followed by the port type, either TCP or UDP. All the columns that follow are the aliases of the previous service. Aliases also exist in this file. They appear after the port number. In the above example, sink and null are the aliases of the discard service.

◆/Etc/host. conf configure the name parser

There are two file declarations where the system looks for name information to configure the UNIX name parser library. The/etc/host. conf file is used by the libc library of version 5, while/etc/nsswitch. conf file is used by version 6 (glibc ). The problem is that some programs use one of them, while some use the other. Therefore, it is necessary to correctly configure both files.

The/etc/host. conf file specifies how to resolve the host name. linux uses the parser library to obtain the IP address corresponding to the host name. The following is the default "/etc/host. conf" after RedHat is installed:

Order hosts, bind
Multi on

※" Order "specifies the host name query order. The parameter is a comma-separated search method. The supported search methods include bind, hosts, and nis, which respectively represent DNS,/etc/hosts, and NIS, it is required to query the "/etc/hosts" file before using DNS to resolve the domain name.
※Trim indicates that when DNS is used to convert the address to the host name, the domain name will be removed from the host name. trim can be contained multiple times by multiple domains, the/etc/hosts and NIS query methods do not work. Note that the host names in the/etc/hosts and NIS tables are properly listed (with or without a full domain name.
※The host specified in the "multi" specify whether "/etc/hosts" file can have multiple addresses. If the value is on, the host is allowed, A host with multiple IP addresses is generally called a host with multiple network interfaces.
※" Nospoof "indicates whether to allow IP Address Spoofing on the server. If the value is on, it indicates that no IP Address Spoofing is allowed. IP spoofing is a means of attacking system security by disguising IP addresses as other computers, to gain the trust of other computers.
※" Alert "when the nospoof command is on, alert controls whether to use the syslog tool to record spoofing attempts. If the value is on, it indicates that the spoofing attempt is used. The default value is off.
※If "rccorder" is set to on, all queries will be re-ordered. Therefore, the host in the same subnet will be returned first, and the default value is off.

◆/Etc/nsswitch. conf configure the name parser

/Etc/nsswitch. the conf file is developed by company S u n and used to manage the search sequence of multiple configuration files in the system. It is similar to/etc/host. the conf file provides more functions. Each line in/etc/nsswitch. conf is either a comment (starting with #) or a keyword followed by a colon and a series of ordered methods to be tried. Each keyword is the name of the/etc file that can be controlled by/etc/nsswitch. conf in the/etc/directory. The following are the keywords that can be included:

※Aliases email alias;
※Passwd system user;
※Group user group;
※Shadow concealed password;
※Hosts host name and I P address;
※Networks network name and No;
※Protocols network protocol;
※Service port number and service name;
※Ethers Ethernet number;
※Name and number of rpc Remote Process calls
※Netgroup Intranet Group

The following keywords can also be included:

※Files is valid for all keywords except netgroup. Search for records in the corresponding/etc File
※Db is valid for all keywords except netgroup. Search for records in the corresponding/var/db database. It is very effective for long files, such as passwd files with more than 500 items. To generate these files from standard/etc files, change the directory to/var/db and run the run Command.
※The compat compatibility mode is effective for passwd, group, and shadow files. In this mode, you will first search for the corresponding/etc file. To search for NIS, the first value (User Name or group name) must be the plus sign (+), followed by the corresponding number of colons (:) (/etc/passwd is 6, 3 for/etc/group and 8 for/etc/shadow ). For example, in the/etc/passwd file, the following line should be included at the end of the file: + :*:::::
※Dns is only valid for hosts. Such as in/etc/resolvconf configuration, search in DNS
※Nis makes sense for all keywords. If NIS is usable, search
※[ STATUS = action] controls the behavior of the name service. STATUS is one of SUCCESS, NOTFOUND, UNAVAIL, and TRYAGAIN. Action is one of return (Terminate search and return the current status) or continue (other items in this row. For example, hosts: dns nis [NOTFOUND = return] files will first be In the DNS, and then find the host name in NIS. The file/etc/hosts is used only when both items are unavailable.

◆/Etc/resolv. conf configure DNS customer

File/etc/resolv. conf configures the DNS customer. It contains the domain name search sequence of the host and the address of the DNS server. Each line should contain one keyword and one or more parameters separated by spaces. The following is an example file:

Search mydom.edu.cn
Nameserver 210.34.0.14
Nameserver 210.34.0.2

Valid parameters and their meanings are as follows:

※Nameserver indicates the IP address of the DNS server. There can be multiple nameserver rows, each with an I P address. The query is performed in the order of nameserver in this file, and the following nameserver is queried only when the first nameserver does not respond.
※Domain declares the host domain name. Many programs use it, such as the mail system. DNS queries are also required for hosts without domain names. If no domain name exists, the host name will be used and all content before the first vertex (.) will be deleted.
※Multiple search parameters indicate the domain name query order. When you want to query hosts without domain names, the hosts will be searched separately in the domain declared by search. Domain and search cannot coexist. If both exist, the domain and search will be used later.
※Sortlist allows specific sorting of the obtained domain name results. Its parameters are network/mask pairs, which can be arranged in any order. Red Hat does not provide the default/e t c/r e s o l v. c o n f file. Its content is dynamically created based on the options provided during installation.

◆/Etc/init. d/network host address, subnet mask, and gateway

Unlike many other UNIX and linux operating systems, Red Hat cannot automatically configure the network through the/etc/hostname and/etc/hosts files. To change the default IP address of a host, you must directly edit the/etc/init. d/network script to reflect the correct network configuration. This file includes the variables for declaring IP addresses, masks, networks, broadcast addresses, and default routers. The following is the corresponding part of this file:

IPADDR = 192.168.1.100
NETMASK = 255.255.255.0
BROADCAST = 192.168.1.255
GATEWAY = 192.168.1.1
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.