Home > System Tutorial > Linux > body text

Analysis of Red Hat Linux9 version network management and three network connection methods of VMware virtual machines

PHPz
Release: 2024-06-23 15:34:18
Original
864 people have browsed it

红帽 Linux9 版本网络管理及 VMware 虚拟机三种网络连接方式解析

This article uses Red Hat Linux9 version as an example to explain.

The network management of Red Hat Linux 9 version is very comprehensive, and network configuration changes can be made in many places. However, it should be noted that in version 9, users can make network configuration changes in the configuration file, but the system cannot. The changed command will be executed, and versions before version 9 can execute it.

Three types of network connections on VMware virtual machines

Bridge Mode:

Connect the network card on the host to the virtual network card Vmnet0 through the virtual hub. In bridge mode, the network card of the virtual machine is connected to the virtual switch Vmnet0. When the virtual machine wants to access the InternetLinux system and network managementIs the Linux system easy to use? , the virtual machine IP address, subnet segment, network segment, etc. need to be configured the same as the host network card.

NAT mode:

Connect the network card on the host to the virtual network card Vmnet8 through the virtual hub. In NAT mode, the DHCP server of the virtual machine is connected to the Vmnet8 virtual switch. It should be noted that the virtual network card Vmnet8 is only used as a communication socket between the host and the virtual machine. The machine finally uses the host network card to connect to the Internet.

Host-Only mode:

The virtual network card Vmnet1 is connected to the virtual switch Vmnet1 to realize virtual machine communication. When the virtual machine needs to be connected to the Internet, the network card of the host network is shared with the virtual network card Vmnet1 to realize virtual machine networking.

Features of NetworkManager

NetworkManager is a project launched by RedHat in 2004 to allow Linux users to more easily handle modern network needs and manually discover network cards and configure IP addresses.

Features of NetworkManager

NM can manage all kinds of networks:

Wired network card, wireless network card

Dynamic ip, static ip

Ethernet, non-Ethernet

Chemical network card, virtual network card

Complete tools:

Command line, text interface, graphical interface, web

Recruit the world:

Manage various types of networks, wired, wireless, physical, virtual

Rich parameters:

Up to 200 configuration parameters (including ethtool parameters)

Unify the world:

RedHat system, Suse system, Debian/Ubuntu system, all supported

linux系统与网络管理_网络管理系统admin_网络管理系统入口

The general trend:

Starting from Red Hat Linux version 9, the network can only be managed through NM

1. Configure the network

Network socket refers to the entrance and exit for communication between computers or network equipment and other devices on the network. Here, it mainly refers to the computer's network socket, that is, the network card device.

Starting from Red Hat Linux 7 version, a new "Consistent Network Device Naming" form has been introduced for naming network sockets. This method can assign fixed names based on firmware, device topology, device type and location information. The first two characters of the network jack's name are the network type symbols.

Network type symbol:

en: stands for Ethernet

wl: stands for Wireless LAN (wlan)

ww: stands for wireless wide area network (wwan)

Select symbols based on device type or location:

o: Indicates the integrated device (i.e. integrated network card) and Soton number external to the graphics card;

s: Indicates an independent device plugged into a hot-swappable jack;

x: represents the device named based on the MAC address; p——represents the mathematical position and number of the PCI jack.

Things to note are:

A network socket can have multiple network connections, but only one network connection can be active at the same time.

1. Modify the configuration file (not recommended)

Prerequisite:

Requires network service

Step into profile

vim/etc/NetworkManager/system-connections/ens160.nmconnection

Compile the corresponding content in the configuration file

[root@tym ~]# vim /etc/NetworkManager/system-connections/ens160.nmconnection 
[connection]
id=ens160
uuid=63a4d8e6-5b83-3145-b9d8-81ac17ac17cc
type=ethernet
autoconnect-priority=-999
interface-name=ens160
timestamp=1708402421
[ethernet]
[ipv4]
address1=192.168.218.4/24,192.168.218.2
dns=223.5.5.5;
method=manual
[ipv6]
addr-gen-mode=eui64
method=auto
[proxy]
Copy after login

2. Use the IP command to configure a temporarily effective network connection to view the configuration information of the network card at the network layer. Add -s to display relevant statistical information, such as the number of data packets received (RX) and transmitted (TX).

