LinuxQuestions.org
Help answer threads with 0 replies.
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 06-04-2008, 06:53 PM   #1
mpapet
Member
 
Registered: Nov 2003
Location: Los Angeles
Distribution: debian
Posts: 538

Rep: Reputation: 71
Iptables problem


I'm trying to forward all traffic from port 172.18.1.40:50006 (eth0) to 172.18.1.40:5432 (postgresql)

My rules work from another machine on the LAN just fine. e.g. a telnet client connects to postgresql server on 50006. However trying to telnet from the machine hosting the postgresql server gets "connection refused." I've added the FORWARD (useless?) rules to try to get it to work on the local machine, but no go. Here are my rules. They are the only ones on the system.

#This rule maps hp's SIM postgre to the postgre default
iptables -t nat -A PREROUTING -p tcp -i eth0 --dport 50006 -j REDIRECT --to-port 5432
iptables -t nat -A PREROUTING -p udp -i eth0 --dport 50006 -j REDIRECT --to-port 5432

iptables -t nat -A PREROUTING -p tcp -i lo --dport 50006 -j REDIRECT --to-port 5432
iptables -t nat -A PREROUTING -p udp -i lo --dport 50006 -j REDIRECT --to-port 5432

#Must accept the traffic from 50006
iptables -A FORWARD -p tcp -m state --state NEW,ESTABLISHED,RELATED -o 172.18.1.40 --dport 5432 -j ACCEPT
iptables -A FORWARD -p udp -m state --state NEW,ESTABLISHED,RELATED -o 172.18.1.40 --dport 5432 -j ACCEPT
iptables -A FORWARD -p tcp -m state --state NEW,ESTABLISHED,RELATED -o 127.0.0.1 --dport 50006 -j ACCEPT
iptables -A FORWARD -p tcp -m state --state NEW,ESTABLISHED,RELATED -o 172.18.1.40 --dport 50006 -j ACCEPT


Any advice is welcome.

Last edited by mpapet; 06-04-2008 at 06:58 PM.
 
Old 06-05-2008, 01:46 PM   #2
mpapet
Member
 
Registered: Nov 2003
Location: Los Angeles
Distribution: debian
Posts: 538

Original Poster
Rep: Reputation: 71
I discovered I had two problems and some faulty assumptions about how iptables could/would route traffic.

The port forwarding stanzas are not viable for 127.0.0.1. Apparently the kernel rejects these outright because they are non-routable addresses... or something like that.... If you have more precise language, please feel free to contribute.

It also appears that because this is happening on-host instead of from a remote host, iptables stanzas won't work.

The right application to use is rinetd. Available and easily configured in Debian's repositories.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
iptables problem.?????????? raklo Linux - Software 4 07-30-2007 12:29 AM
Iptables Problem Peter_APIIT Linux - Security 16 07-28-2007 10:26 PM
iptables v1.2.9: Unknown arg `/sbin/iptables' Try `iptables -h' or 'iptables --help' Niceman2005 Linux - Security 4 12-29-2005 09:20 PM
problem in iptables alvi2 Linux - Networking 1 03-23-2005 01:31 PM
Iptables problem,help me please. ryanux Linux - Security 1 05-21-2004 10:59 PM

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

All times are GMT -5. The time now is 01:39 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration