删除 'Shell-MD/shell脚本案例.md'
This commit is contained in:
parent
0d5c40204d
commit
32c7ac5957
|
@ -1,50 +0,0 @@
|
||||||
<h1><center>shell脚本案例</center></h1>
|
|
||||||
|
|
||||||
作者:行癫(盗版必究)
|
|
||||||
|
|
||||||
------
|
|
||||||
|
|
||||||
## 一:脚本案例
|
|
||||||
|
|
||||||
#### 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
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
Loading…
Reference in New Issue