Question

I have a gateway computer which connects Internet via ADSL and got a virtual interface ppp0. The I establish a pptp vpn through the ADSL and got a virtual interface ppp1.

There are several computers connect to this gateway computer in order to share the Internet and vpn connection.

I want to set some route rules or iptables rule to let the specific requests of specified IP ranges from the internal computers forward to the vpn connection(ppp1) and other requests go directly through the ADSL connection(ppp0).

How should I do?

Was it helpful?

Solution

Hi you could do that by DNAT in iptable on the PREROUTING chain

Below example will redirect http traffic from the range of ips specified ("start-ip" to "end-ip") to the destination ip and port specified(gatewayip:vpnportnumber).

iptables -A PREROUTING -t nat -m iprange --src-range "start-ip"-"end-ip" -i "interface" -p tcp -m tcp --dport 80 -j DNAT --to-destination "gatewayip:vpnportnumber"

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top