1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

HOw do I Port Forward when using Linux ???

Discussion in 'Linux - General discussion' started by Patmann66, Jan 31, 2006.

  1. Patmann66

    Patmann66 Member

    Joined:
    Jan 31, 2006
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    11
    I was just wondering how to port forward using Linux as a router.. I'm trying to use Azureus and I keep on getting a NAT Error .. so if anyone can help me with this it would be greatly appreciated.
     
  2. ddp

    ddp Moderator Staff Member

    Joined:
    Oct 15, 2004
    Messages:
    39,167
    Likes Received:
    136
    Trophy Points:
    143
  3. Daniel_G

    Daniel_G Guest

    Some more info would be handy...
    What Linux distribution are you using?
    What application are you using to do manage your connection?
    How experienced are you in using linux?
     
  4. Spiney4

    Spiney4 Member

    Joined:
    Jan 31, 2006
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    11
    I have a Linux machine acting as a router for me, using iptables. Coincidentally, I started using Azureus last week. To pass the Azureus required port 6881 from my Linux router to my Linux desktop (192.168.0.2) I used the following bash script:

    #!/bin/sh

    export ETH=`ifconfig eth0 | awk '{print $2}' | grep addr | cut -b 6-`
    export PORT="6881"

    for j in ${PORT}
    do
    iptables -t nat -I POSTROUTING -s 192.168.0.2 -p udp \
    --dport $j -j SNAT --to-source ${ETH}:$j
    iptables -t nat -I POSTROUTING -s 192.168.0.2 -p udp \
    --sport $j -j SNAT --to-source ${ETH}:$j

    iptables -t nat -I PREROUTING -p udp -d ${ETH} --dport $j \
    -j DNAT --to-destination 192.168.0.2

    iptables -t nat -I POSTROUTING -s 192.168.0.2 -p tcp \
    --dport $j -j SNAT --to-source ${ETH}:$j
    iptables -t nat -I POSTROUTING -s 192.168.0.2 -p tcp \
    --sport $j -j SNAT --to-source ${ETH}:$j

    iptables -t nat -I PREROUTING -p tcp -d ${ETH} --dport $j \
    -j DNAT --to-destination 192.168.0.2
    done

    To tell the truth, I'm not 100% the UDP port needs to be passed, but I thought I read that when Azureus first reported NAT problems.

    I hope that helps.
     
  5. Patmann66

    Patmann66 Member

    Joined:
    Jan 31, 2006
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    11
    ya thnx man It helped a lot I tried It and It worked.. Thnx man :pP:p
     

Share This Page