improve doc + timeout for checking ipv6

This commit is contained in:
Emilien Devos 2023-10-14 18:44:28 +02:00
parent 688a7d7ed2
commit 9e88afdf62
2 changed files with 21 additions and 2 deletions

View File

@ -12,6 +12,25 @@
4. Run once the script using `sudo python smart-ipv6-rotator.py run`
5. If everything went well then configure a cron for periodically rotate your IPv6 range. Once per day is enough for YouTube servers.
# How to clean the configuration done by the script
```
sudo python smart-ipv6-rotator.py clean
```
Only works if the script did not crash.
# Why does this need root privileges?
You can only modify the network configuration of your server using root privileges.
The attack surface of this script is very limited as it is not running in the background, it's a one shot script.
# How does this script work?
1. First it check that you have IPv6 connectivity.
2. It automatically find the default IPv6 gateway and automatically generate a random IPv6 address from the IPv6 subnet that you configured.
3. It adds the random IPv6 address to the network interface.
4. It configures route for only using that new random IPv6 address for the specific IPv6 subnets (Google ipv6 ranges by default).
This way you current ipv6 network configuration is untouched.
# TODO
- Allow to configure your IPv6 subnets yourself. (Could be used for other projects)
- Better handle in case of errors in configuring IPv6 routes. Rollback the changes automatically

View File

@ -39,7 +39,7 @@ icanhazip_ipv6_address = "2606:4700::6812:7261"
def check_ipv6_connectivity():
try:
requests.get("http://ipv6.icanhazip.com")
requests.get("http://ipv6.icanhazip.com", timeout=5)
except requests.exceptions.RequestException:
sys.exit("[Error] You do not have IPv6 connectivity. This script can not work.")
@ -143,7 +143,7 @@ elif sys.argv[1] == "run":
sleep(2)
try:
check_new_ipv6_address = requests.get(
f"http://[{icanhazip_ipv6_address}]", headers={"host": "ipv6.icanhazip.com"}
f"http://[{icanhazip_ipv6_address}]", headers={"host": "ipv6.icanhazip.com", timeout=5}
)
response_new_ipv6_address = check_new_ipv6_address.text.strip()
if response_new_ipv6_address == random_ipv6_address: