All of lore.kernel.org
 help / color / mirror / Atom feed
* forwarding on the same NIC
@ 2004-05-10 19:36 alucard
  2004-05-10 20:15 ` Antony Stone
  2004-05-10 20:55 ` Alistair Tonner
  0 siblings, 2 replies; 17+ messages in thread
From: alucard @ 2004-05-10 19:36 UTC (permalink / raw)
  To: netfilter

Hi there...

   I have been using netfilter for a while and now, I have to integrate
some other servers and somehow I can't get it to forward packets. Let
me explain mi scenario.

- Linux box, Address 10.73.219.156 nat'ed' from a real IP address from a
external router
- The linux box has only one NIC -and having a second one is not a
problem- It functions as a web/mail server, and that means that I'm using
80 and 25 already. What i'd like to do is, access another internal
webserver from the outside getting in using another port in the nat'ed'
linux box.


-------      -----------------      ----------------
router |<--->|Linux box      |<---->|2nd WebServer |
-------      |using web/mail |      |10.73.219.77  |
             |10.73.219.156  |      ----------------
             -----------------

And I think that, using something like this would make it happen but it
doesn't

-------------
iptables -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i eth0 -p tcp --dport 8080 -j ACCEPT
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 8080 -j DNAT
--to-destination 10.73.219.77:80
--------------

I'm trying to use port 8080 to enter into the server and then forward it
to the other's server port 80 and it's not working. Here's my whole
script, which include some other services that I use perfectly.

--------------
iptables -F
iptables -X

echo "Habilitando politicas de negacion total de paquetes"

iptables -P FORWARD DROP
iptables -P INPUT DROP

echo "Reglas para paquetes de entrada y salida"

iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT

iptables -A INPUT -p tcp --dport 21 -j ACCEPT
iptables -A INPUT -p tcp --dport 25 -j ACCEPT
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 22 -j ACCEPT

##internas
iptables -A INPUT -i eth0 -p tcp --dport 143 -j ACCEPT
iptables -A INPUT -i lo -p tcp --dport 143 -j ACCEPT
iptables -A INPUT -p tcp --dport 3306 -j ACCEPT
iptables -A INPUT -i eth0 -p tcp --dport 110 -j ACCEPT

#para el forward a la maquina compaq

echo 0 > /proc/sys/net/ipv4/ip_forward
iptables -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i eth0 -p tcp --dport 8080 -j ACCEPT
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 8080 -j DNAT \
--to-destination 10.73.219.77:80
echo 1 > /proc/sys/net/ipv4/ip_forward
--------------

Any suggestions would be really apreciated

Thanx a lot as usual...
Juan


^ permalink raw reply	[flat|nested] 17+ messages in thread
* RE: forwarding on the same NIC
@ 2004-05-11 17:30 Daniel Chemko
  0 siblings, 0 replies; 17+ messages in thread
From: Daniel Chemko @ 2004-05-11 17:30 UTC (permalink / raw)
  To: alucard; +Cc: netfilter

Have you tried something like:

iptables -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD --destination 10.73.219.156 -p tcp --dport 80 -j
ACCEPT
iptables -t nat -A PREROUTING --destination 10.73.219.156 -p tcp --dport
8080 -j DNAT --to-destination 10.73.219.77:80
iptables -t nat -A POSTROUTING --destination 10.73.219.77 -p tcp --dport
80 -j SNAT --to-source 10.73.219.156

Remember, if the default router of the web server isn't your firewall
box, the packet will exit the router, but when the next packet destined
for the web server is senty by the client, the linux box doesn't think
its valid. This is because the conntrack missed the obligatory SYNACK.
The subsequent ACK to the firewall would mean nothing. I could be wrong
about the internal logic, but it'd make sense.



^ permalink raw reply	[flat|nested] 17+ messages in thread
* RE: forwarding on the same NIC
@ 2004-05-11 22:18 Daniel Chemko
  0 siblings, 0 replies; 17+ messages in thread
From: Daniel Chemko @ 2004-05-11 22:18 UTC (permalink / raw)
  To: alucard, netfilter

> To make matters worse, the second webserver is IIS and I have no idea
> how to use IP Multiplexing on Win2k, I could do it in linux but
> Windows systems are not my expertise. What I'm going to do -if I get
> the permission- is this: Install a 2nd nic on the 2nd webserver so
> the IP address that is being used doesn't get affected and I will
> configure it's router to the linux box so it can redirect packets
> where they should go...     

You are either not grasping how difficult what your trying to do, or you
haven't used proper the wording. Source Routing from windows == blah! If
you're relying on windows to do routing, I pity thou. 


To the best of my knowledge, you have:
x.x.x.254 ROUTER
   |--x.x.x.1 Linux Server 1  (default route x.x.x.254)
   |--x.x.x.2 Windows IIS (default route x.x.x.254)

You have the router forwarding a public IP address and PATing it to
x.x.x.1. You want x.x.x.1:8080 to go to x.x.x.2:80

To get this to work, use:

# Allow any established traffic to traverse the machine
iptables -A FORWARD -m state ESTABLISHED,RELATED -j ACCEPT
# Forward the packet destined for 8080 to the windows machine on port 80
iptables -t nat -A PREROUTING --destination x.x.x.1 -p tcp --dport 8080
-j DNAT --to x.x.x.2:80
# Allow new web traffic into the network
iptables -A FORWARD --destination x.x.x.2 -p tcp --dport 80 -j ACCEPT
# Forces the windows box to route back to you before leaving the network
iptables -t nat -A POSTROUTING --destination x.x.x.2 -p tcp --dport 80
-j SNAT --to x.x.x.1

The order of traversal becomes:

Router->Firewall->Windows->Firewall->Router
Instead of
Router->Firewall->Windows->Router
The later breaks as I've described earlier.


^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2004-05-11 22:18 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-05-10 19:36 forwarding on the same NIC alucard
2004-05-10 20:15 ` Antony Stone
2004-05-10 22:09   ` alucard
2004-05-10 22:26     ` John A. Sullivan III
2004-05-11 13:49       ` alucard
2004-05-11 15:09         ` John A. Sullivan III
2004-05-11 15:38           ` alucard
2004-05-11 16:26             ` Aleksandar Milivojevic
2004-05-11 19:20               ` alucard
2004-05-11 20:37                 ` Aleksandar Milivojevic
2004-05-11 17:04             ` John A. Sullivan III
2004-05-11 19:35               ` alucard
2004-05-11 20:09                 ` John A. Sullivan III
2004-05-11 21:02                   ` alucard
2004-05-10 20:55 ` Alistair Tonner
  -- strict thread matches above, loose matches on Subject: below --
2004-05-11 17:30 Daniel Chemko
2004-05-11 22:18 Daniel Chemko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.