Results 1 to 3 of 3

Thread: Simple port forward with iptables...

  1. #1
    Join Date
    Feb 2005
    Location
    Windsor, California
    Beans
    292
    Distro
    Ubuntu 7.10 Gutsy Gibbon

    Simple port forward with iptables...

    I'd like to forward udp packets with port 4569 from my gateway ubuntu server (PUBLICIP) to my asterisk server inside (LOCALIP).

    Here are the rules I've done:

    Code:
    $IPT -t nat -A PREROUTING -p udp --dport 4569 -j DNAT --to LOCALIP
    $IPT -A FORWARD -p upd --dport 4569 -j ACCEPT
    $IPT -t nat -A POSTROUTING -p udp -s LOCALIP -j SNAT --to PUBLICIP
    I run tcpdump on my gateway computer and also on my asterisk server. When the keep-alive heartbeat packet comes from a computer on the outside, I see it hit the ubuntu gateway but not the asterisk server. If my asterisk server generates the heartbeat packet, I see it on both ends.

    Also, forwarding is enabled under /proc/sys/net/ipv4/ip_forward

    Anyone know why the ubuntu gateway isn't forwarding the packet on to my asterisk server?
    come on guys, it's all ball bearings nowadays

  2. #2
    Join Date
    Feb 2011
    Location
    Coquitlam, B.C. Canada
    Beans
    3,515
    Distro
    Ubuntu Development Release

    Re: Simple port forward with iptables...

    I think that this rule
    Code:
    $IPT -t nat -A POSTROUTING -p udp -s LOCALIP -j SNAT --to PUBLICIP
    needs to specify an interface. Specifically your external interface.
    Code:
    $IPT -t nat -A POSTROUTING -o EXTERNAL_INTERFACE -p udp -s LOCALIP -j SNAT --to PUBLICIP
    Similiarly for your PREROUTING rule. This:
    Code:
    $IPT -t nat -A PREROUTING -p udp --dport 4569 -j DNAT --to LOCALIP
    should be this:
    Code:
    $IPT -t nat -A PREROUTING -i EXTERNAL_INTERFACE -p udp --dport 4569 -j DNAT --to LOCALIP
    Last edited by Doug S; April 25th, 2015 at 02:46 AM. Reason: fix messed up reply
    Any follow-up information on your issue would be appreciated. Please have the courtesy to report back.

  3. #3
    Join Date
    Feb 2005
    Location
    Windsor, California
    Beans
    292
    Distro
    Ubuntu 7.10 Gutsy Gibbon

    Re: Simple port forward with iptables...

    Well, it turns out the server needed to be rebooted. I guess you can only flush iptables so many times...

    Thanks for your help!

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
  •