All of lore.kernel.org
 help / color / mirror / Atom feed
* forwarding
@ 2004-05-18 14:22 alucard
  2004-05-18 14:39 ` forwarding John A. Sullivan III
  2004-05-18 14:44 ` forwarding Antony Stone
  0 siblings, 2 replies; 38+ messages in thread
From: alucard @ 2004-05-18 14:22 UTC (permalink / raw)
  To: netfilter

Hi there again,

   I finally decided to add a second card to both, the server and the
client to be able to forward packets from port 8080 in server 1 to port
80 in server 2 and somehow this packets are not going thru, let me
explain my scenario

                           Internet Address
                            Nat'ed Address
                            ---------------
                            |  Linux Box  |
                  Server 1  |10.73.219.156|nat'ed' address
                            | 192.168.0.1 |2nd NIC to forward packets
                            ---------------
                                 8080
                                   |
                                   |
                                  80
                            ---------------
                            |  web server |
                  Server 2  | 192.168.0.2 |
                            |             |
                            ---------------


- Server 1 has a natted addres using it's 10.73; what I'm trying to do is
that evrything that comes to 10.73.219.156:8080 gets forwarded to
192.168.0.2:80.

- Server 1 functions as a webserver and that's why I'm using port 8080 in
order to forward packets to port 80 in server 2

- Here's my Server 1's /etc/rc.d/rc.firewall script because somehow it's
not working:

-----
echo "Borrando posibles reglas anteriores..."
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
echo 0 > /proc/sys/net/ipv4/ip_forward
iptables -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -d 192.168.0.2 -p tcp --dport 80 -j ACCEPT
iptables -t nat -A PREROUTING -d 192.168.0.1 -p tcp --dport 8080 \
    -j DNAT --to-destination 192.168.0.2:80
echo 1 > /proc/sys/net/ipv4/ip_forward
-----

I have done this many times and somehow this time is not working, that
means that I have changed many things using postrouting, nat and dnat. Is
it because any missconfiguration on Server 2's route? here's the output:

-----
[root@linserv root]# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.0.0     *               255.255.255.0   U     0      0        0 eth1
10.73.216.0     *               255.255.252.0   U     0      0        0 eth0
169.254.0.0     *               255.255.0.0     U     0      0        0 eth0
127.0.0.0       *               255.0.0.0       U     0      0        0 lo
default         192.168.0.1     0.0.0.0         UG    0      0        0 eth1
-----

Is it because I have to use different INPUT rules? for what I know, INPUT
rules are only for the packets going to the computer itself.

Any suggestions will be great
Thanks a lot as usual to this great mailing list

Juan




^ permalink raw reply	[flat|nested] 38+ messages in thread
* forwarding
@ 2005-03-26 17:48 amir_sarbazi
  0 siblings, 0 replies; 38+ messages in thread
From: amir_sarbazi @ 2005-03-26 17:48 UTC (permalink / raw)
  To: netdev

hi all

I want  when firewall get mail request packet then forward it to
another pc (forward it to 192.168.1.3:25)

how i can do it?
best regards.

