Skip to content

Commit 2a73d00

Browse files
outis151unixfox
andauthored
Add simple ipv6 rotation (#668)
* Create ipv6-rotation-simple.md * Add ipv6-rotation-simple * Update title for IPv6 rotation documentation --------- Co-authored-by: Émilien (perso) <[email protected]>
1 parent 6d4282c commit 2a73d00

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

docs/ipv6-rotation-simple.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Simple IPv6 rotation for avoid YouTube blocking (SLAAC)
2+
3+
## Requirements
4+
- A host with IPv6 support providing a ``/64`` IPv6 prefix. (If your server provider provides smaller prefix lengths such as ``/128`` it is not sufficient for rotation)
5+
- Docker with IPv6 networking enabled so that invidious can access the internet via IPv6
6+
7+
## Setup
8+
### If the IPv6 address on your host is dynamically configured via Stateless Address Autoconfiguration (SLAAC)
9+
Add the following to ``/etc/network/interfaces`` or equivalent configuration.
10+
11+
Note: The configuration syntax shown assumes use of ifupdown (/etc/network/interfaces). On systems using Netplan, systemd-networkd, or NetworkManager, IPv6 privacy extensions must be enabled via their respective configuration formats.
12+
13+
This will enable the IPv6 privacy extensions which will allow the kernel to automatically generate new random IPv6 addresses which are temporary and stay assigned for the specified lifetime.
14+
```
15+
iface eth0 inet6 auto
16+
privext 2
17+
pre-up echo 2 > /proc/sys/net/ipv6/conf/eth0/use_tempaddr
18+
pre-up echo 3600 > /proc/sys/net/ipv6/conf/eth0/temp_valid_lft
19+
pre-up echo 1800 > /proc/sys/net/ipv6/conf/eth0/temp_prefered_lft
20+
```
21+
In this case the prefered lifetime is set to 30 minutes and the valid lifetime to 1 hour. Every 30 minutes a new temporary address will be assigned by the kernel.
22+
The old address will be kept for 30 minutes longer (valid lifetime) for any remaining connections using it.
23+
24+
25+
### If your IPv6 configuration is static
26+
27+
Run the below script every 30 minutes via a cronjob as root
28+
29+
``/usr/local/bin/ipv6-rotate.sh``
30+
```
31+
#!/bin/bash
32+
# Set your network prefix (first 64 bits)
33+
PREFIX="2001:db8:1234:5678"
34+
INTERFACE="eth0"
35+
36+
# Generate random interface ID (last 64 bits)
37+
INTERFACE_ID=$(printf "%04x:%04x:%04x:%04x" $((RANDOM % 65536)) $((RANDOM % 65536)) $((RANDOM % 65536)) $((RANDOM % 65536)))
38+
39+
#Enable prefering temporary addresses
40+
echo 2 > /proc/sys/net/ipv6/conf/"$INTERFACE"/use_tempaddr
41+
42+
# Add the IPv6 address
43+
ip -6 addr add "${PREFIX}":"${INTERFACE_ID}"/64 dev "$INTERFACE" valid_lft 3600 preferred_lft 1860
44+
```
45+
Replace the ``PREFIX`` and ``INTERFACE`` variables according to your setup. Note that if your IPv6 address is ``2001:db8:1234:5678::1``, the correct prefix is ``2001:db8:1234:5678``.
46+
47+
#### In the crontab:
48+
```
49+
*/30 * * * * /usr/local/bin/ipv6-rotate.sh
50+
```
51+
Don't forget to make it executable: ``chmod +x /usr/local/bin/ipv6-rotate.sh``
52+
53+

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ nav:
3838
- 'takedown.md'
3939
- 'hide-instance-behind-proxy-server.md'
4040
- 'ipv6-rotator.md'
41+
- 'ipv6-rotation-simple.md'
4142
- 'improve-public-instance.md'
4243
- 'For Developers':
4344
- 'api.md'

0 commit comments

Comments
 (0)