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 06-04-2008, 05:53 PM   #1
mpapet
Member
 
Registered: Nov 2003
Location: Los Angeles
Distribution: debian
Posts: 548

Rep: Reputation: 72
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 05:58 PM.
 
Old 06-05-2008, 12:46 PM   #2
mpapet
Member
 
Registered: Nov 2003
Location: Los Angeles
Distribution: debian
Posts: 548

Original Poster
Rep: Reputation: 72
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



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

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

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