您的位置:首页 > 运维架构 > Shell

自己用shell+shell脚本自动修改IP信息

2012-02-24 13:07 731 查看
#!/bin/bash

#
echo 系统时间是:`date -d '-1 month' +%Y-%m-%d`
echo 查看当前系统版本:`cat /etc/issue`
echo 查看版本内核:`uname -r`
echo 当前登录用户的UID:$UID
echo 当前登录用户的名称:$LOGNAME
echo 查看服务器CPU:`cat /proc/cpuinfo | grep -c processor`

echo "########################################################################"
echo 关闭iptables
/sbin/chkconfig iptables off
/sbin/chkconfig ip6tables off
/sbin/service iptables stop
/sbin/service ip6tables stop
/sbin/service iptables status
sed -i '/SELINUX=enforcing/s/SELINUX=enforcing/SELINUX=disabled/' /etc/sysconfig/selinux
/usr/sbin/setenforce 0
echo 查看SELINUX运行状态:`/usr/sbin/getenforce`
echo "########################################################################"

echo 本机IP地址
ifconfig $1|sed -n 2p|awk '{ print $2 }'|awk -F : '{ print $2 }'
echo 更换IP地址
echo -n "Continue?(Y/N)"
read ANSWER

case $ANSWER in

[Yy])
echo " you input is y or Y !"
sh ip.sh
;;
[Nn])
echo " Please continue to implement "$ANSWER
;;
esac
echo "########################################################################"
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息