OpenVPN with a specific interface

Viewed 16

I have a Debian VPS with 2 network interfaces and two IP (eth0 and eth1).
I want to keep the first interface for connecting to the VPS, and use the second for OpenVPN in both ways (I can access from the client to internet and internet to the client) I installed OpenVPN and tried that for the routing but it does not work :

FIRST=tun0
SECOND=eth1

# Cleanup
iptables -F
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT

# Route $FIRST to $SECOND
iptables -A FORWARD -i $FIRST -o $SECOND -j ACCEPT
iptables -A FORWARD -i $SECOND -o $FIRST -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -t nat -A POSTROUTING -o $SECOND -j MASQUERADE

# Route $SECOND to $FIRST 
iptables -A FORWARD -i $SECOND -o $FIRST -j ACCEPT
iptables -A FORWARD -i $FIRST -o $SECOND -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -t nat -A POSTROUTING -o $FIRST -j MASQUERADE

Any ideas ? (Sorry for my bad English, I'm French)

0 Answers
Related