iptables question

iptables question

Post by Coenraad Loubse » Sat, 12 Mar 2005 22:33:16



Hi.

I want to forward an outside port to a port on my LAN.
I've got a webserver running on the server that connects to the internet.

I want incoming connections on port 5678 to go to 192.168.0.95
And I want incoming connection on port 80 to keep connecting to my server
(192.168.0.1)

When I do the following:

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

Outside servers can no longer connect to my webserver!!

Why is this? I would really appreciate any comments that could shed some
light on this!!

I've since discovered that if I omit the second command, everything works.
Port gets forwarded. Whoopdee doo. So what's the point of the FORWARD table
then?

Thanks!

Coenraad

 
 
 

iptables question

Post by Jose Maria Lopez Hernande » Sat, 12 Mar 2005 22:49:01



> Hi.

> I want to forward an outside port to a port on my LAN.
> I've got a webserver running on the server that connects to the internet.

> I want incoming connections on port 5678 to go to 192.168.0.95
> And I want incoming connection on port 80 to keep connecting to my server
> (192.168.0.1)

> When I do the following:

> 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

> Outside servers can no longer connect to my webserver!!

> Why is this? I would really appreciate any comments that could shed some
> light on this!!

> I've since discovered that if I omit the second command, everything works.
> Port gets forwarded. Whoopdee doo. So what's the point of the FORWARD table
> then?

Now I understand your question. I find this extremely strange, because
if you've got the webserver listening on port 80 of the firewall then
the packets that goes to the webserver come through the INPUT chain, so
any rule in the FORWARD chain should not affect this traffic.

The rules you have written are correct and they should not affect your
webserver, so it's a mistery for me why this doesn't work.

Anyway I would use Ethereal to see what happens to the traffic and
how the webserver acts with the FORWARD rule and without it. Maybe
that way you can see what's happening.

Quote:> Thanks!

> Coenraad

Regards

--

Jose Maria Lopez Hernandez
Director Tecnico de bgSEC

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"

 
 
 

iptables question

Post by pizz » Sun, 13 Mar 2005 02:36:53


# SET UP YOUR DESTINATIONS AND SOURCES (ASSUMING eth0 IS THE EXTERNAL
INTERFACE.)
iptables -t nat -A PREROUTING -d <ext.addr.> -i <interface(eth0)> -j
DNAT --to <int.addr.>
iptables -t nat -A POSTROUTING -s <int.addr.> -o <interface(eth0)> -j
SNAT --to <ext.addr.>
# I WOULD CHANGE MY DEFAULT POLICIES BUT THIS IS OPTIONAL
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT DROP
# NOW SET YOUR FORWARD TABLE FOR CONNECTIONS STARTING FROM THE OUTSIDE
iptables -A FORWARD -p <protocol(tcp)> -i <ext.interface> -o
<int.interface> -d <int.addr.> [-m multiport --dport 80,443] [-m state
--state NEW] -j ACCEPT
# NOW YOU NEED TO GET THE CONNECTIONS BACK
iptables -A FORWARD -p <protocol(tcp)> -i <int.interface> -o
<ext.interface>-s <int.addr.> [-m multiport --sport 80,443] [-m state
--state ESTABLISHED,RELATED] -j ACCEPT

I HOPE THIS HELPS

 
 
 

1. Iptables Question

Is it possible to redirect traffic on port 80 to another box on 80 using
iptables?

-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----

2. Ingres dies at 3.2

3. iptables question

4. Hang after Telnet/SMC EtherEZ/Telnet

5. MUs, patches available by FTP?

6. ipchains/iptables question

7. Apache virtual host forwarding

8. Am I stupid? Iptables question

9. iptables question....

10. iptables question

11. iptables question about conntracking