Dynamic Page Background Color by Encoding RGB into IPv6 Addresses

Current page color is loading...

As you have probably noticed by the title, and the likely jarring background color, this page’s background is controlled by the users. Not through an obvious interface either, it is controlled by encoding hexadecimal RGB colors into an IPv6 address. I have a server listening for HTTP requests to port 80 on the IPv6 subnet 2001:470:8d76:bbbb::/80, where the last 3 hextets encode the RGB color. For instance a HTTP request to 2001:470:8d76:bbbb::ff:0:0 would make the background of this page full red. The page is updated every second to match the new background color.

hammy /data : curl http://\[2001:470:8d76:bbbb::ca:ca:ca\]:80
Setting to color #cacaca

If the current background is a horrible color, do us all a favour and run curl http://\[2001:470:8d76:bbbb::cc:fb:fb\]:80 changing the last 3 hex numbers to be something else good-looking. Alternatively just go to the following link, http://[2001:470:8d76:bbbb:0:cc:fb:fb]/. If it says you can not connect it is because you likely do not have IPv6 support, check that at https://ipv6-test.com/.

How

This was actually pretty simple to pull off. I setup an ip6tables rule to route everything to the 2001:470:8d76:bbbb::/80 subnet to a local port, because listening on the entire /80 would be insane.

ip6tables -t nat -A PREROUTING -d 2001:470:8d76:bbbb::/80 -i eth0 -p tcp --dport 80 -j REDIRECT --to-ports 6969

Then on that port I have an express app running, this app recieves the request, checks /proc/net/nf_conntrack to get the IP that this request was originally for and parses out the color from the IP. The conntrack searching is done by matching the source IP and the source port, I wanted to use the socket’s SO_ORIGINAL_DST option, but could not figure out a way to access it from NodeJS. That new color is then written to disk, with this page making a HTTP request for that file every second and updating the background color accordingly.

You might also notice all those IPs are pingable, that is from testing when I setup the following rule and just do not feel like removing it.

ip6tables -t nat -A PREROUTING -d 2001:470:8d76:bbbb::/80 -i eth0 -p ipv6-icmp -j REDIRECT