LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   iptables forward rules for OpenVPN & PPTP (https://www.linuxquestions.org/questions/linux-networking-3/iptables-forward-rules-for-openvpn-and-pptp-4175457144/)

crspy 04-06-2013 12:22 PM

iptables forward rules for OpenVPN & PPTP
 
I have OpenVPN and PPTP installed on a VPS. I'm having a few questions that I can't seem to get a firm answer on.

I want to install OpenVPN on 1.1.1.1 (eth0, public IP address) and PPTP on 1.1.1.2 (eth0:1, public IP address). I was able to achieve this with SNAT. However, from all the tutorials I've been reading it recommends forwarding ppp+ to eth0 and vice versa and the same situation for the tun interface.

iptables -A FORWARD -i tun0 -o eth0 -j ACCEPT
iptables -A FORWARD -i eth0 -o tun0 -j ACCEPT
iptables -A FORWARD -i ppp+ -o eth0 -j ACCEPT
iptables -A FORWARD -i eth0 -o ppp+ -j ACCEPT

My setup is CentOS, dedicated server.

For some reason I'm assuming iptables will route all traffic from eth0 to tun0 and stop at that.

My question is,

1) Will these forward rules conflict with each other?
2) Will I need to forward the ppp+ to eth0:1 instead to avoid confliction? Is it even possible? I haven't figured out a way yet.
3) Is iptables smart enough to route traffic that is specific to tun and ppp through these rules?

MikeDeltaBrown 04-17-2013 07:46 AM

It seems there is confusion as to what iptables does. With the listed commands, you are adding rules to a table that is used when the kernel routing routines determine that a packet is destined for delivery to another device. Using the first rule listed as an example, if a packet arrives on the tun0 device and the kernel routing table has a matching entry that the destin ation IP address can be reached through device eth0, then the packet will be sent on its way.

To answer your questions directly;
1). No
2). Probably not as your default policy is most likely ACCEPT which makes all these rules unnecessary anyway..... but they won't keep this from working.
3). Maybe this is a semantic distinction but iptables doesn't route traffic. It only drops packets, or not, based on the rules you enter.

sag47 04-18-2013 02:12 AM

Quote:

Originally Posted by MikeDeltaBrown (Post 4933136)
3). Maybe this is a semantic distinction but iptables doesn't route traffic. It only drops packets, or not, based on the rules you enter.

This is not correct. iptables does route traffic and routing traffic through a VPN is not something new. A simple google search for "iptables route traffic" will reveal that. iptables can even handle network address translation. You can even get fancy with mangling but I digress.

I'll tackle the OP's problem tomorrow. For now it's my bed time.

@OP for now can you post your iptables config for me to review? Since you're using CentOS your configuration will be located at /etc/sysconfig/iptables. Where are you executing the commands you cite? Is it on the command line or are you running it in a script during start up?

SAM


All times are GMT -5. The time now is 12:48 PM.