Monday, February 16, 2026

Minimal script to limit traffic to vpn tunnel using ufw

Having ufw installed, execute the following script with sudo: 

 

ufw --force reset

ufw default deny outgoing
ufw default deny incoming

ufw allow out on tun0 from any to any
# for seeding
ufw allow in on tun0 from any to any


# vpn server ip
#ufw allow out from any to 123.123.123.123
#ufw allow out from any to 123.123.123.0/24
#ufw allow out 1198/udp
#ufw allow in 1198/udp
ufw allow out 1194/udp
ufw allow in 1194/udp

ufw enable
ufw status verbose

No comments: