Okay, it seems I've found the solution.
Check what routes are set up:
$ ìp route show
which in my example gives this result:
default via 192.168.0.1 dev enp0s31f6 proto dhcp metric 100
default via 192.168.200.68 dev wlp4s0 proto dhcp metric 600
169.254.0.0/16 dev enp0s31f6 scope link metric 1000
192.168.0.0/24 dev enp0s31f6 proto kernel scope link src 192.168.0.151 metric 100
192.168.200.0/24 dev wlp4s0 proto kernel scope link src 192.168.200.78 metric 600
The first two lines here show the default gateways of my ethernet (enp0s31f6) and wifi (wlp4s0) respectively.
Now to find the IPs of the domains where I always get banned, I use the dig
command as follows:
$ dig +short a discord.com
162.159.137.232
162.159.135.232
162.159.128.233
162.159.136.232
162.159.138.232
$ dig +short a discord.gg
162.159.136.234
162.159.135.234
162.159.133.234
162.159.134.234
162.159.130.234
Then add a route for each of these destination IPs over the Wifi interface (using the Wifi interface's default gateway that we got from the first command):
sudo route add -host 162.159.137.232 gw 192.168.200.68
etc.
To do this all automatically whenever the wifi connects, if you're using NetworkManager, you can add a script to the /etc/NetworkManager/dispatcher.d
directory. For example:
sudo nano /etc/NetworkManager/dispatcher.d/10-bloody-routes
The 10-
here at the start of the file name denotes the priority. Scripts in the dispatcher.d
directory are run in lexicographical order on network events (interface connected, disconnected, etc.)
I enterd this bash script here to automate the above-mentioned process:
#!/bin/bash
if [ "$1" == "wlp4s0" ] && [ "$2" == "up" ]; then
gateway=`ip route | awk '/default/ { print $3 " " $5 }' | awk '/wlp4s0/ { print $1 }'`;
echo "What's up, $gateway: "`date` >> /home/trollkotze/smackmybitch.up;
echo discord.com >> /home/trollkotze/smackmybitch.up;
for x in `dig +short a discord.com`; do
echo route add -host $x gw $gateway >> /home/trollkotze/smackmybitch.up;
route add -host $x gw $gateway >> /home/trollkotze/smackmybitch.up;
done;
echo discord.gg >> /home/trollkotze/smackmybitch.up;
for x in `dig +short a discord.gg`; do
echo route add -host $x gw $gateway >> /home/trollkotze/smackmybitch.up;
route add -host $x gw $gateway >> /home/trollkotze/smackmybitch.up;
done;
fi;
As you can see from the script, the first and second argument are the interface name (in my case I'm looking for wlp4s0
) and the event (I'm looking for the up
event when the interface goes online).
I added some logging to a file in my home directory here to verify that all is working.
Whenever I connect my wifi now this script is run and adds the appropriate routes to Discord over the wifi's default gateway.