1. Linux network configuration steps
1. Log in to root
the 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 addr
to view network information
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
4. After entering this directory, ls
view the files in the directory through the command
The arrow in the above figure points ens33
to the name of the Linux network card.
5. Enter vi ifcfg-ens33
to view the network configuration
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 A
to enter the edit mode, use the up and down arrows to change ONBOOT=no
the parameter tono
yes
7. Press esc
to exit edit mode
8. Press shift
+ :
together to enter the command line, enter wq
, and then enter
exit to save
Because the host configuration protocol is set to , the address dhcp
of linux will be automatically assigned to us , so there is no need to manually configure the address.ip
ip
9. Input service network restart
, restart Linux
the 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.
10. ping www.baidu.com
Test whether the network connection is successful
There is data returned, which proves that the network has been successfully connected.
Two, Linux network configuration principle
The Windows system WLAN
is connected to the external network through a network card.
Linux
The system is installed in the virtual machine Windows
in the system VMware
, and its network card is called ip
. 子网ip
It needs to connect to the virtual router, and then the virtual router connects to the network card, connects vmnet8
through the network card , and finally connects to the network to realize the network configuration.vmnet8
WLAN网卡
外网
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. VMware
Two network interfaces will be provided for us: VMnet1
and 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
2.子网ip
linux
The operating system is installed windows
inside, and linux uses a subnet, so the ip of linux is also called the subnet ip.
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-enss
to enter the file to configure the network
2. dhcp
Change 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, esc
exit the editing mode, shift+:
enter the command line, enter, wq
save and exit
9. Restart the network: service network restart
10. Check the IP address:ip addr
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.