[Linux] Detailed steps of network configuration and related basic knowledge introduction

1. Linux network configuration steps

1. Log in to rootthe account.
You need to use root authority to perform network configuration, so you need to log in as the root user first.

​​​​​​
2. Enter ip addrto view network information

insert image description here
There is only one local address 127.0.0.1, because the network card switch of the Linux operating system has not been turned on.

3. Enter cd /etc/sysconfig/network-scripts/the directory

insert image description here
4. After entering this directory, lsview the files in the directory through the command

insert image description here

The arrow in the above figure points ens33to the name of the Linux network card.

5. Enter vi ifcfg-ens33to view the network configuration

insert image description here
The last line ONBOOT=no means that the network card is not turned on. This command means whether to activate the network card, and the parameter is changed to yes to indicate that the network card must be activated.

6. Press Ato enter the edit mode, use the up and down arrows to change ONBOOT=nothe parameter tonoyes

insert image description here

7. Press escto exit edit mode

8. Press shift+ :together to enter the command line, enter wq, and then enterexit to save

insert image description here
Because the host configuration protocol is set to , the address dhcpof linux will be automatically assigned to us , so there is no need to manually configure the address.ipip

9. Input service network restart, restart Linuxthe network card
After configuring the network card information, enter the following command to restart the Linux network card, and the network configuration will take effect.
insert image description here
10. ping www.baidu.comTest whether the network connection is successful

insert image description here
There is data returned, which proves that the network has been successfully connected.

Two, Linux network configuration principle

The Windows system WLANis connected to the external network through a network card.
insert image description hereLinuxThe system is installed in the virtual machine Windowsin the system VMware, and its network card is called ip. 子网ipIt needs to connect to the virtual router, and then the virtual router connects to the network card, connects vmnet8through the network card , and finally connects to the network to realize the network configuration.vmnet8WLAN网卡外网Linux

What is the subnet ip, what is the gateway, what is the network ip of vmnet8, and the viewing method is mentioned below.

3. Configure the basic knowledge related to the network

1. VMwareTwo network interfaces will be provided for us: VMnet1and VMnet8, to configure the network for Linux, we choose to use VMnet8.

In the system network settings, open the change adapter option, you can see the following figure

insert image description here
2.子网ip
linux The operating system is installed windowsinside, and linux uses a subnet, so the ip of linux is also called the subnet ip.

insert image description here
The point 0 in the back indicates the initial segment of the subnet ip . When we use it, it is not necessarily 0. 3 to 254 can be used.

3.网关ip
The gateway ip is our virtual route, and the ip it uses is called the gateway ip.

4. Supplementary part: Manually configure the networking ip of Linux

1. Enter the command vi ifcfg-enssto enter the file to configure the network
2. dhcpChange the parameter to static
3. Set the subnet ip: IPADDR=192.168.111.3
192.168.111.3 to 192.168.111.254 can be written casually.
4. Set the subnet mask: NETMASK=255.255.255.0
5. Set the default gateway: GATEWAY=192.168.111.2
6. Configure the preferred DNS server: DNS1=114.114.114.114
7. Configure the alternate DNS server: DNS2=8.8.8.8
8. After the setting is completed, escexit the editing mode, shift+:enter the command line, enter, wqsave and exit
9. Restart the network: service network restart
10. Check the IP address:ip addr

insert image description here
You can see that the IP address has been changed to the one we set: 192.168.111.3.
11. Test network: ping www.baidu.com
If there is data returned, it proves that the networking is successful.

Guess you like

Origin blog.csdn.net/hold_on_qlc/article/details/130440562