Centos Network Configuration
1. Nic Configuration
The NIC must be correctly configured for the host to access the network. The NIC configuration is stored in the/etc/sysconfig/network-script/directory.
The directory contains a lot of scripts about the network configuration, where the NIC configuration uses the ifcfg-eth0 form number.
Modifies the ifcfg-eth0 of the specified Nic profile.
After modifying the NIC configuration, restart the network service (refer to 8 ).
For example:
/Etc/sysconfig/network-scripts/ifcfg-eth0
# Advanced Micro Devices 79c970 [pcnet32 Lance]
Device = eth0 # device name
Bootproto = static | DHCP # use static configuration or IP address assigned by DHCP
Hwaddr = 00: 0C: 29: 26: A2: A6 # Nic physical address MAC
Onboot = Yes
Dhcp_hostname = 192.168.1.1 # DHCP address
Ipaddr = 192.168.1.9 # Nic IP Address
Netmask = 255.255.255.0 # Subnet Mask
Gateway = 192.168.1.1 # gateway IP Address
Broadcast = 192.168.1.255 # broadcast IP
2. network Network Configuration
The/etc/sysconfig/network file records some network configuration information.
For example ):
Networking = Yes | no # Yes indicates that the network needs to be configured. No: No network needs to be configured.
Hostname = yezee # Fully Qualified Domain Name of the host
Gateway = GW-IP # IP address of the Network Gateway
Gatewaydev = GW-dev # gateway device name (for example, eth0 or IP address)
Nisdomain = dom-name # indicates the NIS (Name Information Service) domain (if any)
Forward_ipv4 = "No" # whether to forward IPv4 When configuring a router.
Networking_ipv6 = yes # IPv6 network protocol
3. Configure DNS
The file for saving DNS configuration is/etc/resolv. conf.
Nameserver can have up to three DNS servers.
Up to 6 domain names can be specified for search
Format:
Domain a.yezee.org
Search B .yezee.org c.yezee.org
Nameserver 202.96.128.86
Nameserver 192.168.1.1
I found a description of domain and search keywords on the Internet, which indicates that domain and search keywords have the same role.
Domain linpro. No
Search linpro. No uio. No IFI. uio. No
Domain Function:
Had I typed Telnet math. uio. no. with the trailing dot, the resolver wowould have known it was an FQDN and wowould have looked up math. uio. no at once, without trying to append the specified domain first. not all applications are tolerant of the trailing dot, though, so it can't always be specified.
Search function:
When SSH gram is executed, the resolver first looks for gram. linpro. no, which does not exist; then gram. uio. no, which does not exist, either; and finally gram. ifI. uio. no, which will succeed because it does exist
4. Configure host
It is mainly the/etc/hosts configuration file.
The file records the ing between IP addresses and host names, which is similar to c: \ windows \ system32 \ drivers \ etc \ hosts in Windows XP.
Format:
192.168.1.9 www.yezee.org (hostname host name) yezee (alias)
5. Configure DNS resolution sequence
The configuration of the/etc/host. conf file determines the parsing sequence of/etc/resolv. conf and/etc/hosts.
Generally, DNS domain name resolution and static/etc/hosts configurations exist in the system, and/etc/host. conf determines the resolution sequence of these configurations.
Format:
Order hosts, bind # DNS resolution sequence
Multi on | off # whether a host can have multiple IP addresses in/etc/hosts configuration is allowed or disabled
Nospoof on # disable (check) IP Address Spoofing
Alert on # If IP spoofing is detected, the warning information is recorded through Syslog
The Order keyword defines the DNS resolution sequence. First, use the hosts table on the local machine to resolve the domain name. If the domain name cannot be resolved, use the specified DNS server.
6. Service port configuration
The configuration file/etc/Services records the port correspondence between the port number and the service.
By configuring this fileProgramThe service name can be converted to the port number.
After the configuration is complete, you need to use some commands to check and enable the new configuration.
7. ifconfig command
7.1 run the ifconfig command to check the network configuration. Enter ifconfig and press Enter.
Format: ifconfig or ifconfig eth0 # view the configuration of the specified Nic
Shown as follows:
7.2 use ifconfig to activate and disable NICs (network devices)
Format: ifconfig eth0 up | down
Up indicates the Enable Nic eth0; Down indicates the disable Nic eth0.
7.3 use ifconfig to modify Nic Configuration
Format: ifconfig eth0 192.168.1.9 netmask 255.255.255.0
The nic ip address is changed to 192.168.1.9, And the subnet mask is 255.255.255.0.
7.4 use ifconfig to allow the NIC to obtain the IP address dynamically allocated by DHCP
Format: ifconfig eth0-dynamic
8. Use/etc/rc. d/init. d/network to start and stop the network service.
Format:/etc/rc. d/init. d/Network
Use this script to start, stop, and restart the network service,
The Command actually calls the scripts in the/etc/sysconfig/network-scritps/directory.
9. More common centos network check commands:
Ping www.yezee.org # Ping, simple connectivity test
Traceroute www.yezee.org # view Route Test Results
Netstat-T # View TCP connections. netstat has many useful parameters. For details, refer to the help documentation.
Hostname yezee # change the host name to yezee
ARP # view ARP cache
ARP-s IP Mac # Add IP and Mac ing to the ARP cache
ARP-d ip # Delete ARP ing from ARP cache