I currently have a NAS box running under port 80. To access the NAS from the outside, I mapped the port 8080 to port 80 on the NAS as follow:
iptables -t nat -A PREROUTING -p tcp --dport 8080 -j DNAT --to-destination 10.32.25.2:80
This is working like a charm. However, this is working only if I am accessing the website from the outside of the network (at work, at diffrent house, etc). So when I type in mywebsite.com:8080
, IPTables do the job correctly and everything is working fine.
Now, the problem I have is, how can I redirect this port from the inside of the network ? My domain name mywebsite.com
point to my router (my linux server) from the inside (10.32.25.1) but I want to redirect port 8080 to port 80 on 10.32.25.2 from the inside.
Any clue?
Edit #1
Attempting to help facilitate this question I put this diagram together. Please feel free to update if it's incorrect or misrepresenting what you're looking for.
iptables
| .---------------.
.-,( ),-. v port 80 |
.-( )-. port 8080________ | |
( internet )------------>[_...__...°]------------->| NAS |
'-( ).-' 10.32.25.2 ^ 10.32.25.1 | |
'-.( ).-' | | |
| '---------------'
|
|
__ _
[__]|=|
/::/|_|
10.32.25.1:8080
redirect to10.32.25.2:80
. My rule above is working from the outside, but not from the inside of my network. So if I am at the office, I can access my NAS from website.com:8080 and it's completly transparent. From my home, website.com:8080 point to 10.32.25.1 because it's my router aka Linux server. I want to redirect the port 8080 to the NAS also on port 80 but again, in a transparent way.eth0 10.32.25.2
, so that we can able to write iptables use based on inbound interface