Find the answer to your Linux question:
Results 1 to 4 of 4
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Port-forwarding with iptables problem

    Hi all,

    I have a setup like the one shown below and I want to forward HTTP requests from my gateway to my internal HTTP server (and also to forward UDP packets with destination port 4321 to another internal machine -

    Internet -------------- wan (EXT_IP) GATEWAY ( lan -------------------- ( HTTP sever

    Well, this is how I am using iptables:

    iptables -t nat -A POSTROUTING -j MASQUERADE -o wan
    iptables -t nat -A PREROUTING -p udp -i wan --dport 4321 -j DNAT --to
    iptables -t nat -A PREROUTING -p tcp -i wan --dport 80 -j DNAT --to
    Using this configuration, the udp packets to port 4321 are forwarded correctly to the internal address However, when I try to access the WEB server from outside I cannot get the WEB pages.

    Is there something wrong? Am I missing any rule?

    Thanks in advance,


  2. #2
    1) is your FORWARD chain set to ACCEPT, or at least ACCEPT forward from (try to initialise your chain at the beginning of the script, i.e. DROP all or ACCEPT all if no other matched rules, and --flush all related chain as well as POSTROUTING and PREROUTING)

    2) is's gateway set properly? i.e. to your firewall

    3) very unlikely, but try to add the port number to your ip address i.e.:

    4) your's httpd isn't running :P

  3. #3
    Thanks for your answer.
    I found the (stupid reason... and it corresponds with point number 2:

    2) is's gateway set properly? i.e. to your firewall

    The routes.conf of the gateway was wrong!



  4. $spacer_open
  5. #4
    hehe, sometimes i do missed out some minor details as well

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts