写个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即可。

给TA打赏
共{{data.count}}人
人已打赏
站长笔记

普通用户和AIGC

2023-2-8 0:46:23

站长笔记

讲讲什么是ChatGPT

2023-2-11 7:58:20

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索