LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 03-17-2004, 05:49 AM   #1
hotrodowner
Member
 
Registered: Mar 2002
Distribution: Too many to count
Posts: 368

Rep: Reputation: 30
strrange iptables forwarding


The worst part about this is that it just suddenly happened. Eth0 is my Internet connection. I typed:

iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 23 -j DNAT --to-destination 192.168.**.1:22

iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j DNAT --to-destination 192.168.**.5:22

the ** are for security reasons in posting here; those are real numbers in the commands. The reason I have such strange forwarding is because I have to get through another firewall that blocks most ports besides telnet and http. This worked when I first used it, but yesterday I didn't get a responce on the port 80 forwarding. I don't have httpd running, so I tried service iptables stop and then retyping those commands, but I still can't get through. I tried switching the ports, and then port 80 worked but 23 didn't. I tried ssh'ing straight to 192.168.**.5 and it worked fine. It appears to me that iptables just isn't forward to "outside the box" ip addresses. Any thoughts? some module I need or rule I forgot?
 
Old 03-17-2004, 06:10 AM   #2
AutOPSY
Member
 
Registered: Mar 2004
Location: US
Distribution: Redhat 9 - Linux 2.6.3
Posts: 836

Rep: Reputation: 31
from the looks of it you have 1 machine as a firewall.
that you are trying to forward port 80 requests to 192.168.1.105

Dont you have a router that you can use for port forwarding?

PS: adding * isnt going to help security.
192.168.1.1 is everyones class b lan router address.

Last edited by AutOPSY; 03-17-2004 at 06:13 AM.
 
Old 03-17-2004, 07:47 AM   #3
hotrodowner
Member
 
Registered: Mar 2002
Distribution: Too many to count
Posts: 368

Original Poster
Rep: Reputation: 30
I don't want to discourage posting, but please post something relavent

1) I am trying to forward the requests to 192.168.**.5, not 192.168.1.105.
2) I am using my linux computer as the router
3) putting * will provide security because it could be any number from 0-254
4) 192.168.1.1 is a specific ip address, in classful addressing it belongs to the 192.168.1.0/24 network.
5) the 192.168.1.1/24 address range is not what everybody uses.
6) 192.168.1.1/24 is not a class B network, it is a class C network.


I don't mean to cause hostility or hurt feelings, but please know what your talking about. Could someone please reply that knows something about iptables rules?
 
Old 04-03-2004, 07:43 PM   #4
hotrodowner
Member
 
Registered: Mar 2002
Distribution: Too many to count
Posts: 368

Original Poster
Rep: Reputation: 30
I wish someone could help me with this, it's kinda important...
 
Old 04-04-2004, 03:45 AM   #5
ugge
Senior Member
 
Registered: Dec 2000
Location: Gothenburg, SWEDEN
Distribution: OpenSUSE 10.3
Posts: 1,028

Rep: Reputation: 45
Some clarifying questions:
"yesterday I didn't get a responce on the port 80 forwarding"
That means you tried to ssh to you Internet IP on port 80 FROM the Internet?

"I tried ssh'ing straight to 192.168.**.5"
Meaning ssh from local router to 192.168.**.5 ?

To make something out of this we will have to know the current iptables setup.
iptables -n -L
iptables -n -L -t nat
 
Old 04-04-2004, 07:19 AM   #6
hotrodowner
Member
 
Registered: Mar 2002
Distribution: Too many to count
Posts: 368

Original Poster
Rep: Reputation: 30
Yes, I tried to ssh from the Internet

Chain INPUT (policy ACCEPT)
target prot opt source destination

Chain FORWARD (policy ACCEPT)
target prot opt source destination
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
ACCEPT all -- 192.168.**.0/24 0.0.0.0/0
ACCEPT all -- 0.0.0.0/0 192.168.**.0/24
DROP all -- !192.168.**.0/24 0.0.0.0/0

Chain OUTPUT (policy ACCEPT)
target prot opt source destination


--------------------------------------------------------------------------

Chain PREROUTING (policy ACCEPT)
target prot opt source destination
DNAT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:23 to:192.168.**.1:22
DNAT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:80 to:192.168.**.5:22

Chain POSTROUTING (policy ACCEPT)
target prot opt source destination



and the 23 routing works, but the 80 doesn't

Last edited by hotrodowner; 04-04-2004 at 07:21 AM.
 
Old 04-04-2004, 09:13 AM   #7
ugge
Senior Member
 
Registered: Dec 2000
Location: Gothenburg, SWEDEN
Distribution: OpenSUSE 10.3
Posts: 1,028

Rep: Reputation: 45
My conclusion of the network topology

Internet - ISP firewall - Your router - Your LAN

How far does the packets come? Do you get any incoming packets for the 80 or 23 port on your firewall? iptables -L -n -v
Where are your packets matched, one of your rules or are they matched at the policy?
This is interesting to know because then we can narrow the problem down to where and why it can't establish a connection.

iptables -Z will zero the counters so that you can monitor it more easily.
 
Old 04-04-2004, 01:58 PM   #8
hotrodowner
Member
 
Registered: Mar 2002
Distribution: Too many to count
Posts: 368

Original Poster
Rep: Reputation: 30
yes, I do get packets for both. I tried the port 80, and it has twice the number of packets as the one to port 23. Port 23 works, but then port 80 times out.

They are matched by the rules:

iptables -t nat -A PREROUTING -i eth+ -p tcp -m tcp --dport 23 -j DNAT --to-destination 192.168.**.1:22

iptables -t nat -A PREROUTING -i eth+ -p tcp -m tcp --dport 80 -j DNAT --to-destination 192.168.**.5:22
 
  


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
IPCHAINS port forwarding and IPTABLES port forwarding ediestajr Linux - Networking 26 01-14-2007 07:35 PM
help with iptables and forwarding laclac01 Linux - Networking 1 10-23-2005 07:16 AM
iptables forwarding... AnalyticaL Linux - Networking 5 09-28-2004 08:55 AM
Iptables Forwarding Help!! jglazner Linux - Networking 2 10-20-2003 05:04 PM
IP forwarding through iptables harshalupatel Linux - Networking 0 06-18-2003 01:29 PM

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

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