LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 04-26-2009, 12:57 AM   #1
fuze
LQ Newbie
 
Registered: Apr 2009
Posts: 14

Rep: Reputation: 0
iptables Port Forwarding Problem


Here is my Network:
Code:
       Internet
-----------|-----------
   Static IP Router
IP: 192.168.0.1
-----------|-----------
ETH0: 192.168.0.101
 Ubuntu DHCP + Firewall
ETH1: 172.17.207.121
-----------|-----------
IP: 172.17.207.200
       WebServer
i tried Port Forwarding using these Commands:
Code:
/sbin/iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 6900 -j DNAT --to 172.17.207.200
/sbin/iptables -A FORWARD -d 172.17.207.200 -p tcp --dport 6900 -j ACCEPT
But that doesnt work ive tried pinging 172.17.207.200 from the Ubuntu Server but it just times out maybe there is a network problem?

Im trying to Forward port 6900 from the internet to ip: 172.17.207.200 in my inside network on port: 80

Any Ideas?

My rc.local script that sets up NAT and port forwarding using iptables:
Code:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
echo " * STARTING AND CONFIGURING FIREWALL.................................."
echo " * Flushing All iptables already setup				[ OK ]"
# START FLUSH
/sbin/iptables -F
/sbin/iptables -X
/sbin/iptables -t nat -F
/sbin/iptables -t nat -X
/sbin/iptables -t mangle -F
/sbin/iptables -t mangle -X
# END FLUSH

echo " * Setting Default Filter Policy				[ OK ]"
# START DEFAULT FILTER POLICY
/sbin/iptables -P INPUT DROP
/sbin/iptables -P OUTPUT ACCEPT
# END DEFAULT FILTER POLICY

echo " * Setting Unlimited access to loop back			[ OK ]"
# START UNLIMITED ACCESS TO LOOPBACK
/sbin/iptables -A INPUT -i lo -j ACCEPT
/sbin/iptables -A OUTPUT -o lo -j ACCEPT
# END UNLIMITED ACCESS TO LOOPBACK

echo " * Setting up NAT...						[ OK ]"
# START NAT
/sbin/iptables -P FORWARD ACCEPT
/sbin/iptables --table nat -A POSTROUTING -o eth0 -j MASQUERADE
# END NAT

echo " * Setting Port Forwards					[ OK ]"
# START PORT FORWARDING
# Allow UDP, DNS and Passive FTP
echo " * Allowing UDP, DNS and Passive FTP				[ OK ]"
/sbin/iptables -A INPUT -i eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT
# Allow Bittorent Incomming client request
echo " * Opening Port 6881						[ OK ]"
echo " * Opening Port 6999						[ OK ]"
/sbin/iptables -A INPUT -p tcp --destination-port 6881:6999 -j ACCEPT
# Allow SSHD Incoming client request
echo " * Opening Port 22						[ OK ]"
/sbin/iptables -A INPUT -p tcp --dport 22 -j ACCEPT
# Allow HTTP Incoming client request
echo " * Opening Port 80						[ OK ]"
/sbin/iptables -A INPUT -p tcp --dport 80 -j ACCEPT
# Allow Webmin Incoming client request
echo " * Opening Port 10000						[ OK ]"
/sbin/iptables -A INPUT -p tcp --dport 10000 -j ACCEPT
echo " * Opening Port 3000						[ OK ]"
/sbin/iptables -A INPUT -p tcp --dport 3000 -j ACCEPT
echo " * Opening Port 4214						[ OK ]"
/sbin/iptables -A INPUT -p tcp --dport 4214 -j ACCEPT
echo " * Finished Opening Ports					[ OK ]"
echo " * Starting Forward Ports to inside Servers			[ OK ]"
echo " * Forwarding Port 6900 to 172.17.207.200:80			[ OK ]"
/sbin/iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 6900 -j DNAT --to 172.17.207.200:80
/sbin/iptables -A FORWARD -d 172.17.207.200 -p tcp --dport 6900 -j ACCEPT
echo " * Finished Forwarding Ports to inside Servers			[ OK ]"
# END PORT FORWARDING

echo " * Setting Open Ports						[ OK ]"
# START LOCAL PORT OPENS
# END LOCAL PORTS OPENS

echo " * Drop Everything and Log it					[ OK ]"
# START DROP everything and Log it
/sbin/iptables -A INPUT -j LOG
/sbin/iptables -A INPUT -j DROP
# END DROP everything and Log it
echo " * Setting up NAT						[ OK ]"
exit 0
dhcpd.conf file:
Code:
ddns-update-style none;
option domain-name "router.local";
option domain-name-servers 203.97.33.14, 203.97.37.14;
option routers 172.17.207.121;
default-lease-time 42300;
max-lease-time 84600;
authoritative;
log-facility local7;
subnet 172.17.0.0 netmask 255.255.0.0 {
	range 172.17.207.1 172.17.207.100;
}

Last edited by fuze; 04-26-2009 at 02:03 AM.
 
Old 04-26-2009, 01:50 AM   #2
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,529

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
do you use masquerading on the server?
 
Old 04-26-2009, 01:55 AM   #3
fuze
LQ Newbie
 
Registered: Apr 2009
Posts: 14

Original Poster
Rep: Reputation: 0
um i think i put in the rc.local script i use above.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem on iptables port forwarding panic4all Linux - Networking 2 01-30-2009 09:22 AM
Port Forwarding Problem using IPTABLES ^vampire^ Linux - Networking 1 10-12-2006 06:27 AM
Port Forwarding Problem using IPTABLES ^vampire^ Linux - Security 1 10-12-2006 04:22 AM
iptables problem.....port forwarding..... shahg_shahg Linux - Networking 1 03-22-2006 05:17 AM
IPTables port forwarding problem deadlydemon Linux - Security 2 04-25-2005 04:43 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 09:27 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration