This article mainly introduces the common network configuration files under Linux:
/etc/sysconfig/network
/etc/hosts
/etc/services
/etc/host.conf
/etc/nsswitch.conf
/etc/resolv.conf
/etc/xinetd.conf
/etc/modules.conf
/etc/sysconfig/network-scripts/ifcfg-ethn
We'll talk about each of these files next.
1,/etc/sysconfig/network
Used to specify the network configuration information on the server, including the behavior parameters that control network-related files and daemons.
2,/etc/hosts
The IP address and host name Mapping, also includes the host name alias, the IP address design makes the computer easy to recognize, but is difficult for people to remember. Therefore, create a/etc/hosts file to resolve this issue.
Once you have configured the network configuration information, you need to restart the network service to make the change effective command is:
Service Network restart
/etc/hosts files typically contain host names, localhost, and system aliases that are frequently used by system administrators. Sometimes it takes a long time to telnet to the Linux machine, and you can reduce the logon time by adding the client's machine name and IP address to the/etc/hosts. In the absence of a domain name server, all network programs on the system will parse the IP address corresponding to a host by querying the file. Otherwise, the other host names are usually resolved by DNS. The partial configuration of the DNS client is in/etc/resolv.conf.
3,/etc/services
Contains the mapping between the service name and the port number. A lot of system programs to use this file.
There are also aliases in this file, which appear behind the port number.
4,/etc/host.conf
Configuring the name Resolver
There are two files declaring the system where to look for the name information to configure the UNIX name Parser library. The file/etc/host.conf is referenced by version 5 of the LIBC library, and/etc/nsswitch.conf is used by version 6 (GLIBC). The problem is that some programs use one, and some use the other, so it is necessary to configure two files.
The/etc/host.conf file specifies how the hostname is resolved, and Linux obtains the IP address of the host name by parsing the library.
Parameters in the host.conf file:
order specifies the sequence of queries for the host name, whose parameters are comma-separated lookup methods, and bind, hosts, NIS represent DNS,/etc/hosts, and NIS, respectively
"Trim" indicates that the domain name is clipped from the host name when the address-to-hostname conversion is done through DNS, and trim can contain multiple domain names several times. The/etc/hosts and NIS query methods do not work. Note in the/etc/hosts and NIS tables, the host names are listed appropriately.
"Multi" Specifies whether the host specified in the/etc/hosts file can have multiple addresses, with a value of on to allow, hosts with multiple IP addresses are generally referred to as having multiple network interfaces.
"Nospoof" refers to whether IP address spoofing is allowed on the server, the value is on to disallow, IP address spoofing is a means of providing system security, by the IP address disguised as another computer, to obtain the trust of other computers.
"Alert" when the nopoof instruction is on, the alert control spoofing attempt is logged with the Syslog tool, the value is on for use, and the default value is off.
If "Recorder" is selected as on, all queries will be reordered, so hosts in the same subnet will be returned first. The default value is off.
5,/etc/nsswitch.conf
This file was developed by Sun and used to manage the order of lookups for multiple profiles in the system. It provides more functionality than/etc/host.conf, each line in the/etc/nsswitch.conf or a comment or a keyword followed by a colon and a series of sequential methods to be tried. Each keyword is the name of the/etc file in the/etc/directory that can be controlled by/etc/nsswitch.conf. Here are the keywords that can be included:
Aliases Mail aliases
passwd System Users
Group user groups
Shadow Covert Password
Hosts hostname and IP address
Networks Network Name and number
Protocols Network protocol
Services port number and service name
ethers Ethernet Number
Name and number of the RPC remote process call
Netgroup in-Network group
6,/etc/resolv.conf
Configure DNS Clients
It contains the search order of the host and the address of the DNS server, each of which should contain one keyword and one or more parameters separated by spaces.
The valid parameters and their meanings are as follows:
NameServer indicates the IP address of the DNS server. There can be many lines of nameserver, each with an IP address. At query time, press nameserver in the order of the text file. And the next is queried only if the first one is unresponsive.
Domain declares the hostname of the host, many programs use it, such as the mail system. It is also used when DNS queries are made for hosts that do not have a domain name. When there is no domain name, the host name is used, and all the first (.) is deleted. The previous content.
Search its multiple parameters indicate the order of the domain name query. When you want to query a host that does not have a domain name, the host is found separately in the domain that is declared by search. Domain and search cannot coexist, and if they exist at the same time, subsequent occurrences will be used.
Sortlist allows the resulting domain name results to be given a specific sort. Its parameters are network/mask pairs, allowing arbitrary ordering.
7,/etc/xinetd.conf
redhat7.1 and later versions, xinetd.conf replaced the original inetd.conf, and directly used the Firewall service. The default profile for xinetd is/etc/xinetd.conf, which, although it looks completely different from the old version of/etc/inetd.conf, simply expands the service specified in each row of inetd into a single script as a/etc/xinetd.d/ The configuration file under. The format is:
Service Service-name
{
disabled=yes/no;//whether to disable
SOCKET_TYPE=XXX;//TCP/IP SocketType, such as Stream dgram,raw.
Protocols used by the protocol=xxx;//service
Full path to server=xxx;//service daemon
server_args=xxx;//Service Parameters
port=xxx;//Specifying a service port number
wait=xxx;//whether the service is blocked, that is, single-threaded or multithreaded
UID of the user=xxx;//service process
Group=xxx;//gid
REUSE=XXX;//Reusable Flags
.
.
}
Example
1) Configuring the FTP service
Edit WU-FTPD in the/etc/xinetd.d directory
# Default:on
# description:the WU-FTPD FTP server serves FTP connections. It uses
\
# Normal, unencrypted usernames and passwords for authentication.
Service FTP
{
Disable = no
Socket_type = Stream
wait = no
user = root
Server =/USR/SBIN/IN.FTPD
Server_args =-l-a
Log_on_success + = DURATION
Nice = 10
}
2) Configuring the Telnet service
Edit Telnet under the/etc/xinetd.d directory
# Default:on
# description:the Telnet Server serves Telnet sessions; It uses \
# unencrypted Username/password pairs for authentication.
Service Telnet
{
Disable = no
Flags = Reuse
Socket_type = Stream
wait = no
user = root
Server =/usr/sbin/in.telnetd
Log_on_failure + = USERID
}
Restart service after configuration is complete
/etc/rc.d/init.d/xinetd restart
8,/etc/modules.conf
This file defines the various module parameter information that needs to be loaded at startup, and the file format is as follows:
Alias Eth3 TG3
9,/etc/sysconfig/network-scripts/ifcfg-ethn
The configuration file for the system network device is saved in the/etc/sysconfig/network-scripts directory.
Ifcfg-eth0 represents the first Nic, Ifcfg-eth1 represents the second NIC
The following is a "/etc/sysconfig/network-scripts/ifcfg-eth0" configuration instance:
DEVICE =eth0
Onboot=yes
Bootproto=static
ipaddr=192.168.1.10
netmask=255.255.255.0
gateway=192.168.1.1
If you need to manually modify the network address or add a new network interface on the new interface, you can modify the corresponding file (IFCFG-ETHN), or create a new file to implement.
Linux_ Common network configuration file introduction