Networking Forums

Networking Forums > Computer Networking > Linux Networking > NAT issue with iptable

Reply
Thread Tools Display Modes

NAT issue with iptable

 
 
crowl@gmx.de
Guest
Posts: n/a

 
      06-21-2005, 02:49 PM
I am using iptables for nat.

iptables -t nat -A POSTROUTING -o $IFACE_EXT -j MASQUERADE

iptables -A INPUT -i $IFACE_EXT -s $myPublicIP -j ACCEPT

iptables -t nat -A PREROUTING -i $IFACE_EXT -p tcp -d $myPublicIP
--dport 443 -j DNAT --to-destination $myInternalWebserver

Issue: In the web server logs I get only the ip of myPublicIP. It seems
that nat rewrite the original ip address. The original ip of the client
is very important for the running web server application.

How can I avoid the rewrite of the original ip address?

Thanks for your help.

 
Reply With Quote
 
 
 
 
Bill Davidsen
Guest
Posts: n/a

 
      06-22-2005, 02:42 AM
(E-Mail Removed) wrote:
> I am using iptables for nat.
>
> iptables -t nat -A POSTROUTING -o $IFACE_EXT -j MASQUERADE
>
> iptables -A INPUT -i $IFACE_EXT -s $myPublicIP -j ACCEPT


You accept packets from external machines pretending to be your ext-IP?
Why? Who is sending them?
>
> iptables -t nat -A PREROUTING -i $IFACE_EXT -p tcp -d $myPublicIP
> --dport 443 -j DNAT --to-destination $myInternalWebserver
>
> Issue: In the web server logs I get only the ip of myPublicIP. It seems
> that nat rewrite the original ip address. The original ip of the client
> is very important for the running web server application.
>
> How can I avoid the rewrite of the original ip address?


Run tcpdump on all NICs, You would see this if you were using the
external NIC to talk to the "$myInternalWebserver" and using the MASQ.
>
> Thanks for your help.
>

Not much help, I don't understand the 2nd rule. But you should just
trace this all out, and display the overall packet flow to understand
what's happening.

--
bill davidsen <(E-Mail Removed)>
CTO TMR Associates, Inc
Doing interesting things with small computers since 1979
 
Reply With Quote
 
crowl@gmx.de
Guest
Posts: n/a

 
      06-22-2005, 12:32 PM
> > I am using iptables for nat.
> > iptables -t nat -A POSTROUTING -o $IFACE_EXT -j MASQUERADE
> > iptables -A INPUT -i $IFACE_EXT -s $myPublicIP -j ACCEPT

>
>
> You accept packets from external machines pretending to be your ext-IP?
> Why? Who is sending them?


Sorry for the confusion. In fact $myPublicIP is the IP range provided
by our ISP. $IFACE_EXT is eth0 and is bind to two IP addressed. One IP
from $myPublicIP and one from our private IP range 192.168.x.x.
$IFACE_EXT is in our DMZ. The machine has also a second nic which is
connected with our intranet protected by iptables. In $myPublicIP range
exist two machines we need for testing purposes. Therefore we have this
second rule. I know I have to be more specific with this rule. But this
adjustment was a quick hack for testing purposes during setup the DMZ.
I think we can neglect the second rule, because it is not important for
the original issue, isn't it? Once again, sorry for the confusion.

> > iptables -t nat -A PREROUTING -i $IFACE_EXT -p tcp -d $myPublicIP
> > --dport 443 -j DNAT --to-destination $myInternalWebserver

>
>
> > Issue: In the web server logs I get only the ip of myPublicIP. It seems
> > that nat rewrite the original ip address. The original ip of the client
> > is very important for the running web server application.

>
> > How can I avoid the rewrite of the original ip address?

>
> Run tcpdump on all NICs, You would see this if you were using the
> external NIC to talk to the "$myInternalWebserver" and using the MASQ.


I am a little bit confused about that. I have run tcpdump and see the
IP from the external client. I am not familiar with tcpdump maybe I
overlook something. But how can tcpdump help me to solve my issue (see
the IP address of the client in the logs of the webserver and in the
running applications instead of the IP of the machine itself)? Or
should tcpdump give me a clue to find the right way?

>
> > Thanks for your help.

>
> Not much help, I don't understand the 2nd rule. But you should just
> trace this all out, and display the overall packet flow to understand
> what's happening.


Thanks for your assistance.

cl

 
Reply With Quote
 
crowl@gmx.de
Guest
Posts: n/a

 
      06-22-2005, 03:17 PM
> > I am using iptables for nat.
> > iptables -t nat -A POSTROUTING -o $IFACE_EXT -j MASQUERADE
> > iptables -A INPUT -i $IFACE_EXT -s $myPublicIP -j ACCEPT

>
>
> You accept packets from external machines pretending to be your ext-IP?
> Why? Who is sending them?


