auto to change IP address script
2012-05-16 15:04
316 查看
#!/bin/bash
read -p "network driver ( eth0 | eth1 ) :" network
echo -n "It's checking"
/sbin/ifdown "$network"
/sbin/ifup "$network"
for i in `seq 6`
do
echo -en "."
sleep 1
done
echo
eth="/etc/sysconfig/network-scripts/ifcfg-$network"
driver=`ifconfig eth0 |grep 'UP'| awk '{print $1}'`
if [ "$driver" = "UP" -a "$network" = eth0 ]; then
echo "you can setup netowrk ( eth0 )"
echo
echo "**********your $network link is ok**********"
elif [ "$driver" = "UP" -a "$network" = eth1 ]; then
echo "**************you can setup network ( eth1 )**********"
echo
echo "***********your $network link is ok********"
else echo "your network have problem or you must input right information,please check !!!!!!!!!!!!!!!!!!!!!!!!!!!"
exit 1
fi
path="/etc/sysconfig/network-scripts/ifcfg-$network"
cat "$path" > /root/ifcfg-$network
read -p "please input ( dhcp | static ) :" te
echo "ONBOOT=yes" > $path
echo "TYPE=Ethernet" >> $path
echo "DEVICE=eth0" >> $path
if [ $te = "dhcp" ]; then
echo "BOOTPROTO=$te" >> $path
/etc/init.d/network restart
elif [ "$te" = "static" ]; then
read -p "please input ip address:" ip
echo "IPADDR=$ip" >> $path
read -p "please input netmask : " netmask
echo "NETMASK=$netmask" >> $path
echo "setup done"
echo "************will be restart netowrk********************"
/etc/init.d/network restart
else
echo "you must be input again (dhcp | static )!!!!!!!!!!!!!!!!!!!!!!!11"
sh $0
fi
本文出自 “tony” 博客,请务必保留此出处http://tonyzeng.blog.51cto.com/406650/864886
read -p "network driver ( eth0 | eth1 ) :" network
echo -n "It's checking"
/sbin/ifdown "$network"
/sbin/ifup "$network"
for i in `seq 6`
do
echo -en "."
sleep 1
done
echo
eth="/etc/sysconfig/network-scripts/ifcfg-$network"
driver=`ifconfig eth0 |grep 'UP'| awk '{print $1}'`
if [ "$driver" = "UP" -a "$network" = eth0 ]; then
echo "you can setup netowrk ( eth0 )"
echo
echo "**********your $network link is ok**********"
elif [ "$driver" = "UP" -a "$network" = eth1 ]; then
echo "**************you can setup network ( eth1 )**********"
echo
echo "***********your $network link is ok********"
else echo "your network have problem or you must input right information,please check !!!!!!!!!!!!!!!!!!!!!!!!!!!"
exit 1
fi
path="/etc/sysconfig/network-scripts/ifcfg-$network"
cat "$path" > /root/ifcfg-$network
read -p "please input ( dhcp | static ) :" te
echo "ONBOOT=yes" > $path
echo "TYPE=Ethernet" >> $path
echo "DEVICE=eth0" >> $path
if [ $te = "dhcp" ]; then
echo "BOOTPROTO=$te" >> $path
/etc/init.d/network restart
elif [ "$te" = "static" ]; then
read -p "please input ip address:" ip
echo "IPADDR=$ip" >> $path
read -p "please input netmask : " netmask
echo "NETMASK=$netmask" >> $path
echo "setup done"
echo "************will be restart netowrk********************"
/etc/init.d/network restart
else
echo "you must be input again (dhcp | static )!!!!!!!!!!!!!!!!!!!!!!!11"
sh $0
fi
本文出自 “tony” 博客,请务必保留此出处http://tonyzeng.blog.51cto.com/406650/864886
相关文章推荐
- How to change CentOS IP address on a cloned VM
- Change Ubuntu Server from DHCP to a Static IP Address
- How to change IP address of your ESX Server
- Auto setup ip address
- Script to change gateway by command
- git fatal: unable to auto-detect email address
- How to get local machine name and IP address?
- How to check ip address in linux
- [error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln222] Failed to get master_ip_failover_script
- SQL server Management Studio Express auto generate change script
- change the DHCP address to static address at home
- retrive ip address list change event by EventSelect and Overlapped
- auto-summary and ip summary-address rip comparison
- Java – Convert IP address to Decimal Number
- Warning: Permanently added the RSA host key for IP address '192.30.255.112' to the list of known hos
- Passing address of non-local object to __autoreleasing parameter for write-back
- Permanently added the RSA host key for IP address '192.30.252.130' to the list of known hosts.
- Assign an Elastic IP Address to Your Instance
- How to Find Your IP Address in Ubuntu Linux