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

    Port forwarding... kinda...

    Hey guys,

    A quick explanation of my LAN setup: I have a hardware router ( with two PCs ( = gentoo) and ( = WinXP).

    I have set everything up so that Gentoo/.1.6 is sitting on the DMZ and runs apache/squid/webmin/etc using an iptables firewall.

    WinXP/.1.5 is merely a workstation and essentially has no "knowledge" of the linux box in any way.

    However, now i want to run a daemon on the WinXP/.1.5 box (lets say port 567, but as the hardware router is set up to keep Gentoo/.1.6 on the DMZ i want to use Gentoo/.1.6 to do the port forwarding.

    So how can i make all traffic apearing on port 5678 of the Gentoo/.1.6 box "forward onto" the WinXP/.1.5 box using iptables?

    Thankyou a lot,

  2. #2
    Linux Newbie framp's Avatar
    Join Date
    Jul 2006
    Stuttgart, Germany
    That's an extract from a rule in my FW script for an udp port:

    GW_IP="external_ip / internet IP of gentoo box"
    DPORT="destinationPort on XP (567)"
    IP="destinationIP of XP ("

    iptables -t nat -A PREROUTING -p udp -d $GW_IP --dport $DPORT -j DNAT --to $IP
    iptables -A FORWARD -p udp -i dsl0 -o nic0 -s 0/0 -d $IP --dport $DPORT -j ACCEPT
    iptables -A FORWARD -p udp -i nic0 -o dsl0 -d 0/0 -s $IP --sport $DPORT -j ACCEPT

    You have to change dsl0 (external NIC) and nic0 (internat NIC) to reflect your local config.
    "Really, I'm not out to destroy Microsoft. That will just be a completely unintentional side effect." Linus Benedict Torvalds

Posting Permissions

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