I have a VPN connection and I want to make sure that all traffic use this VPN connection. I though of using iptables. ideas somebody? ten x
Asked
Active
Viewed 6,437 times
4
-
1please can you explain in your question why your question is different from this one? http://askubuntu.com/questions/26793/enforce-vpn-connection-to-access-the-internet – fossfreedom Jun 05 '11 at 11:22
-
cause i dont like to use any program for that. – userAgent Jun 05 '11 at 11:30
-
eh? The "program" in the answer is just a GUI front end to iptables. – fossfreedom Jun 05 '11 at 11:33
3 Answers
6
By running this script at startup i solved the problem explained in your post
# Delete all existing rules
iptables -F
# Allow from local network
iptables -A OUTPUT -d 192.168.2.0/24 -j ACCEPT
iptables -A OUTPUT -s 192.168.2.0/24 -j ACCEPT
# Allow OpenVPN
iptables -A OUTPUT -p udp --dport 1194 -j ACCEPT
# Deny eth0
iptables -A OUTPUT -o eth0 -j DROP
1
The best method is a hardware method.
Read this article: en.wikipedia.org: Network tap.
You can plug in the second machine 2 ethernet cards.
.----.
.---------. | == |
|.-"""""-.| |----|
|| || | == |
|| || |----|
|'-.....-'| |::::|
`"")---(""` |___.|--------. /
/:::::::::::\" _ " \ /
/:::=======:::\`\`\ | /
`"""""""""""""` '-' | \ + /
Your Personal Computer / \_________+_____/
/ + /\________+____/\ \
/ +/ /\_______+___/\ \ \ +
____/ /+/+/\______+__/\ \ \ +
.----. / / / /+/\_____+_/\ \ \+\ \
| == |/ / / /+/ \ \ + \ \ \
|----| / / / / \+\_\_\_\_\_____
| == |----------------------E | InterNet |_|_|_|_|_|_______
|----| \ \ \+\ / / / / / | | |
|::::| \ \ \+\ \_______/+/ / / / / / /
|___.| \ \+\ \/+______\/ + / / / / /
" " + \ /_+_______\/ / + / / /
Your Tap Router + \ \/__+________\/ / +/ /
+ \ \/___+_________\/ / / /+
\/____+_______+__\/ / /
/ +___________\/ /
__________\/
______\
___\
\
And sniff everything what's going on.

innocent-world
- 586
- 1
- 4
- 11
1
You should set up a "default route" to send your TCP/IP traffic through the VPN. man route
, netstat -rn
. See also To allocate data usage efficiently with two internet connections

waltinator
- 36,399