LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 03-26-2010, 01:17 PM   #1
robertjinx
Member
 
Registered: Oct 2007
Location: Prague, CZ
Distribution: RedHat / CentOS / Ubuntu / SUSE / Debian
Posts: 749

Rep: Reputation: 73
iptables port forwarding not working...


Hello, I have the following setup and Im trying to forward all incoming connection on port 1194 on eth2 which is the external network to ip 192.168.10.100, but seems its not working.

Current config:

# Generated by iptables-save v1.3.8 on Sun Nov 16 00:00:54 2008
*nat
:PREROUTING ACCEPT [26751696:2175544875]
:POSTROUTING ACCEPT [339911:19096812]
:OUTPUT ACCEPT [339825:19075304]
-A POSTROUTING -s 192.168.10.0/255.255.255.0 -d ! 192.168.10.0/255.255.255.0 -o eth2 -j MASQUERADE
-A POSTROUTING -s 192.168.11.0/255.255.255.0 -d ! 192.168.11.0/255.255.255.0 -o eth2 -j MASQUERADE
COMMIT
# Completed on Sun Nov 16 00:00:54 2008
# Generated by iptables-save v1.3.8 on Sun Nov 16 00:00:54 2008
*filter
:INPUT DROP [0:0]
:FORWARD DROP [753:246984]
:OUTPUT ACCEPT [0:0]
-A INPUT -i lo -j ACCEPT
-A INPUT -i eth0 -j ACCEPT
-A INPUT -i eth1 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 20 -m state --state NEW -j ACCEPT
-A INPUT -p tcp -m tcp --dport 21 -m state --state NEW -j ACCEPT
-A INPUT -p tcp -m tcp --dport 22 -m state --state NEW -j ACCEPT
-A INPUT -p tcp -m tcp --dport 80 -m state --state NEW -j ACCEPT
-A INPUT -p tcp -m tcp --dport 443 -m state --state NEW -j ACCEPT
-A INPUT -p tcp -m tcp --dport 25 -m state --state NEW -j ACCEPT
-A INPUT -p tcp -m tcp --dport 143 -m state --state NEW -j ACCEPT
-A INPUT -p tcp -m tcp --dport 993 -m state --state NEW -j ACCEPT
-A INPUT -p udp -m udp --dport 123 -m state --state NEW -j ACCEPT
-A INPUT -p tcp -m tcp --dport 53 -m state --state NEW -j ACCEPT
-A INPUT -p udp -m udp --dport 53 -m state --state NEW -j ACCEPT
-A INPUT -p tcp -m tcp --dport 1138 -m state --state NEW -j ACCEPT
-A INPUT -p tcp -m tcp --dport 20000 -m state --state NEW -j ACCEPT
-A INPUT -p tcp -m tcp --dport 1194 -m state --state NEW -j ACCEPT
-A INPUT -p icmp -m limit --limit 1/sec --limit-burst 1 -j ACCEPT
-A INPUT -i eth2 -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m tcp --tcp-flags ACK ACK -j ACCEPT
-A FORWARD -i eth0 -j ACCEPT
-A FORWARD -i eth1 -j ACCEPT
-A FORWARD -p tcp -m tcp --tcp-flags ACK ACK -j ACCEPT
-A FORWARD -m state --state ESTABLISHED -j ACCEPT
-A FORWARD -m state --state RELATED -j ACCEPT
COMMIT

plus im adding the prerouting:

iptables -t nat -A PREROUTING -i eth2 -p tcp --dport 1194 -j DNAT --to-destination 192.168.10.100

This configuration doesnt work. I also I have tried:

iptables -D PREROUTING -t nat -p tcp -d XX.XX.XX.XX --dport 1194 -m state --state NEW,ESTABLISHED,RELATED -j DNAT --to 192.168.10.100:1194

and the same its not working.

Connecting thru telnet to the domain: telnet mydomain.org 1194 doesnt work, but within the server, running telnet 192.168.10.100 1194 it works.

Does anyone have an idea whats the problem?
 
Old 03-26-2010, 04:22 PM   #2
nicedream
Member
 
Registered: Feb 2010
Distribution: Arch Linux
Posts: 68

Rep: Reputation: 19
One thing you should check is to make sure IP Forwarding is turned on.

