sed命令修改ens33配置为静态ip
在shell脚本中使用sed通过设置ip配置文件为固定ip为192.168.1.1 255.255.255.0 192.168.1.254 114.114.114.144 8.8.8.8
sed -e '/BOOTPROTO/s/dhcp/static/' -e '$a\IPADDR=192.168.112.139' -e '$a\NETMASK=255.255.255.0' -e '$a\GATEWAY=192.168.112.1' -e '$a\DNS1=114.114.114.114' -e '$a\DNS2=8.8.8.8' /etc/sysconfig/network-scripts/ifcfg-ens33
运行结果
最后需要重启服务才能生效
service network restart