diff --git a/Shell-MD/shell脚本案例.md b/Shell-MD/shell脚本案例.md deleted file mode 100644 index d3bf12d..0000000 --- a/Shell-MD/shell脚本案例.md +++ /dev/null @@ -1,50 +0,0 @@ -

shell脚本案例

- -作者:行癫(盗版必究) - ------- - -## 一:脚本案例 - -#### 1.配置静态IP案例 - -```shell -#!/bin/bash -# This script configures a static IP address on CentOS 7 - -# Define variables for the IP address, netmask, gateway, and DNS servers -IP_ADDRESS=192.168.1.100 -NETMASK=255.255.255.0 -GATEWAY=192.168.1.1 -DNS_SERVERS="8.8.8.8 114.114.114.114" - -# Backup the original network configuration file -cp /etc/sysconfig/network-scripts/ifcfg-ens33 /etc/sysconfig/network-scripts/ifcfg-ens33.bak - -# Modify the network configuration file with the static IP address, netmask, gateway, and DNS servers -cat << EOF > /etc/sysconfig/network-scripts/ifcfg-ens33 -TYPE=Ethernet -BOOTPROTO=none -NAME=ens33 -DEVICE=ens33 -ONBOOT=yes -IPADDR=$IP_ADDRESS -NETMASK=$NETMASK -GATEWAY=$GATEWAY -DNS1=${DNS_SERVERS%% *} -DNS2=${DNS_SERVERS##* } -EOF - -# Restart the network service to apply the changes -systemctl restart network - -# Display the new network configuration -ip addr show ens33 -``` - -centos stream 9 - -``` - -``` -