#!/bin/bash
#配置ip地址参数脚本
NET=/etc/sysconfig/network-scripts/ifcfg-ens33
if grep -E "BOOTPROTO=dhcp" $NET
then read -p "请输入ip地址:" ip1
read -p "请输入netmask:" net1
sed "1a$ip1" $NET
sed "2a$net1" $NET
systemctl restart network
elif grep -E "BOOTPROTO=static" $NET
then
read -p "请输入ip地址:" ip2
read -p "请输入netmask:" net2
sed -i "s/IPADDR=.*/IPADDR=$ip2/g" $NET
sed -i "s/NETMASK=.*/NETMASK=$net2/g" $NET
echo "正在配置你所输入的IP地址,请耐心等待,一会就可以登录了亲(づ ̄3 ̄)づ╭~"
systemctl restart network fi