OBJECT
g[eneral] NetworkManager\'s general status and operations
n[etworking] overall networking control
r[adio] NetworkManager radio switches
c[onnection] NetworkManager\'s connections
d[evice] devices managed by NetworkManager #显示网卡设备信息
a[gent] NetworkManager secret agent or polkit agent
[root@localhost ~]# nmcli d #显示网卡设备信息,查看要配置的网卡名称
[root@localhost ~]# nmcli connection modify ethxx ipv4.method manual ipv4.address 192.168.4.1/24 ipv4.gateway 192.168.4.254 ipv4.dns 192.168.4.200 connection.autoconnect yes #method为manual设为手动,后面才能配ip,一套命令下来可以把获取地址方式、ip地址、掩码、网关、随机自连连接方式都设置好了
[root@localhost ~]# nmcli connection up ethxx #激活刚才配置的网卡信息
>方法二、网络设置-nmtui
[root@localhost ~]# nmtui #进入网卡配置文本界面,进入edit界面
配置完成后,要激活连接,重启一下网卡服务,systemctl restart network
注意ip地址配置的时候是CIDR格式,CIDR的作用就是支持IP地址的无类规划,别忘了/24 ,默认是/32,会导致ssh+ip怎么连都连不上。
补充:
在RedHat的Linux系统中,会发现存在一个本机回送地址:127.0.0.1
[root@localhost ~]# ls /etc/sysconfig/network-scripts/
ifcfg-lo
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-lo #这是系统回环网卡地址配置信息
DEVICE=lo
IPADDR=127.0.0.1
NETMASK=255.0.0.0
NETWORK=127.0.0.0
# If you\'re having problems with gated making 127.0.0.0/8 a martian,
# you can change this to something else (255.255.255.255, for example)
BROADCAST=127.255.255.255
ONBOOT=yes
NAME=loopback
对于回送地址,查了一下相关资料,有以下收获: