Linux关于网络的设置

1、打开文件
vim /etc/sysconfig/network-scripts/ifcfg-ens33 

2、添加静态分配ip地址
将ONBOOT=no改为yes,将BOOTPROTO=dhcp改为BOOTPROTO=static,并在后面增加几行内容: 
IPADDR=192.168.127.128 
NETMASK=255.255.255.0 
GATEWAY=192.168.127.2 
DNS1=119.29.29.29 

3、保存文件
:wq!

4、重启网络
systemctl restart network.service

5、用命令查看IP,并用命令ping测试网络的连通性。
ip addr

6.自动获取ip地址DHCP
是指使用动态主机配置协议动态的配置网络接口的网络参数
dhclient
Editing is enabled. Use the "Save changes" button below the editor to commit modifications to this file.