Check the output of /proc/sys/net/ipv4/ip_forward by running

Code:
cat /proc/sys/net/ipv4/ip_forward
If the output is a zero, then enable IP Forwarding by running

Code:
echo 1 > /proc/sys/net/ipv4/ip_forward
 
Old 03-26-2010, 04:24 PM   #3
Berhanie
Senior Member
 
Registered: Dec 2003
Location: phnom penh
Distribution: Fedora
Posts: 1,625

Rep: Reputation: 165Reputation: 165
Code:
iptables -t nat -A PREROUTING -i eth2 -p tcp --dport 1194 -j DNAT --to-destination 192.168.10.100
ok, but you also need something in the FORWARDING chain to allow it. you probably know this already, but
openvpn runs on UDP port 1194 by default.
 
Old 03-26-2010, 06:34 PM   #4
robertjinx
Member
 
Registered: Oct 2007
Location: Prague, CZ
Distribution: RedHat / CentOS / Ubuntu / SUSE / Debian
Posts: 749

Original Poster
Rep: Reputation: 73
Its running on tcp port 1194 and have not idea what else to do.

ip_forward is enabled.
 
Old 03-26-2010, 08:30 PM   #5
Berhanie
Senior Member
 
Registered: Dec 2003
Location: phnom penh
Distribution: Fedora
Posts: 1,625

Rep: Reputation: 165Reputation: 165
Quote:
and have not idea what else to do.
To be more explicit, you need something like this:
Code:
iptables -t nat -A PREROUTING -i eth2 -d ip.address.of.eth2 -p tcp --dport 1194 -j DNAT --to-destination 192.168.10.100
iptables -A FORWARD -d 192.168.10.100 -p tcp --dport 1194 -j ACCEPT
If you're still having problems after installing these rules, you can use tcpdump
to see whether the packets and replies are being sent/received.
 
Old 03-27-2010, 03:50 AM   #6
robertjinx
Member
 
Registered: Oct 2007
Location: Prague, CZ
Distribution: RedHat / CentOS / Ubuntu / SUSE / Debian
Posts: 749

Original Poster
Rep: Reputation: 73
Sorry, but thats not working ether... other ideas. Normally I dont have a problem with this, but I cant figure it out what im doing wrong.
 
Old 03-27-2010, 04:27 AM   #7
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Is a packet being filtered by your FORWARD chain's policy when your test fails?
Code:
iptables -A FORWARD -j LOG --log-prefix "FORWARD DROP: "
If so, post the log entry generated by said packet.

While we're at it, are your routes properly set? Let's see the output of:
Code:
/sbin/ifconfig
Code:
/sbin/route -n
Also, please show us the output of these commands, so that we may see your current, actual configuration:
Code:
iptables -nvL FORWARD
Code:
iptables -nvL -t nat
Please use CODE tags when you post output, so that it's easier to read.

Last edited by win32sux; 03-27-2010 at 04:43 AM.
 
Old 03-27-2010, 06:00 AM   #8
barshani
LQ Newbie
 
Registered: Sep 2004
Location: Trivandrum
Distribution: Redhat
Posts: 18

Rep: Reputation: 3
1. please check your 192.168.10.100's gateway. that must be XX.XX.XX.XX's LAN IP.

2. you should check - telnet mydomain.org 1194 only from outside of this Gateway.
 
Old 03-27-2010, 06:01 AM   #9
Berhanie
Senior Member
 
Registered: Dec 2003
Location: phnom penh
Distribution: Fedora
Posts: 1,625

Rep: Reputation: 165Reputation: 165
[EDIT]Removed. This was essentially barshani's point #2.

Last edited by Berhanie; 03-27-2010 at 06:33 AM.
 
  


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
[SOLVED] IPTables port forwarding using prerouting not working blackman890 Linux - Networking 3 02-19-2010 02:33 PM
Iptables port forwarding is not working 8080 to 80 linux_man_2004 Linux - Networking 13 04-14-2008 01:10 PM
IPtables port-forwarding not working. Ratclaws Linux - Networking 3 04-12-2005 08:14 AM
iptables port forwarding not working! friendklay Linux - Networking 1 03-23-2005 06:37 AM
Port forwarding with iptables is not working?!! philipina Linux - Networking 1 04-03-2004 03:18 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 12:02 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