怎么在Linux系统中查看和编辑网卡信息?

以下是在 Linux 中检查网卡信息的一些技巧:
检查特定网卡: vim /etc/sysconfig/network-scripts/ifcfg-<网卡名称> 例如eth0,直接打开文件即可看到配置。
注意:该路径可能会更改,例如,在某些系统上它是 /etc/network/interfaces。

Look at the DNS settings: vim /etc/resolv.conf Inside is the DNS server address.
View all network cards: nmcli 扩展计划 List all network cards and configurations.
It all depends on the network equipment: 显示 nmcli 设备 甚至还显示了无线。

Change network card configuration: 首先看连接细节:nmcli连接方案 找到要更改的连接的名称,例如 Wiredconnection1
Change parameters directly using: nmcli 连接模式 <连接名称> <参数> <值> For example, changing the IP: nmcli连接模式“Wiredconnection1 ”ipv4 .addresses“1 9 2 .1 6 8 .1 .1 00/2 4 ”
添加DNS: nmcli 连接模式 <连接名称> ipv4 .dns +<新地址> For example, add 8 .8 .8 .8 : nmcli连接模式“Wiredconnection1 ” ipv4 .dns +8 .8 .8 .8
删除DNS: nmcli 连接模式 <连接名称> ipv4 .ignore-auto-dns 是 先忽略自动 DNS,然后切换到手动设置。

进行更改后必须重新启动网络: systemctl restart NetworkManager 或者: nmcli connection down <连接名称> && nmcli connection up <连接名称>
首先,我不记得具体的参数名称,但可能是这样的。

Linux常用的四种配置网卡方式

vim配置:1 9 2 .1 6 8 .1 0.2 0/2 4 ,ens1 6 0,系统重启后生效。
nm-connection-editor:GUI,重启后生效。
在系统托盘中:有线网络设置。
重新启动以使更改生效。
nmtui:字符界面,重启后生效。
实用提醒:重启后请务必检查您的配置。