4

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

  • 1
    please can you explain in your question why your question is different from this one? askubuntu.com/questions/26793/… – fossfreedom Jun 5 '11 at 11:22
  • cause i dont like to use any program for that. – userAgent Jun 5 '11 at 11:30
  • eh? The "program" in the answer is just a GUI front end to iptables. – fossfreedom Jun 5 '11 at 11:33
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

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

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.

  • 2
    dat graphics. respect. – Tamás Barta Jul 14 '15 at 8:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.