Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: port forwarding

  1. #1
    Join Date
    Dec 2006
    Location
    in the boonies
    Beans
    Hidden!

    port forwarding

    I have a Ubuntu system that has 2 network cards.

    eth0 with ip address 192.168.1.23

    eth1 with ip address 192.168.7.15

    I would like do port forwarding such that anything for
    192.168.1.23:19320
    is forwarded to
    192.168.7.15:19340
    and it should stay that way after rebooting.

    How do you do this?

  2. #2
    Join Date
    Jan 2006
    Location
    Not heaven... Iowa
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: port forwarding

    iptables comes to mind. ufw/gufw may be another approach to the same thing. (Unfortunately, another area I have yet to learn...)
    Linux User #415691 Ubuntu User #8629
    Iowa Team (LoCo): [Wiki] [Launchpad]
    IRC channel: #ubuntu-us-ia on irc.freenode.net

  3. #3
    Join Date
    Apr 2009
    Location
    Romania
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: port forwarding

    see this

    http://ubuntuforums.org/showthread.php?t=93420


    mybe this will help you
    Brush your teeth kissing is imminent!!!
    sources

  4. #4
    Join Date
    Dec 2006
    Location
    in the boonies
    Beans
    Hidden!

    Re: port forwarding

    Quote Originally Posted by Iowan View Post
    iptables comes to mind. ufw/gufw may be another approach to the same thing. (Unfortunately, another area I have yet to learn...)
    Currently, ufw is not enabled on this Ubuntu system and I want to keep it that way.
    So, is it possible to use gufw so that:
    • The firewall is NOT enabled.
    • But this one port is forwarded.

  5. #5
    Join Date
    Dec 2006
    Location
    in the boonies
    Beans
    Hidden!

    Re: port forwarding

    Quote Originally Posted by stilling View Post
    see this

    http://ubuntuforums.org/showthread.php?t=93420


    mybe this will help you
    I am looking at it.

    While I was waiting for responses to this post, I found:
    http://shahidz.com/iptables-port-forwarding-on-ubuntu/

    Looks more like what I need.
    Right?

  6. #6
    Join Date
    Apr 2009
    Location
    Romania
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: port forwarding

    you can try this i`m not relly sure about it but

    sudo iptables -t nat -A PREROUTING -p tcp -i eth0 -d 192.168.1.23 --dport 19340 -j DNAT --to 192.168.7.15:19340
    sudo iptables -A FORWARD -p tcp -i eth0 -d 192.168.7.15 --dport 19340 -j ACCEPT

    echo 1 > /proc/sys/net/ipv4/ip_forward

    test and if that is ok

    sudo gedit /etc/sysctl.conf
    find net.ipv4.ip_forward = 1 remove the # that is placed in front
    and add the 2 lines with iptables in /etc/rc.local before exit 0


    hope this helps
    Brush your teeth kissing is imminent!!!
    sources

  7. #7
    Join Date
    Dec 2006
    Location
    in the boonies
    Beans
    Hidden!

    Re: port forwarding

    Quote Originally Posted by stilling View Post
    you can try this i`m not relly sure about it but

    sudo iptables -t nat -A PREROUTING -p tcp -i eth0 -d 192.168.1.23 --dport 19340 -j DNAT --to 192.168.7.15:19340
    sudo iptables -A FORWARD -p tcp -i eth0 -d 192.168.7.15 --dport 19340 -j ACCEPT

    echo 1 > /proc/sys/net/ipv4/ip_forward

    test and if that is ok

    sudo gedit /etc/sysctl.conf
    find net.ipv4.ip_forward = 1 remove the # that is placed in front
    and add the 2 lines with iptables in /etc/rc.local before exit 0


    hope this helps
    To confirm - this will ensure that all requests will port forwarded (not just mine), correct?

  8. #8
    Join Date
    Apr 2009
    Location
    Romania
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: port forwarding

    that forwards from eth0 ip to eth1 ip that port
    Brush your teeth kissing is imminent!!!
    sources

  9. #9
    Join Date
    Dec 2006
    Location
    in the boonies
    Beans
    Hidden!

    Re: port forwarding

    I need to do the same thing on another Ubuntu system but instead of eth0 and eth1
    we have eth0 and TUN virtual network device

    Will the same script work?
    (Since your script mentions eth0 but not eth1.)

  10. #10
    Join Date
    Apr 2009
    Location
    Romania
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: port forwarding

    now you know how to do it the problemis that TUN virtual network device must have a name or a ip something like eth1 .... if you understand
    Brush your teeth kissing is imminent!!!
    sources

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

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