Search code examples
linuxiptablesforwardtraffic

IPtables all traffic forwarded to one specific IP


I need to redirect all traffic to one specific ip (in this case a index.html) wIth iptables

let me make it clear: I've a router with tomcat7 on it, with an logon page. (index.html) with the following url i can get to the log on page(Index.html) ip/URL: 192.168.137.111:8080

wlan ip:(Access point) 192.168.0.1
eth0 ip: 192.168.137.1

i've already checked other questions that has been asked, but i could not fix it. I got the following code i'm trying to use. Im not sure if it works.

iptables -t nat -A PREROUTING -d 192.168.0.1 -p tcp -m tcp --dport 80 -j DNAT --to-destination 192.168.137.111:8080

what am i doing wrong?

Is it possible to get a rule with iptables that redirects / forwards all traffic to the index.html(192.168.137.111:8080)?

Thanks in advance


Solution

  • Your firewall rule says that only TCP traffic to 192.168.0.1:80 is redirected to 192.168.137.111:8080.

    Try:
    iptables -t nat -A PREROUTING -p tcp -m tcp --dport 80 -j DNAT --to-destination 192.168.137.111:8080

    I only removed -d 192.168.0.1 so it catches all TCP connections on port 80.