天天看点

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

"bootproto=static">>$ip_path

echo "ipaddr=$ip">>$ip_path

"netmask=255.255.255.0">>$ip_path

"gateway=$gateway">>$ip_path

"onboot=yes">>$ip_path

/etc/init.d/network restart

继续阅读