微信关注,获取更多

写个shell脚本:Linux下定时重启ipv6

运行环境:Ubuntu-server-22.04 lts.

#!/bin/bash

# Disable IPv6
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1
sudo sysctl -w net.ipv6.conf.lo.disable_ipv6=1

# Wait for a few seconds
sleep 5

# Enable IPv6
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=0
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=0
sudo sysctl -w net.ipv6.conf.lo.disable_ipv6=0

# Show the IPv6 status
cat /proc/sys/net/ipv6/conf/all/disable_ipv6

设置定时运行脚本:

# Edit the cron table
crontab -e

# Add the following line to run the script every day at 1 AM
0 1 * * * /path/to/reset-ipv6-script.sh

根据你的实际需要定时重启ipv6即可。

未经允许不得转载:大神网 » 写个shell脚本:Linux下定时重启ipv6

相关推荐

    暂无内容!