Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have router works like this

internet -> 1.2.3.4 eth1 -> Router <- eth0 10.0.0.1 - LAN

and want to port forward port 80 from 1.2.3.4 to 10.0.0.10

-A FORWARD -d 10.0.0.10 -p tcp -m tcp --dport 80 -j ACCEPT
-A PREROUTING -d 1.2.3.4 -p tcp -m tcp --dport 80 -j DNAT --to-destination 10.0.0.10:80

this works perfectly from interntet, but not from LAN network ex.IP 10.0.0.2 how can i achieve that? (i dont want to use DNS for that)

P.S.: i need to access 1.2.3.4:80 from both networks

share|improve this question

1 Answer 1

up vote 2 down vote accepted

You need to make sure all traffic runs back through your router (so it can rewrite it).

A POSTROUTING rule can achieve this. (see: http://www.netfilter.org/documentation/HOWTO/NAT-HOWTO-10.html)

$ iptables -t nat -A POSTROUTING -d 10.0.0.10 -s 10.0.0.0/24 \
    -p tcp --dport 80 -j SNAT --to 10.0.0.1`
share|improve this answer
    
thx it works perfectly –  xinu Jul 11 '12 at 13:14
    
Heel erg bedankt, je bent de beste! –  user127928 Jul 11 '12 at 13:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.