网络管理工具
iproute 软件包包括 ip ss 命令
net-tools软件包包括 ifconfig route netstat命令
ip 命令相当于之前的 ifconfig route
ss 命令相当于之前的 netstat
nmtui 命令(软件包NetworkManager-tui) setup命令 (软件包setuptool)
nmtui命令替代setup命令
nmcli 网络管理客户端
nmcli常用命令
查看网络连接
[root@localhost ~]# nmcli connection
NAME UUID TYPE DEVICE
eth0 f2e44960-4b5c-4b4b-8b3e-ba1206b3926b ethernet eth0
eth1 9c87161a-54b5-4bbc-b0b8-ea31ecce5f14 ethernet eth1
eth2 0ab31d07-7c68-44cf-8207-dbb2f453da01 ethernet eth2
查看网络设备
nmcli device
修改网卡配置方法1
修改配置
nmcli connection modify eth0 ipv4.addresses 10.0.0.220/24 ipv4.gateway 10.0.0.254 ipv4.method manual autoconnect yes
停止网卡
nmcli connection down eth1
启动网卡
nmcli connection up eth1
修改网卡配置方法2
vim修改网卡配置文件
重载网卡配置文件
nmcli connection reload
停止网卡
nmcli connection down eth1
启动网卡
nmcli connection up eth1
网卡添加IP地址
nmcli connection modify eth0 +ipv4.addresses 10.0.0.32/24
nmcli connection down eth0 && nmcli connection up eth0
添加一块网卡
添加静态ip的网卡
nmcli connection add con-name eth1 ipv4.addresses 172.16.1.220/24 ipv4.gateway 172.16.1.254 ipv4.method manual autoconnect yes type ethernet ifname eth1
添加动态ip的网卡
nmcli connection add con-name eth2 ipv4.method auto autoconnect yes type ethernet ifname eth2
ifname <interface name>
con-name <connection name>
删除连接网卡(网卡配置文件也被删除)
nmcli connection delete eth1
CentOS8网络管理脚本
yum install network-scripts
附
路由添加与删除
ip route add 10.15.150.0/24 via 192.168.150.253 dev eth0
ip route del 10.15.150.0/24
ip route add default via 192.168.0.254 dev eth2
ip route del default via 192.168.0.254 dev eth2
ip、ifconfig、brctl
网卡接口操作 | ip | ifconfig/brctl |
---|---|---|
关闭网卡接口 | ip link set docker0 down | ifconfig docker0 down |
删除网卡接口 | ip link delete docker0 | brctl delbr docker0 |