Basic configuration knowledge of linux Network-Linux Enterprise Application-Linux server application information. The following is a detailed description. Objectives:
Basic configuration knowledge of linux Network
Command to view Network Information in linux
Measure the test taker's knowledge about network setting commands in linux.
Measure the test taker's knowledge about the network configuration file settings in linux.
View Network Information
View Network Interface Information
1. Understand Network Interface Devices in linux
$/Sbin/ifconfig to view information about all active network interfaces, including a loose.
2. view the information of the specified network interface
$/Sbin/ifconfig <网络接口名称> View the specified interface information.
3. View information of all network interfaces in the system
$/Sbin/ifconfig? A. View All interface information, including inactive interfaces.
Note: When a common user views Network Interface Information, add "/sbin" before the command, but the Administrator does not. This is because the command search
You can view the cause of the cable PATH through "$ echo $ PATH.
View gateway address and route information
1. View host route information
#/Route: displays the route table information of the current linux host.
#/Route | grep default is displayed on the line starting with "default" in the display result of the route command.
The default gateway address of the host, which combines the route command and grep command
Only the default gateway address is displayed.
2. Test the network connection with other hosts
$ Ping the destination host address and use the ping command to test the network connection with other hosts. Ctrl + C terminate.
$ Ping? C <测试数据包数量> <目的主机地址>
Use the ping command to send a specified number of packets for network connection testing.
$ Tips for using the ping command to test network connections
Note: When the ping command test fails, the connection from the current host to the target host cannot be determined to be disconnected because of many factors,
(Such as network firewall), the host cannot be pinged when the network connection is normal.
3. Test the network connection path with other hosts
$ Traceroute <目的主机地址> The traceroute command shows the locations between the current host and the target host.
The address of a network node and the connection from the current host to each intermediate node
Connection status.
View Host Name Information
1. view the current host name
$ Hostname: view the current host name.
2. Use the dns server to query domain names
$ Nslookup
Interactive Mode: usually used to test the DNS server
Direct mode: Used to query the IP address corresponding to a domain name
Use Network commands for network settings
Network Setting Method
1. DHCP Network Configuration
$ Dhclient you can use the dhclient command to apply for a new network configuration from the DHCP server.
Apply to the current host.
Note: The DHCP server usually provides the most basic network configuration information to the DHCP client, including the interface IP address, default gateway, and DNS.
Server address.
2. Manual Network Configuration
Network interface IP address and subnet mask
Default gateway address
Current Host Name
DNS server address
IP Address Configuration command
Ifconfig <网络接口名称> Network <子网掩码>
Example: # ifconfig eth0 192.168.1.222 netmask 255.255.255.0
Note: manual linux network configuration is only for temporary use, and the configuration is not saved.
Extension: # ifconfig eth0: 1 10.0.0.1 netmask 255.0.0.0 multiple sub-IP addresses are configured for one Nic.
# Ifconfig eth0 hw ether MAC address: Modify the mac address of the NIC,
Route configuration command
1. Delete the default gateway route
$ Route del default gw <默认网关地址>
2. Add a default gateway route
$ Route add default gw <默认网关地址>
Example: # route add default gw 192.168.1.1
Host Name configuration command
# Replace hostname 123 with the temporary host name 123.
DNS domain name resolution
Nslookup
> The server displays the DNS server address used in linux, or the temporary settings take effect.
Modify the configuration file to set the network
Use tools for network settings
# Set the network in the Netconfig graphical interface, which takes effect after the network is restarted.
Content to be filled in:
The IP address of the host network interface.
The subnet mask of the network interface.
The default gateway address.
The IP address of the primary DNS server.
Network Service Startup Script
/Etc/init. d/network can take effect after it is restarted
Extension: #/etc/rc. d/init. d/network start network
#/Etc/rc. d/init. d/network stop network
#/Etc/rc. d/init. d/network restart network
Network Interface Configuration File
/Etc/sysconfig/network-scripts/ifconfg -*
DEVICE = eth0 Nic ID
ONBOOT = yes indicates whether the NIC is enabled when the instance is started.
BOOTPROTO = static IP address or DHCP dynamic acquisition.
IPADDR = 192.168.1.163 ip
NETMASK = 255.255.255.0 mask
GATEWAY = 192.168.1.1 GATEWAY
The following is a dynamic acquisition method:
DEVICE = eth0
ONBOOT = yes
BOOTPROTO = dhcp
Stop and start a specified network interface
After the configuration of a single network interface is modified
Ifdown Network Interface Name: Stop a network interface.
Ifup network interface name to enable a network interface.
Note: After the configuration file of a single network interface is modified, you do not have to start the network service to make the configuration file take effect every time. The preceding commands are available.
Extension: Network Interface operation:
# Ifconfig eth0 down stop eth0 Interface
# Ifconfig eth0 up enable the eth0 Interface
Continuous use
Ifdown eth0; ifup eth0
Host Name configuration file
/Etc/sysconfig/network
Example: # vi/etc/sysconfig/network use the vi editor to open the host name configuration file.
NETWORKING = yes indicates whether the Network is available.
HOSTNAME = xxxx is the new host name.
Local host name parsing File
/Etc/hosts
Hosts and DNS have similar host name resolution Functions
Domain Name Server Configuration File
/Etc/resolv. conf
You can set up to three rows.
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.