首页 > 代码库 > Linux自动修改IP脚本(手动编写)

Linux自动修改IP脚本(手动编写)

#!/bin/bash
netmask=255.255.255.0
IP_PATH=/etc/sysconfig/network-scripts/ifcfg-eth0
GM_PATH=/etc/sysconfig/network
echo -e "Please input IP(FORMAT:192.168.46.88):\c"
read ip
echo -e "Please input GateWay(FORMAT:192.168.46.1):\c"
read gateway
#change ipaddress
echo "DEVICE=eth0">$IP_PATH
echo "BOOTPROTO=static">>$IP_PATH
echo "IPADDR=$ip">>$IP_PATH
echo "NETMASK=255.255.255.0">>$IP_PATH
echo "GATEWAY=$gateway">>$IP_PATH
echo "ONBOOT=yes">>$IP_PATH
/etc/init.d/network restart