以下是一个简单的逃生脚本,用于在更改 Debian 11 的 IP 地址时出现错误时恢复默认设置:

#!/bin/bash

# Default network interface and IP address
interface="eth0"
ip_address="192.168.1.10"

# Revert to default settings
ifconfig $interface down
ifconfig $interface $ip_address
ifconfig $interface up

# Restart networking service
systemctl restart networking.service

echo "IP address reverted to default: $ip_address"

将此脚本保存为 revert_ip.sh,然后执行以下命令以使其可执行:

chmod +x revert_ip.sh

如果更改 IP 地址时出现错误,只需运行此脚本即可恢复默认设置。请注意,此脚本假定默认 IP 地址为 192.168.1.10,您需要根据自己的网络设置进行更改

请给一个debian11 改ip失败后的逃生脚本

原文地址: https://www.cveoy.top/t/topic/dh9F 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录