I am using raspberry as an OpenVPN client to connect to other networks. My routing table on that machine is:
root@raspberrypi:~# ip route list
default via 192.168.1.1 dev eth0 metric 202
10.1.0.0/24 via 10.1.0.1 dev tun0
10.1.0.1 dev tun0 proto kernel scope link src 10.1.0.30
10.10.10.0/24 via 10.1.0.1 dev tun0
192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.101 metric 202
192.168.88.0/24 via 10.1.0.1 dev tun0
Everything works fine, but I would like raspberry to access the internet ONLY through VPN, but in the same time I still want it to be accessible from LAN (192.168.1.0/24). I don't want to use "redirect-gateway def1" in config, as it "disappears from LAN". How can I achieve that?
ufw
(based on iptables)?ufw
is simply a front-end toiptables
. I use it to block all outgoing traffic that doesn't go through a VPN (tun0) unless is comes or goes to my local network. It's not too complicated to setup (ufw
is an abbreviation of "uncomplicated firewall" for a reason).