Sorry for the confusion. In fact $myPublicIP is the IP range provided
by our ISP. $IFACE_EXT is eth0 and is bind to two IP addressed. One IP
from $myPublicIP and one from our private IP range 192.168.x.x.
$IFACE_EXT is in our DMZ. The machine has also a second nic which is
connected with our intranet protected by iptables. In $myPublicIP range
exist two machines we need for testing purposes. Therefore we have this
second rule. I know I have to be more specific with this rule. But this
adjustment was a quick hack for testing purposes during setup the DMZ.
I think we can neglect the second rule, because it is not important for
the original issue, isn't it? Once again, sorry for the confusion.

> > iptables -t nat -A PREROUTING -i $IFACE_EXT -p tcp -d $myPublicIP
> > --dport 443 -j DNAT --to-destination $myInternalWebserver

>
>
> > Issue: In the web server logs I get only the ip of myPublicIP. It seems
> > that nat rewrite the original ip address. The original ip of the client
> > is very important for the running web server application.

>
> > How can I avoid the rewrite of the original ip address?

>
> Run tcpdump on all NICs, You would see this if you were using the
> external NIC to talk to the "$myInternalWebserver" and using the MASQ.


I am a little bit confused about that. I have run tcpdump and see the
IP from the external client. I am not familiar with tcpdump maybe I
overlook something. But how can tcpdump help me to solve my issue (see
the IP address of the client in the logs of the webserver and in the
running applications instead of the IP of the machine itself)? Or
should tcpdump give me a clue to find the right way?

>
> > Thanks for your help.

>
> Not much help, I don't understand the 2nd rule. But you should just
> trace this all out, and display the overall packet flow to understand
> what's happening.


Thanks for your assistance.

cl

 
Reply With Quote
 
Bill Davidsen
Guest
Posts: n/a

 
      06-22-2005, 05:10 PM
(E-Mail Removed) wrote:
>>>I am using iptables for nat.
>>>iptables -t nat -A POSTROUTING -o $IFACE_EXT -j MASQUERADE
>>>iptables -A INPUT -i $IFACE_EXT -s $myPublicIP -j ACCEPT

>>
>>
>>You accept packets from external machines pretending to be your ext-IP?
>>Why? Who is sending them?

>
>
> Sorry for the confusion. In fact $myPublicIP is the IP range provided
> by our ISP. $IFACE_EXT is eth0 and is bind to two IP addressed. One IP
> from $myPublicIP and one from our private IP range 192.168.x.x.
> $IFACE_EXT is in our DMZ. The machine has also a second nic which is
> connected with our intranet protected by iptables. In $myPublicIP range
> exist two machines we need for testing purposes. Therefore we have this
> second rule. I know I have to be more specific with this rule. But this
> adjustment was a quick hack for testing purposes during setup the DMZ.
> I think we can neglect the second rule, because it is not important for
> the original issue, isn't it? Once again, sorry for the confusion.
>
>
>>>iptables -t nat -A PREROUTING -i $IFACE_EXT -p tcp -d $myPublicIP
>>>--dport 443 -j DNAT --to-destination $myInternalWebserver

>>
>>
>>>Issue: In the web server logs I get only the ip of myPublicIP. It seems
>>>that nat rewrite the original ip address. The original ip of the client
>>>is very important for the running web server application.

>>
>>>How can I avoid the rewrite of the original ip address?

>>
>>Run tcpdump on all NICs, You would see this if you were using the
>>external NIC to talk to the "$myInternalWebserver" and using the MASQ.

>
>
> I am a little bit confused about that. I have run tcpdump and see the
> IP from the external client. I am not familiar with tcpdump maybe I
> overlook something. But how can tcpdump help me to solve my issue (see
> the IP address of the client in the logs of the webserver and in the
> running applications instead of the IP of the machine itself)? Or
> should tcpdump give me a clue to find the right way?


You need to see everything at the same time, so you need two copies of
tcpdump running. Something like this:
tcpdump -i eth0 >eth0.tcpd &
tcpdump -i eth1 >eth1.tcpd &
...run your tests...
killall tcpdump
for n in eth0 eth1; do
tcpdump -r$n.tcpd -v | sed 's/ / $n /'
done | sort -n | less

That looks a bit arcane, but it allows you to see the packets in time
order, so you can tell where each packet came in, with what addresses,
and where it went out, and the results of any NAT rewriting.

You can post that info which may allow someone to see your problem sooner.
>
>
>>>Thanks for your help.

>>
>>Not much help, I don't understand the 2nd rule. But you should just
>>trace this all out, and display the overall packet flow to understand
>>what's happening.

>
>
> Thanks for your assistance.
>
> cl
>



--
bill davidsen <(E-Mail Removed)>
CTO TMR Associates, Inc
Doing interesting things with small computers since 1979
 
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
What does this IPTABLE entry mean? news@celticbear.com Linux Networking 3 11-09-2005 07:40 AM
iptable freezeup Sargon Linux Networking 1 12-15-2003 11:47 AM
Help on NetMeeting over iptable Eric Linux Networking 0 10-03-2003 10:51 AM
RFE entries in IPTABLE Rob Simac Linux Networking 2 09-25-2003 04:27 PM
iptable question Rob Simac Linux Networking 1 09-11-2003 09:46 PM



1 2 3 4 5 6 7 8 9 10 11