Networking Forums

Networking Forums > Computer Networking > Linux Networking > iptables q

Reply
 
 
Coenraad Loubser
Guest
Posts: n/a

 
      03-10-2005, 06:53 PM
I've got a webserver running on port 80. Why can't external sites access it
after I execute the following? The intended port gets through... but I
suspect everything else goes to the forwarded
port too...

iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 5678 -j DNAT --to-dest
192.168.0.95
iptables -A FORWARD -p tcp -i eth0 --dport 5678 -d 192.168.0.95 -j ACCEPT




 
Reply With Quote
 
 
 
 
Jose Maria Lopez Hernandez
Guest
Posts: n/a

 
      03-10-2005, 07:11 PM
Coenraad Loubser wrote:
> I've got a webserver running on port 80. Why can't external sites access it
> after I execute the following? The intended port gets through... but I
> suspect everything else goes to the forwarded
> port too...
>
> iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 5678 -j DNAT --to-dest
> 192.168.0.95
> iptables -A FORWARD -p tcp -i eth0 --dport 5678 -d 192.168.0.95 -j ACCEPT


If you've got the webserver running in port 80 then you should change
your rules to:

iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 5678 -j DNAT
--to-dest 192.168.0.95:80
iptables -A FORWARD -p tcp -i eth0 --dport 80 -d 192.168.0.95 -j ACCEPT

Regards.

--

Jose Maria Lopez Hernandez
Director Tecnico de bgSEC
(E-Mail Removed)
bgSEC Seguridad y Consultoria de Sistemas Informaticos
http://www.bgsec.com
ESPAÑA

The only people for me are the mad ones -- the ones who are mad to live,
mad to talk, mad to be saved, desirous of everything at the same time,
the ones who never yawn or say a commonplace thing, but burn, burn, burn
like fabulous yellow Roman candles.
-- Jack Kerouac, "On the Road"
 
Reply With Quote
 
Coenraad Loubser
Guest
Posts: n/a

 
      03-11-2005, 12:38 PM
Sorry, i've rephrased the question in a new post...

I dont want 5678 to go to port 80, (handy syntax though..).

The command is executed on a machine 192.168.0.1 that gets all incoming
connections. If something connects on port 5678 i want it to go to
192.168.0.95.

But when i execute iptables -A FORWARD -p tcp -i eth0 bla ba it kills my
webserver on 192.168.0.1

Any ideas why this is?
That line, to me, looks like an "allow" line. I dont have any "block all"
lines, so I suspect that soon as I enter that, it automatically presumes
that it should ONLY accept these connections...

Hmmm..

Damn, I'm sure the syntax for these silly commands could be just a little
more simplified...!

Thanks anyway


 
Reply With Quote
 
Jarek
Guest
Posts: n/a

 
      04-19-2005, 12:34 PM
Hi!

Coenraad Loubser wrote:
> I've got a webserver running on port 80. Why can't external sites access it
> after I execute the following? The intended port gets through... but I
> suspect everything else goes to the forwarded
> port too...
>
> iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 5678 -j DNAT --to-dest
> 192.168.0.95
> iptables -A FORWARD -p tcp -i eth0 --dport 5678 -d 192.168.0.95 -j ACCEPT


What about reverse NAT (SNAT, MASQUERADE) ?
Do you think that client will accept ACK comming from 192.168.0.95 ?

regards
Jarek
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
about iptables junaidaslam Linux Networking 3 08-29-2005 09:35 PM
Looking for iptables applications code (iptables.c) to run some rules to forward packets tvnaidu@yahoo.com Linux Networking 2 01-17-2005 05:01 PM
iptables Bernd Roth Linux Networking 5 01-16-2005 05:53 PM
iptables and nat Marcin Giedz Linux Networking 5 07-06-2004 07:05 AM
iptables "can't initialize iptables table `filter'" pete Linux Networking 1 10-10-2003 03:44 AM



1 2 3 4 5 6 7 8 9 10 11