A:方法一:
一、动态网络配置
(1)打开终端,以网口 ens3 为例
(2)编辑文件/etc/sysconfig/network-scripts/ifcfg-ens3,设置BOOTPROTO为dhcp:
二、静态网络配置
(1)打开终端,以网口 ens3 为例:
(2)编辑文件/etc/sysconfig/network-scripts/ifcfg-ens3,设置BOOTPROTO为static, 填写 IP、子网掩码、网关:
方法二:
一、 动态网络配置
打开终端,以网口 eth0 为例:
# nmcli conn add connection.id eth0-dhcp type ether ifname eth0 ipv4.method auto
其中“eth0-dhcp”为连接的名字,可以根据自己的需要命名方便记忆和操作的名字;“ifname eth0”为配置的网口,根据自己的设备情况按需调整。
二、 静态网络配置
打开终端,以网口 eth0 为例:
# nmcli conn add connection.id eth0-static type ether ifname eth0 ipv4.method manual ipv4.address 192.168.1.10/24 ipv4.gateway 192.168.1.254 ipv4.dns 192.168.1.254
其中“eth0-static”为连接的名字,可以根据自己的需要命名方便记忆和操作 的名字;“ifname eth0”为配置的网口,根据设备情况按需调整;IP、子网掩码、 网关根据实际网络按需配置。