1、编辑网卡配置文件
vi /etc/sysconfig/network-scripts/ifcfg-ens33
2、修改以下配置
BOOTPROTO=static #dhcp:自动分配ip ,static:静态ip
ONBOOT=yes #开启启动必须是yes
3、设置IP、掩码、网关、DNS1、DNS2
IPADDR=192.168.0.202 #ip地址
NETMASK=255.255.255.0 #掩码
GATEWAY=192.168.0.1 #网关
DNS1=192.168.0.1 #域名服务器1
DNS2=8.8.8.8 #域名服务器1
4.重启网络服务
systemctl restart network
参照下图
当执行 ifup ens33 出现错误:
[root@localhost ~]# ifup ens33
Error: Connection activation failed: No suitable device found for this connection (device lo not available because device is strictly unmanaged).
1
解决办法:
[root@localhost ~]# systemctl stop NetworkManager.service
Note: Forwarding request to ‘systemctl disable NetworkManager.service’.
Removed symlink /etc/systemd/system/multi-user.target.wants/NetworkManager.service.
Removed symlink /etc/systemd/system/dbus-org.freedesktop.NetworkManager.service.
Removed symlink /etc/systemd/system/dbus-org.freedesktop.nm-dispatcher.service.
Removed symlink /etc/systemd/system/network-online.target.wants/NetworkManager-wait-online.service.
[root@localhost ~]# systemctl stop NetworkManager.service
Redirecting to /bin/systemctl stop NetworkManager.service
[root@localhost ~]# systemctl restart network.service
Starting network (via systemctl): [ OK ]