2

I have been using Ubuntu (Lubuntu Distro) since 16.04 and have always used a VPN + UFW as a killswitch. It's a very simple thing to do. Especially with the GUFW GUI.

First, you simply deny incoming / outgoing connections by default. Then you allow outgoing on tun0 or whatever your OpenVPN adapter is labeled. This is almost ALWAYS tun0.

Since I ugpraded to tun0 the same rules I have used forever no longer work. Nothing is allowed through, even when I specify to allow traffic through on tun0.

Can anyone else confirm that UFW is not working properly in this aspect in 18.04? It seems to be working fine except it's not playing nice with the tun* adapters.

2
  • It still works in general, but did you test any rules with a VPN using the tun0/tun1 adapter?
    – jdubu420
    May 22, 2018 at 18:54
  • Please do not edit your question to add the word "SOLVED". Instead, accept (by clicking the tick) the answer which solved it for you. If you solved it yourself, post your solution as an answer. May 23, 2018 at 23:40

1 Answer 1

2

You need to add this line to your script.

sudo ufw allow out on <wlan or enp0s3 from ifconfig> from any to <VPN IP>

The complete script looks like this

sudo ufw reset 
sudo ufw default deny incoming
sudo ufw default deny outgoing 
sudo ufw allow out on <wlan or enp0s3 from ifconfig> from any to <VPN IP> 
sudo ufw allow out on tun0 from any to any 
sudo ufw enable
2
  • Thank you. I tried adding "sudo ufw allow out on enp0s3 from <ifconfig> from any to <VPN IP>" And it worked. I tried the script previously with my wireless device wlp3s0 and the firewall would still not allow any traffic through. It's very strange that this wasn't necessary to do in either 16.04 or 17.04. Most of the guides online make no mention of this extra rule. Though I did find a few comments that stated you should allow localhost 192.168.1.0/24 to out on enp0s3. Your solution works though! Thank you very much! It's much harder to switch VPN servers, but at least it works!
    – jdubu420
    May 23, 2018 at 14:34
  • @Kurt Fehlhauer, made a post referencing your solution here (see link)... I tried it, but UFW kills 100% of traffic & I don't why. Any tips? askubuntu.com/questions/1303789/openvpn-ufw-overkill
    – nightwatch
    Dec 30, 2020 at 4:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .