Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

share|improve this question
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

3 Answers 3

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
share|improve this answer

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

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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