sed -i '$a IPADDR=192.168.1.199' /etc/sysconfig/ifcfg-eth0work-scripts/ifcfg-eth0 #追加ip地址。 sed -i '$aNETMASK=255.255.255.0' /etc/sysconfig/ifcfg-eth0work-scripts/ifcfg-eth0 #追加子网掩码 sed -i '$aGATEWAY=192.168.1.1' /etc/sysconfig/ifcfg-eth0work-scripts/ifcfg-eth0 #追加网关 sed -i '$aDNS1=114.114.114.114' /etc/sysconfig/ifcfg-eth0work-scripts/ifcfg-eth0 #追加DNS. sed -i '/BOOTPROTO=/s/dhcp/static/g' /etc/sysconfig/ifcfg-eth0work-scripts/ifcfg-eth0 #修改ip获取方式。 sed -i '/ONBOOT=/s/no/yes/g' /etc/sysconfig/ifcfg-eth0work-scripts/ifcfg-eth0 #开机自启网卡。