Created
December 9, 2024 02:37
-
-
Save Jxck-S/8a069fb37a08f6c501bc90721e9be49f to your computer and use it in GitHub Desktop.
IPv6 Toggle Script, Disables or enables IPv6 system-wide
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# IPv6 Toggle Script | |
# Disables or enables IPv6 system-wide | |
function disable_ipv6() { | |
echo "Disabling 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 | |
echo "net.ipv6.conf.all.disable_ipv6=1" | sudo tee -a /etc/sysctl.conf > /dev/null | |
echo "net.ipv6.conf.default.disable_ipv6=1" | sudo tee -a /etc/sysctl.conf > /dev/null | |
echo "net.ipv6.conf.lo.disable_ipv6=1" | sudo tee -a /etc/sysctl.conf > /dev/null | |
sudo sysctl -p | |
echo "IPv6 has been disabled." | |
} | |
function enable_ipv6() { | |
echo "Enabling 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 | |
sudo sed -i '/net.ipv6.conf.*.disable_ipv6/d' /etc/sysctl.conf | |
sudo sysctl -p | |
echo "IPv6 has been enabled." | |
} | |
# Main Script Execution | |
echo "Do you want to enable or disable IPv6? (enable/disable)" | |
read -r action | |
case "$action" in | |
disable) | |
disable_ipv6 | |
;; | |
enable) | |
enable_ipv6 | |
;; | |
*) | |
echo "Invalid option. Please type 'enable' or 'disable'." | |
exit 1 | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment