-1

My Tomato based router has two interfaces Eth0 - direct connection Tun1 - vpn

Sometimes some websites return "HTTP/1.1 302 Found" and when that happens, I want to add iptables rule to use Tun1 instead of Eth0 for that particular IP.

I can not figure out how to catch "HTTP/1.1 302 Found" response on router and how to use it as a trigger for IPTABLES rule. Should i have tcpdump 24\7 or there are better ways? Any input will be really appreciated. Thanks.

1
  • Why do you want to do this, aka what are you trying to accomplish? Apr 29, 2018 at 12:31

1 Answer 1

0

I doubt there is anything ready to implement this kind of behaviour.

In order to accomplish this, you need to consider the following points:

  1. This is only possible with HTTP connections, as it requires being able to read the plain-text version of data. In HTTPS the data is encrypted.
  2. One needs to have a mechanism which reads the traffic and implements HTTP protocol parsing and finds out destination from the Location HTTP header.
  3. One needs to parse the URL to extract the domain from Location header, and then perform an IP address lookup for that domain.
  4. One needs to add the IPTables NAT rule for IP address found in step 3 to the kernel's firewall tables.

In conclusion, this would need many different components to implement the feature, and I don't think no-one has implemented it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .