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?

有帮助吗?

解决方案

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"

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top