A network card IP address setting
1. After installing the Linux system using the minimum, the Internet is temporarily disabled, and the network adapter needs to be configured. As shown in the figure below, the virtual machine selects the NAT mode.
Click the VMware option "Edit" -> "Virtual Network Editor" to view the network segment used in NAT mode, as shown in the figure below for the 20.0.0.0 network segment.
2. Open the virtual machine.
Use the vi editor to add the IP address, subnet mask, gateway, and modify BOOTPROTO and ONBOOT.
Enter the command " vi /etc/sysconfig/network-scripts/ifcfg-ens33 ".
Note : This is because of the real machine The gateway is 20.0.0.1, so the virtual machine gateway must be set to 20.0.0.2 so that it will not conflict with the real machine gateway.
Press the ESC key to exit from the input mode to the command mode *, then enter ":" to enter the last line mode , wq save and exit .
3. Enter the command " systemctl restart network " to restart the network service, the IP address can already be pinged
Two DNS configuration
After completing the basic settings of the IP address, although the Internet can be accessed, the entered URL cannot be resolved (that is, www.baidu.com cannot be pinged), so you need to set the DNS at this time.
1. Enter the configuration file
vi /etc/resolv.conf and
add " nameserver 8.8.8.8 "
2. Enter the configuration file
vi /etc/NetworkManager/NetworkManager.conf and
add
dns=none under [main]
3. Enter the command " systemctl restart NetworkManager "Restart the network service, now you can ping the I website
Three add a new network card
1. Click "Virtual Machine" -> "Settings" -> "Add" -> "Network Adapter", select NAT mode.
Enter the command " nmcli connection " to view the UUID information of the network card.
Copy the UUID information.
2. Enter the command " cd /etc/sysconfig/network-scripts/ " to enter this directory and
enter the command "ll" to view the files in this directory and find ifcfg -ens34
3. Enter the command " cp ifcfg-ens33 ifcfg-ens34 " to copy the content of ens33 to ens34 and
modify the following
NAME="ens33"--->NAME="ens34"
DEVICE="ens33"-->NAME="ens34"
UUID="73d73154-ad5e-4800-a230-70dbb7d03ec1"
IPADDR="20.0.0.65" //在20.0.0.0/24网段随意设置
Enter the command "systemctl restart network" to refresh the settings.
Enter the command "ip addr" to view the network card information
Four commonly used commands for network testing
1.ifconfig command
View the information of the enabled network card in the current host
1.1 View specified network card information
ifconfig ens33
ether: physical address
inet: IP address
broadcast: broadcast address
netmask: subnet mask
TX: sent data packet
RX: received data packet
2.ip/ethtool command
Same as ifconfig command, view network card information, but more powerful
2.1 ip link
View data link layer information
2.2 ip addr
View network layer information
2.3 ethtool ens*
View the speed, mode and other information of the network card
3.route command
View routing table information
Generally combined with the "-n" option, "-n" means to display the address in the routing record as a number.
Destination means the target network segment, and Iface means the network interface that sends the data.
4.netstat command
View network connection status
Common options
-a View all connection information
-n Display in digital form
-u View udp protocol connection
-t View TCP protocol connection
-p Display process number
-r Display routing table information
5.ping command
Test network connectivity
6.traceroute command
Tracking the routing path of data packets, you can view which network nodes have passed from the current host to the target host, and display the connection status of each intermediate node. The connection status is "*" indicating a node that cannot respond
7. nslookup command
Test DNS domain name resolution
dig command is more detailed than nslookup
8. Add and delete gateway records
route del default gw 20.0.0.2 //删除默认网关记录20.0.0.2
route add default gw 192.168.1.1 //添加默认网关记录192.168.1.1