Current status: OpenVPN is up and runnning, ifconfig shows eth0, lo, tun0.
To be achieved: Temporarily blocking all traffic via calling a bash script except all traffic in home network and all traffic over VPN. And a second script, that restores the RaspBMC defaults (without reboot).
After some research, I believe this could be achieved with IPTables. Please advice, if this is not the way to go.
Now the details - for the sake of completeness (and maybe to catch some mistakes I might have made) the OpenVPN configuration file and the output on the Terminal after start:
OpenVPN is on tun, udp, port 53.
Output of ifconfig -s:
Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg eth0 1500 0 3103 0 0 0 1949 0 0 0 BMRU lo 65536 0 8 0 0 0 8 0 0 0 LRU tun0 1500 0 11 0 0 0 11 0 0 0 MOPRU
Output of iptables -L (these should be default RaspBMC as I did not change anything)
Chain INPUT (policy ACCEPT) target prot opt source destination ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED ACCEPT all -- 10.0.1.0/24 anywhere DROP all -- anywhere anywhere Chain FORWARD (policy ACCEPT) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source destination
Finally, I am overwhelmed with iptables-configuration, even after hours of reading. And I am worried about overlooking something which keeps me running without VPN.
What I really want to achieve: if I start my bash script "safe on", I want that only local traffic and traffic via VPN is allowed. If VPN disconnects, all programms should loose their connection just as if the internet connection itself would be offline (and ideally resume, when VPN comes online again). And with "safe off" I want to return to the default settings with all possibilities (with or without connected VPN). Ideally, local access should be always allowed.
I would deeply appreciate any tips!