ip[-s]addrshow[network card device name]

[root@tym ~]# ip addr show ens160
2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:0c:29:57:78:25 brd ff:ff:ff:ff:ff:ff
altname enp3s0
inet 192.168.218.4/24 brd 192.168.218.255 scope global noprefixroute ens160
 valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe57:7825/64 scope link noprefixroute 
 valid_lft forever preferred_lft forever
Copy after login

View the configuration information of the network card at the data link layer

ip[-s]linkshow[network card device name]

linux系统与网络管理_网络管理系统入口_网络管理系统admin

[root@tym ~]# ip link show ens160
2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000
link/ether 00:0c:29:57:78:25 brd ff:ff:ff:ff:ff:ff
altname enp3s0
Copy after login

Add or delete the temporary IPv4 address of the network card; add or delete the temporary IPv6 address of the network card

ip[-4]addradd|delIP address[/network segment width]dev network card connection name

ip-6addradd|delIP address[/network segment width]dev network card connection name

[root@tym ~]# ip addr add 192.168.218.5/24 dev ens160
[root@tym ~]# ip a
inet 192.168.218.4/24 brd 192.168.218.255 scope global noprefixroute ens160
 valid_lft forever preferred_lft forever
inet 192.168.218.5/24 scope global secondary ens160
 valid_lft forever preferred_lft forever
Copy after login

禁用|启用指定网卡

iplinksetdev网卡的设备名down|up

[root@tym ~]# ip link set dev ens160 up
Copy after login

三、nmcli命令(命令行工具)

命令界面输入“nmcli”,按下"Tab"键,输出相匹配的后续命令,输入相匹配的命令后,按下"Tab"键继续输出相匹配的后续命令。

[root@tym ~]# nmcli 
agent connectiondevicegeneral helpmonitor networkingradio
[root@tym ~]# nmcli connection 
adddelete edit help load modify reload up 
clonedown export import migratemonitorshow
Copy after login

查看网卡设备

nmclidevice

缩写:nmclid

[root@tym ~]# nmcli device
DEVICETYPESTATECONNECTION 
ens160ethernetconnectedens160 
loloopbackunmanaged-- 
Copy after login

nmclideviceshow

[root@tym ~]# nmcli device show 
GENERAL.DEVICE: ens160
GENERAL.TYPE: ethernet
GENERAL.HWADDR: 00:0C:29:57:78:25
GENERAL.MTU:1500
GENERAL.STATE:100 (connected)
Copy after login

connected:已被NM管理,但是当前有活跃的connection

disconnected:已被NM管理,并且当前没有活跃的connection

unmanaged:未被NM管理

unavailable:不可用,NM难以管理,一般出现于网卡为down的时侯

查看网卡相应的会话

nmcliconnection

缩写:nmclic

nmclicshow

[root@tym ~]# nmcli connection 
NAMEUUIDTYPEDEVICE 
ens16063a4d8e6-5b83-3145-b9d8-81ac17ac17ccethernetens160 
Copy after login

配置已存在会话的网卡的IP地址

非交互式:

nmclicmodify……)----非交互式的相关配置

[root@tym ~]# nmcli connection modify ens160 ipv4.method manual ipv4.addresses 192.168.218.5/24ipv4.gateway 192.168.218.2ipv4.dns 223.5.5.5autoconnectyes
[root@tym ~]# nmcli c up ens160(重启网卡设备)
Copy after login

交互式:

nmclicedit……)----交互式的相关配置

[root@tym ~]# nmcli connection edit ens160
nmcli> goto ipv4
nmcli ipv4> set addresses 192.168.168.11/24
nmcli ipv4> activate(激活)
nmcli ipv4> quit
[root@tym ~]# nmcli c up ens160
Copy after login

添加新的会话

nmclicaddtypeethernetcon-name会话名称ifname网卡设备ipv4.addressesIP地址ipv4.gateway网段ipv4.dnsdns服务器ipv4.methodmanualautoconnectyes

[root@tym ~]# nmcli c add type ethernet con-name 1 ifname ens160 ipv4.addresses 192.168.218.11/24 ipv4.gateway 192.168.218.2 ipv4.dns 223.5.5.5 ipv4.method manual autoconnect yes
Connection '1' (635585a9-aed8-4327-9bf8-7fbf1565036b) successfully added.(会话建立成功)
[root@tym ~]# nmcli c show
NAMEUUIDTYPEDEVICE 
ens16063a4d8e6-5b83-3145-b9d8-81ac17ac17ccethernetens160 
1 635585a9-aed8-4327-9bf8-7fbf1565036bethernet--
Copy after login

联接、断开、删除会话

联接会话

[root@tym~]#nmclicup网卡设备

断掉会话

[root@tym~]#nmclicdown网卡设备

删掉会话

[root@tym~]#nmclicdelete网卡设备

四、nmtui(图形界面工具)

nmtui(命令行回车后linux系统与网络管理,步入图形化界面)

命令回车后步入的第一页面如右图。

在这里插入图片描述

使用按键上的上下左右键可进行不同选项的选择,选项的涵义如下:

Edit a connection ----编辑一个网络连接,即可创建或修改一个网络连接
Activate a connection ----激活一个网络连接
Set system hostname ----设置系统的主机名
Copy after login

步入选项“Editaconnection”,创建一个新的网路联接。

在这里插入图片描述

步入选项后,我们使用鼠标左右键联通光标,选中“Add”选项,创建一个新的网路联接

在这里插入图片描述

步入“Add”选项后,我们选择“Ethernet”选项

网络管理系统入口_网络管理系统admin_linux系统与网络管理

在这里插入图片描述

选择完成网路类型后,回车步入如下页面

在这里插入图片描述

在此页面,使用上下键联通光标,我们须要将IPv4的配置模式修改为自动模式,并在虚拟机相对应的网路联接模式(桥接模式、NAT模式、Host-Only模式)下进行相应的IP地址、网关、DNS服务器等配置

在这里插入图片描述

配置完成后,使用上下键将光标联通至最下方,并选中“OK”,之后回车

在这里插入图片描述

步入选项“Activateaconnection”,激活创建的网路联接。

在这里插入图片描述

使用上下左右键选中创建的新网路联接,并将光标联通至“Deactivate”处,进行回车,如网路联接前显示“*”号,则代表该联接已激活

在这里插入图片描述

最后,回到最初的页面,选中“Quit”,并联通光标至“OK”,之后回车,完成新网路联接的创建和激活。

网络管理系统admin_linux系统与网络管理_网络管理系统入口

二、网络测试命令一、ping命令

用于测试网路的连贯性

命令格式为:

ping[选项]

选项:

-c 数字:用于设定本命令发出的ICMP消息包的数量,若无此选项,则会无限次发送消息包直到 用户按【Ctrl+C】组合键才终止命令。
-s 字节数:设置ping命令发出的消息包的大小,默认发送的测试数据大小为56字节;自动添加8字节的ICMP协议头后,显示的是64字节;再添加20字节的IP协议头,则显示的为84字节。最大设置值为65507B。
-i 时间间隔:设定前后两次发送ICMP消息包之间的时间间隔,无此选项时,默认时间间隔为1 秒。为了保障本机和目标主机的安全,一般不要小于0.2秒。
-t :设置存活时间TTL(Time To Live)
Copy after login

使用疗效如下:

[root@tym ~]# ping -c 2 www.baidu.com
PING www.a.shifen.com (120.232.145.185) 56(84) bytes of data.
64 bytes from 120.232.145.185 (120.232.145.185): icmp_seq=1 ttl=128 time=35.1 ms
64 bytes from 120.232.145.185 (120.232.145.185): icmp_seq=2 ttl=128 time=36.1 ms
--- www.a.shifen.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1002ms
rtt min/avg/max/mdev = 35.093/35.573/36.053/0.480 ms
Copy after login

二、tracepath命令

用于追踪并显示报文抵达目的主机所经过的路由信息

命令格式为:

tracepath[选项]

常用选项:

-n :对沿途各主机节点,,仅仅获取并输出IP地址,不在每个IP 地址的节点设备上通过DNS查找其主机名,以此来加快测试速度。
-b :对沿途各主机节点同时显示IP地址和主机名。
-l 包长度:设置初始的数据包的大小。
-p 端口号:设置UDP传输协议的端口(缺省为33434)
Copy after login

网络管理系统admin_网络管理系统入口_linux系统与网络管理

使用疗效如下:

[root@tym ~]# tracepath -b www.baidu.com
 1?: [LOCALHOST]pmtu 1500
 1:_gateway (192.168.218.2)0.198ms 
 1:_gateway (192.168.218.2)0.337ms 
 2:no reply
Copy after login

三、traceroute命令(Windows系统下是tracert)

该命令借助ICMP合同定位计算机和目标计算机之间的所有路由器,追踪数据包在网路上传输时的全部路径linux系统教程,它默认发送的数据包大小是40字节

命令格式为:

traceroute[选项]

常用选项:

-I :使用ICMP协议
Copy after login

三、通过域名来访问主机一、配置静态解析,通过/etc/hosts文件实现域名解析

[root@tym ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.218.4 tym
[root@tym ~]# ping tym
PING tym (192.168.218.4) 56(84) bytes of data.
64 bytes from tym (192.168.218.4): icmp_seq=1 ttl=64 time=0.091 ms
64 bytes from tym (192.168.218.4): icmp_seq=2 ttl=64 time=0.083 ms
Copy after login

二、通过/etc/resolv.conf文件委派域名解析服务器的地址,由dns服务器做域名解析

[root@tym ~]# vim /etc/resolv.conf 
# Generated by NetworkManager
nameserver 223.5.5.5
nameserver 192.168.218.4
[root@tym ~]# host www.baidu.com 192.168.218.4
Using domain server:
Name: 192.168.218.4
Address: 192.168.218.4#53
Aliases: 
www.baidu.com is an alias for www.a.shifen.com.
www.a.shifen.com has address 120.232.145.144
www.a.shifen.com has address 120.232.145.185
www.a.shifen.com has IPv6 address 2409:8c54:870:67:0:ff:b0c2:ad75
www.a.shifen.com has IPv6 address 2409:8c54:870:34e:0:ff:b024:1916
Copy after login

四、从网站下载文件一、wget命令

用于在终端命令行里下载网路文件,中文全称为:webget

命令格式为:

wget[选项]网址

选项:

-P :下载到指定目录
-t :最大尝试次数
-b :后台下载模式
-c :断点续传
-p :下载页面内所有资源,包括图片、视频等
-r :递归下载
Copy after login

使用疗效如下:

[root@tym ~]#wget http://rpmfind.net/linux/epel/8/Everything/x86_64/Packages/s/sl-5.02-1.el8.x86_64.rpm
--2024-04-03 21:23:56--http://rpmfind.net/linux/epel/8/Everything/x86_64/Packages/s/sl-5.02-1.el8.x86_64.rpm
Resolving rpmfind.net (rpmfind.net)... 195.220.108.108
Connecting to rpmfind.net (rpmfind.net)|195.220.108.108|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 16564 (16K) [application/x-rpm]
Saving to: ‘sl-5.02-1.el8.x86_64.rpm’
sl-5.02-1.el8.x86_64.rpm100%[=====================================>]16.18K5.77KB/sin 2.8s
2024-04-03 21:24:02 (5.77 KB/s) - ‘sl-5.02-1.el8.x86_64.rpm’ saved [16564/16564]
[root@tym ~]# ls
anaconda-ks.cfgsl-5.02-1.el8.x86_64.rpm
Copy after login

二、curl命令

curl命令是一个网路工具,其主要作用是通过http、https、ftp等形式下载/上传文件

命令格式为:

curl网址[选项]

选项:

-o :指定名称
Copy after login

使用疗效如下:

[root@tym ~]# curl www.baidu.com -o baidu.html
% Total% Received % XferdAverage Speed TimeTime TimeCurrent
 DloadUpload Total SpentLeftSpeed
100238110023810 0196770 --:--:-- --:--:-- --:--:-- 19677
[root@tym ~]# ls
anaconda-ks.cfgbaidu.htmlsl-5.02-1.el8.x86_64.rpm
Copy after login

The above is the detailed content of Analysis of Red Hat Linux9 version network management and three network connection methods of VMware virtual machines. For more information, please follow other related articles on the PHP Chinese website!

source:itcool.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact [email protected]
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!