Linux system configures network for virtual machine

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
insert image description here
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)

insert image description here
Edit a connection (configure the network)
Activate a connection (activate the network)
select "Edit a connection" and press Enter,
insert image description here
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
insert image description here
down Press Enter to select IPv4.
insert image description here
Select Manual (manually configure IP), press Enter,
insert image description here
select "show" on the right side of the direction machine, and press Enter.
insert image description here
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)
insert image description here
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"
insert image description here
and select "Back" below to return
insert image description here
. Select "Activate a connection
insert image description here
" to activate
the network card. There is a * in front, which means the network card has been activated.
insert image description here
After activating the network card, select "Back" again
insert image description here
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

insert image description here
Right-click the f0-rhel82 virtual machine, select "Settings",
insert image description here
click "Add"
insert image description here
, 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)

insert image description here
Select "Edit a connection" and press Enter.
insert image description here
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
insert image description here
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)

Guess you like

Origin blog.csdn.net/qq_51344334/article/details/111361771