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 12-24-2001, 07:19 PM   #1
GnomeKing
LQ Newbie
 
Registered: Sep 2001
Posts: 12

Rep: Reputation: 0
heeeeeelp! :( (packet forwarding)


:smash:
I <JUST> realised my firewall was rediculously insecure.... I'm forwarding connections to a certain port to an internal machine, on a per-host basis... HOWEVER, this port forwarding doesnt seem to match to the host atall!

relavent setup:

$IPTABLES -t nat -A PREROUTING -i $EXT_IF -p tcp --dport 41265 -j DNAT --to 192.168.1.37

$IPTABLES -A INPUT -i $EXT_IF -s $ANY -j ext_in

$IPTABLES -A ext_in -p tcp --dport 41265 -m state --state NEW -j custom_rule

$IPTABLES -A custom_rule -s 135.113.9.64 -j ACCEPT
$IPTABLES -A custom_rule -j DROP

can someone tell me what I've done wrong?
clients connect to <<myip>>:41265 and EVERYONE is forwarded to 192.168.1.37 ... ... ...

Thanks in advance for your help
 
Old 12-26-2001, 01:21 PM   #2
jrmann1999
Member
 
Registered: Feb 2001
Location: Texas
Distribution: Slackware, Mandrake, LFS
Posts: 306

Rep: Reputation: 30
Quote:
$IPTABLES -t nat -A PREROUTING -i $EXT_IF -p tcp --dport 41265 -j DNAT --to 192.168.1.37
Let's break this down so that you might understand why it's failing.

$IPTABLES -t nat -A PREROUTING

The above part of the command selects the PREROUTING entry from the nat table.

-i $EXT_IF

using the interface defined by $EXT_IF

-p tcp --dport 41265

directed at the TCP port 41265

-j DNAT --to 192.168.1.37

take this connection and DNAT it to the IP specified.

You'll notice, you haven't done any -s or -d flags(source and destination), so my question to you is, how did you expect it to NOT forward everyone to that port? Try something like:

$IPTABLES -t nat -A PREROUTING -p tcp --dport 41265 -s $ALLOWED_IP -i $EXT_IF -j DNAT --to $DESTINATION_IP:41265

and substitute as many entries as you think you'll need for $ALLOWED_IP
 
Old 12-26-2001, 01:33 PM   #3
GnomeKing
LQ Newbie
 
Registered: Sep 2001
Posts: 12

Original Poster
Rep: Reputation: 0
Quote:
Originally posted by jrmann1999

You'll notice, you haven't done any -s or -d flags(source and destination), so my question to you is, how did you expect it to NOT forward everyone to that port? Try something like:
it was my understanding that the packets first went through the INPUT chain from the external interface...
I restrict by IP there...

but if it doesnt go through that chain I guess I'll have to add all the ip's in there.....
 
Old 12-26-2001, 02:34 PM   #4
jrmann1999
Member
 
Registered: Feb 2001
Location: Texas
Distribution: Slackware, Mandrake, LFS
Posts: 306

Rep: Reputation: 30
Nope, the order is loosely:

Prerouting->Input->Forward->Output->PostRouting

Prerouting and Postrouting are ALWAYS used, the others are obviously optional depending on the connection.

J
 
  


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
packet forwarding? one.eleven Linux - Networking 19 11-08-2006 03:35 AM
Packet and Port forwarding umeshbabu Linux - Networking 1 08-21-2005 11:43 PM
packet fragmentation in packet forwarding code cranium2004 Linux - Networking 0 05-16-2005 04:05 AM
How to enable packet forwarding davidho3 Linux - Networking 2 10-12-2004 10:45 AM
port forwarding and packet forwarding syrtsardo Linux - Newbie 2 07-03-2003 10:37 AM

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

All times are GMT -5. The time now is 12:23 AM.

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