Linux system configures network for virtual machine
configure network (nmtui)
IP address, subnet mask, gateway, DNS
IP address (the unique number of each computer, IPv4 dotted decimal, such as 1.1.1.1)
IP address range 0-255, (binary 00000000-11111111)
1.1.1.1 (this IP The address can be divided into network bits and host bits, the subnet mask determines where the network bits go)
The IP address is 1.1.1.1, the subnet mask is 255.0.0.0, the result: the first number represents the network
IP address is 1.1. 1.1, the subnet mask is 255.255.0.0, the result: the first two numbers represent the network
cross-network route, configure the gateway for your computer (the gateway is your router)
DNS (give a domain name, DNS can be resolved to IP, Give an IP to resolve the corresponding domain name)
Prepare the experimental environment (create a virtual machine):
1. Several virtual machines are preset in the f0-rhel82 (server1) computer
2. Use virt-manager to view the virtual machine (The command terminal can directly execute the virt-manager command.)
By default, there is a virtual machine named utility (this virtual machine takes up memory resources and can be closed temporarily)
3. Use rht (enter the Tab key to realize the automatic completion of the command ), rht-vmctl reset red
Execute the rht-vmctl reset red command, it will automatically initialize a virtual machine, and automatically start the virtual machine
The virtual machine uses:
virt-manager
finds red, double-click it.
localhost login: Prompt to log in, enter the user name is: root
Password: Prompt to enter the password, the password is: redhat
After entering the system, you can execute the command
ip as (ip address show, check the network card and the corresponding IP)
The name of the network card in Linux is generally eth0, eth1, eth2 (ethernet), sometimes the network card name may also be ens33, ens36
nmtui (a tool for configuring IP)
Edit a connection (configure the network)
Activate a connection (activate the network)
select "Edit a connection" and press Enter,
select the name of the network card that needs to configure IP, such as eth0, and then select Edit on the right (combined with the left and right keys and the up and down keys), and press Enter to go up and
down Press Enter to select IPv4.
Select Manual (manually configure IP), press Enter,
select "show" on the right side of the direction machine, and press Enter.
Addrees (IP address), click Add to add IP
Gateway (gateway), directly enter
DNS servers (DNS domain name resolution server), click Add to add server IP
in the experimental environment:
IP: 172.25.0.25/24 (24 is the subnet mask 255.255.255.0)
Gateway: 172.25.0.254 (server1 is the gateway)
DNS: 172.25.0.254 (server1 is the DNS server)
Be sure to check the option to use a space, or uncheck
automatically when the computer starts Activate the network card automatically, and
finally select "OK"
and select "Back" below to return
. Select "Activate a connection
" to activate
the network card. There is a * in front, which means the network card has been activated.
After activating the network card, select "Back" again
and finally select OK
Ping the red virtual machine on the Server1 host to test whether the network is connected:
[root@server1 ~]# ping -c 4 172.25.0.25
Configure the network for the local virtual machine
Right-click the f0-rhel82 virtual machine, select "Settings",
click "Add"
, select "Network Adapter", click "Finish", click "OK"
to open the command terminal on the server1 computer:
click Activities—>terminal (command terminal) in the upper left corner of the desktop )
ip as (You will see that there is an additional network card on the server1 computer, named eth1)
nmtui (a tool for configuring IP)
Select "Edit a connection" and press Enter.
The name of the network card here is not eth1, but Wired connection 1 (wired connection 1).
Select Wired connection 1, then select "Edit" and press Enter
to modify the Profile name: change the name of the network card Change to eth1, and then you can configure Automatic (automatically obtain IP) below,
or you can refer to the above practice steps to select manual (manually configure IP).
Finally, remember to activate the network card (refer to the screenshot of the previous steps)