this post was submitted on 27 Apr 2025
33 points (92.3% liked)

Linux

53684 readers
465 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 5 years ago
MODERATORS
 

Hi all, I'm trying to have my rpi5 running raspberry OS communicate with the Internet only through the tun0 interface (vpn). For this I wanted to create a ufw ruleset. Unfortunately, I've hit a roadblock and I can't figure out where I'm going wrong.

Can you help me discover why this ruleset doesn't allow Internet communication over tun0? When I disable ufw I can access the Internet.

The VPN connection is already established, so it should keep working, right?

I hope you can help me out!

This is the script with the ruleset: sudo ufw reset

Set default policies

sudo ufw default deny incoming

sudo ufw default deny outgoing

Allow SSH access

sudo ufw allow ssh

Allow local network traffic

sudo ufw allow from 192.168.0.0/16

sudo ufw allow out to 192.168.0.0/16

Allow traffic through VPN tunnel

sudo ufw allow in on tun0

sudo ufw allow out on tun0

Add routing between interfaces (I read its necessary, not sure why?)

sudo ufw route allow in on tun0 out on wlan0

sudo ufw route allow in on wlan0 out on tun0

sudo ufw enable

you are viewing a single comment's thread
view the rest of the comments
[–] oshu@lemmy.world 2 points 2 days ago (1 children)

If your concern is ensuring a killswitch type vpn setup, I do that but in a different and simple way.

I have a GLinet microrouter configured to join the vpn and active killswitch mode. This is 2 clicks in the menu. I connect it to my network via its wan port.

Everything I want behind the VPN gets connected to the microrouter lan port and job done.

[–] sykaster 1 points 2 days ago (1 children)

Interesting! I'm new to this, this is really valuable! What made you choose this approach?

[–] oshu@lemmy.world 1 points 2 days ago (1 children)

Its simple and I can easily put a laptop or phone or whatever behind the microrouter and have confidence its only using the vpn.

When I travel I take a second microrouter with me to connect to the hotel wifi. All my devices are set to use the microrouter wifi so they never touch the hotel network, only the vpn. Easy, private, and avoids any filtering the hotek is doing.

[–] sykaster 1 points 2 days ago (1 children)

Cool! And you can easily control the mini router from your devices so that it connects to the hotel WiFi or whatever network you want?

[–] oshu@lemmy.world 1 points 2 days ago* (last edited 1 day ago)

Yes it has a web ui to connect to wifi. For cable you just plug it in.