^ permalink raw reply	[flat|nested] 38+ messages in thread
* RE: forwarding
@ 2004-05-18 20:48 Daniel Chemko
  2004-05-18 21:15 ` forwarding John A. Sullivan III
  0 siblings, 1 reply; 38+ messages in thread
From: Daniel Chemko @ 2004-05-18 20:48 UTC (permalink / raw)
  To: alucard; +Cc: John A. Sullivan III, netfilter

Ok, one more thing:

Is the address 10.73.219.156 the only IP address on the external
interface of the server1?

If you don't bind the 10.73.219.156 IP address to the ethernet interface
on server1, then hosts on that network won't be able to find the server
even with the prerouting rule. You could solve this by Proxy-arp or just
simply adding another IP address to the outside interface.

This may be redundant, but I don't believe the external interface's been
discussed at all as a possible issue.



^ permalink raw reply	[flat|nested] 38+ messages in thread
* RE: forwarding
@ 2004-05-18 20:33 Daniel Chemko
  0 siblings, 0 replies; 38+ messages in thread
From: Daniel Chemko @ 2004-05-18 20:33 UTC (permalink / raw)
  To: netfilter

Antony Stone wrote:
> On Tuesday 18 May 2004 7:23 pm, Daniel Chemko wrote:
> 
>> iptables -t nat -A POSTROUTING --destination ${server2} -j SNAT --to
>> ${server1_internal_ip} 
>> 
>> This is the last time I try to respond to you since you've been
>> ignoring the rest.
> 
> Who are you talking to here (your posting was addressed to two
> individuals, plus the list), and what is "the rest" you refer to?
> 
> I have only seen one other email from you in this thread, and that
> was in response to a somewhat off-topic posting about reverse
> routing, which IMHO didn't require a response...
> 
> We don't want anyone to feel left out on this list, but if you've
> posted other comments and not had a response, the reason is probably
> that other list subscribers haven't seen what you said yet (no, I
> don't know why that would be).

Sorry, I was referring to the last thread the poster openned. Not this
one. I agree with the rest. I forgot that he had implemented the
two-card solutino already.


^ permalink raw reply	[flat|nested] 38+ messages in thread
* RE: forwarding
@ 2004-05-18 18:23 Daniel Chemko
  2004-05-18 18:42 ` forwarding Antony Stone
                   ` (2 more replies)
  0 siblings, 3 replies; 38+ messages in thread
From: Daniel Chemko @ 2004-05-18 18:23 UTC (permalink / raw)
  To: alucard, John A. Sullivan III; +Cc: netfilter

iptables -t nat -A POSTROUTING --destination ${server2} -j SNAT --to
${server1_internal_ip}

This is the last time I try to respond to you since you've been ignoring
the rest. SNAT traffic from server 1 to server 2. Period. There's no
magic. Put it in, then the system will magically work. Well, replace the
${}'s with the actual values first.

If you even get this email, let me know cause I feel like I'm falling on
deaf ears.


^ permalink raw reply	[flat|nested] 38+ messages in thread
* RE: forwarding
@ 2004-05-18 18:04 Daniel Chemko
  0 siblings, 0 replies; 38+ messages in thread
From: Daniel Chemko @ 2004-05-18 18:04 UTC (permalink / raw)
  To: John A. Sullivan III, CPD - David Cardeñosa Rubio; +Cc: netfilter

John A. Sullivan III wrote:
> I do not believe that is necessarily true.  I'm not the expert but I
> believe that if all you want is inbound access, connection tracking
> will take care of the source alteration.  You would only need SNAT if
> you wanted to originate outbound packets with the altered source. 
> Someone please correct me if I am wrong - John    

If the default route does not route back through the Linux server, you are required to SNAT the packet back to thye firewall's address basically forcing the respondee to keep the firewall in-the-loop so to speak. Netfilter will NOT allow a one way stream into the system since the second packet sent by the client (ACK) is marked as INVALID by the state machine since it never received a SYNACK in response to the initial packet.



^ permalink raw reply	[flat|nested] 38+ messages in thread
* RE: forwarding
@ 2004-05-18 17:04 CPD - David Cardeñosa Rubio
  0 siblings, 0 replies; 38+ messages in thread
From: CPD - David Cardeñosa Rubio @ 2004-05-18 17:04 UTC (permalink / raw)
  To: 'alucard@kanux.com'; +Cc: netfilter

[-- Attachment #1: Type: text/plain, Size: 3145 bytes --]

hi

Im testing your configuration in my test machines and it´s works for me


	
Firewall					web server
172.40.x.x (yes, local network with public ip, aggg) ----- [172.40.42.200 -
192.168.150.1] ----- [192.168.150.2]



firewall:~# iptables -L -t nat -n -v
Chain PREROUTING (policy ACCEPT 259 packets, 35934 bytes)
 pkts bytes target     prot opt in     out     source
destination
    3   144 DNAT       tcp  --  *      *       0.0.0.0/0
172.40.43.200      tcp dpt:8080 to:192.168.150.2:80

Chain POSTROUTING (policy ACCEPT 39 packets, 2680 bytes)
 pkts bytes target     prot opt in     out     source
destination

Chain OUTPUT (policy ACCEPT 19 packets, 1499 bytes)
 pkts bytes target     prot opt in     out     source
destination
firewall:~#

firewall:~# iptables -L -n -v
Chain INPUT (policy DROP 15 packets, 1455 bytes)
 pkts bytes target     prot opt in     out     source
destination
 2943  293K ACCEPT     all  --  *      *       0.0.0.0/0
0.0.0.0/0          state RELATED,ESTABLISHED
    1    48 ACCEPT     tcp  --  *      *       0.0.0.0/0
0.0.0.0/0          tcp dpt:22

Chain FORWARD (policy DROP 1 packets, 72 bytes)
 pkts bytes target     prot opt in     out     source
destination
 3963 3939K ACCEPT     all  --  *      *       0.0.0.0/0
0.0.0.0/0          state RELATED,ESTABLISHED
    3   144 ACCEPT     tcp  --  *      *       0.0.0.0/0
192.168.150.2      tcp dpt:80

Chain OUTPUT (policy ACCEPT 3794 packets, 283K bytes)
 pkts bytes target     prot opt in     out     source
destination
firewall:~#


balanceador:~# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use
Iface
192.168.150.0   0.0.0.0         255.255.255.252 U     0      0        0 eth1
192.168.200.0   0.0.0.0         255.255.255.0   U     0      0        0 eth0
0.0.0.0         192.168.150.1   0.0.0.0         UG    0      0        0 eth1
balanceador:~#


firewall:~# tcpdump -n tcp src or dst port 80 or 8080
tcpdump: listening on eth0
20:01:06.945606 172.60.60.75.2286 > 172.40.43.200.8080: S
1752076561:1752076561(0) win 16384 <mss 1460,nop,nop,sackOK> (DF)
20:01:06.946034 172.40.43.200.8080 > 172.60.60.75.2286: S
2920282127:2920282127(0) ack 1752076562 win 5840 <mss 1460,nop,nop,sackOK>
(DF)
20:01:06.946273 172.60.60.75.2286 > 172.40.43.200.8080: . ack 1 win 17520
(DF)
20:01:17.851129 172.60.60.75.2286 > 172.40.43.200.8080: P 1:3(2) ack 1 win
17520 (DF)
20:01:17.851467 172.40.43.200.8080 > 172.60.60.75.2286: . ack 3 win 5840
(DF)

balanceador:~# tcpdump -i eth1 -n tcp src or dst port 80
tcpdump: listening on eth1
21:08:36.116571 172.60.60.75.2286 > 192.168.150.2.80: S
1752076561:1752076561(0) win 16384 <mss 1460,nop,nop,sackOK> (DF)
21:08:36.116668 192.168.150.2.80 > 172.60.60.75.2286: S
2920282127:2920282127(0) ack 1752076562 win 5840 <mss 1460,nop,nop,sackOK>
(DF)
21:08:36.117201 172.60.60.75.2286 > 192.168.150.2.80: . ack 1 win 17520 (DF)
21:08:47.022155 172.60.60.75.2286 > 192.168.150.2.80: P 1:3(2) ack 1 win
17520 (DF)
21:08:47.022211 192.168.150.2.80 > 172.60.60.75.2286: . ack 3 win 5840 (DF)

[-- Attachment #2: Type: text/html, Size: 7794 bytes --]

^ permalink raw reply	[flat|nested] 38+ messages in thread
* RE: forwarding
@ 2004-05-18 15:33 CPD - David Cardeñosa Rubio
  2004-05-18 15:47 ` forwarding John A. Sullivan III
  2004-05-18 15:51 ` forwarding Antony Stone
  0 siblings, 2 replies; 38+ messages in thread
From: CPD - David Cardeñosa Rubio @ 2004-05-18 15:33 UTC (permalink / raw)
  To: 'netfilter@lists.netfilter.org'

[-- Attachment #1: Type: text/plain, Size: 1930 bytes --]


HI!

if you add

iptables -t nat -A PREROUTING -d 192.168.0.1 -p tcp --dport 8080 \
    -j DNAT --to-destination 192.168.0.2:80

you need 

iptables -t nat -A POSTROUTING -s 192.168.0.2 -p tcp --dport 80 -j SNAT --to
192.168.0.1:8080

you can test the conections with tcpdump 

Un saludo

David Cardeñosa

-----Mensaje original-----
De: alucard@kanux.com [mailto:alucard@kanux.com]
Enviado el: martes, 18 de mayo de 2004 17:13
Para: netfilter@lists.netfilter.org
Asunto: Re: forwarding



> Although it probably did, are you sure nmap scanned port 8080? How about
> nmap -sT -p 8080 10.73.219.156
>
> I would then trace both the wire and the iptables rules to find out
> where it is breaking - John

Yes, it filters now but now it seems that the problem is in the 2nd server
because I try to telnet to server 1's 8080 port and I get no response. Is
it any missconfiguration on the router? take a look at this:
----
root@mail:~# nmap -sT -p 8080 10.73.219.156

Starting nmap 3.48 ( http://www.insecure.org/nmap/ ) at 2004-05-18 11:06 VET
Interesting ports on mail.aeropostal.com.ve (10.73.219.156):
PORT     STATE    SERVICE
8080/tcp filtered http-proxy
----

the webserver in server 2 is working perfectly but im not able to reach it
from server one, look at this in server 2, maybe im doing something wrong

[root@linserv root]# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use
Iface
192.168.0.0     *               255.255.255.0   U     0      0        0 eth1
10.73.216.0     *               255.255.252.0   U     0      0        0 eth0
169.254.0.0     *               255.255.0.0     U     0      0        0 eth0
127.0.0.0       *               255.0.0.0       U     0      0        0 lo
default         192.168.0.1     0.0.0.0         UG    0      0        0 eth1


Thanx a lot for this great help
Juan





[-- Attachment #2: Type: text/html, Size: 4510 bytes --]

^ permalink raw reply	[flat|nested] 38+ messages in thread
* forwarding
@ 2002-07-08  3:25 Tim
  2002-07-08  0:30 ` forwarding Antony Stone
  0 siblings, 1 reply; 38+ messages in thread
