Skip to content

Instantly share code, notes, and snippets.

@searls
Created July 19, 2011 15:07
Show Gist options
  • Save searls/1092695 to your computer and use it in GitHub Desktop.
Save searls/1092695 to your computer and use it in GitHub Desktop.
Forwarding

http://forums.linuxmint.com/viewtopic.php?f=157&t=56226

http://serverfault.com/questions/140622/how-can-i-port-forward-with-iptables

  1. Set up the forwarding

     sudo -s
     echo '1' > /proc/sys/net/ipv4/conf/eth0/forwarding
     iptables -t nat -A PREROUTING -p tcp -i eth0 --dport 1521 -j DNAT --to-destination 192.168.56.102:1521
     iptables -A FORWARD -p tcp -d 192.168.56.102 --dport 1521 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
    
  2. Verify the config

     iptables -L -n
    
  3. Persist that config

     iptables-save > /etc/firewall.conf
    
  4. Create /etc/network/if-up.d/iptables with:

     #!/bin/sh
     iptables-restore < /etc/firewall.conf
    
  5. Make it executable:

     chmod +x /etc/network/if-up.d/iptables
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment