以下操作在cent os上进行
1.在系统中创建set-ip-tool命令要求如下
当在系统中执行set-ip-tool 172.25.254.X 后
*)会自动显示ifconfig命令的输出
*)系统ip被设定为:172.25.254.X
*)系统网关被设定为:172.25.254.250
*)系统dns被设定为:172.25.254.250
最后结果为
set-ip-tool.sh的代码为
#!/bin/bash
echo "set ip as $1"
nmcli connection modify System\ eth0 ipv4.addresses $1>/dev/null
echo "set gateway 172.25.254.250"
route add default gw 172.25.254.250 &>/dev/null
echo "set dns 172.25.254.250"
nmcli connection modify System\ etho ipv4.dns 172.25.254.250 &>/dev/null
systemctl restart network &>/dev/null
ifconfig
本文介绍了一个用于CentOS系统的简单脚本set-ip-tool.sh,该脚本可以快速设置系统的IP地址、网关及DNS服务器。执行命令set-ip-tool 172.25.254.X后,系统将自动完成上述配置,并重启网络服务。
492

被折叠的 条评论
为什么被折叠?