From: Tim @ 2002-07-08  3:25 UTC (permalink / raw)
  To: iptables-list

[-- Attachment #1: Type: text/plain, Size: 751 bytes --]

Well, it looks like my netfilter rules/commands are not forwarding even though I have 

--snip--
## Routing packets (traffic) between INTERNAL and DMZ
"echo "1" /proc/sys/net/ipv4/ip_forward" 
## FORWARD rules for traffic between INTERNAL and DMZ
iptables -A FORWARD -i $INTERNAL_NET -o $DMZ_NET -j ACCEPT
iptables -A FORWARD -i $DMZ_NET -o $INTERNAL_NET -j ACCEPT
--snip--

set up in the script and the rules, gentlemen any ideas? Is there something wrong with what is in these rules/commands?

Tim Rodriguez-- Mia/Fla.
Network Security Student
--
90% of networking problems are routing problems.
9 of the remaining 10% are routing problems, but in the other direction.
The final 1% might not be routing, but check it anyway.
--


[-- Attachment #2: Type: text/html, Size: 1664 bytes --]

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

end of thread, other threads:[~2005-03-26 17:48 UTC | newest]

Thread overview: 38+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-05-18 14:22 forwarding alucard
2004-05-18 14:39 ` forwarding John A. Sullivan III
2004-05-18 14:49   ` forwarding alucard
2004-05-18 14:51     ` forwarding John A. Sullivan III
2004-05-18 14:56     ` forwarding Antony Stone
2004-05-18 14:57   ` forwarding alucard
2004-05-18 14:58     ` forwarding John A. Sullivan III
2004-05-18 15:12       ` forwarding alucard
2004-05-18 15:53         ` forwarding John A. Sullivan III
2004-05-18 16:38           ` forwarding alucard
2004-05-18 17:02             ` forwarding John A. Sullivan III
2004-05-18 18:21               ` forwarding alucard
2004-05-18 18:28                 ` forwarding Antony Stone
2004-05-18 18:42                   ` forwarding alucard
2004-05-18 19:22                 ` forwarding John A. Sullivan III
2004-05-18 21:33                 ` forwarding Antony Stone
2004-05-19  4:56                   ` forwarding Juan Hernandez
2004-05-18 15:09     ` forwarding Antony Stone
2004-05-18 15:40       ` forwarding alucard
2004-05-18 15:53         ` forwarding Antony Stone
2004-05-18 14:44 ` forwarding Antony Stone
  -- strict thread matches above, loose matches on Subject: below --
2005-03-26 17:48 forwarding amir_sarbazi
2004-05-18 20:48 forwarding Daniel Chemko
2004-05-18 21:15 ` forwarding John A. Sullivan III
2004-05-18 20:33 forwarding Daniel Chemko
2004-05-18 18:23 forwarding Daniel Chemko
2004-05-18 18:42 ` forwarding Antony Stone
2004-05-18 18:50 ` forwarding alucard
2004-05-18 19:15 ` forwarding John A. Sullivan III
2004-05-18 18:04 forwarding Daniel Chemko
2004-05-18 17:04 forwarding CPD - David Cardeñosa Rubio
2004-05-18 15:33 forwarding CPD - David Cardeñosa Rubio
2004-05-18 15:47 ` forwarding John A. Sullivan III
2004-05-18 15:51 ` forwarding Antony Stone
2002-07-08  3:25 forwarding Tim
2002-07-08  0:30 ` forwarding Antony Stone
     [not found]   ` <003801c22632$521c93a0$1606d6d1@nebuchadnezza>
2002-07-08  0:53     ` forwarding Antony Stone
2002-07-08  4:03       ` forwarding Tim

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.