Welcome to the { mindfrost82.com } forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

Go Back   { mindfrost82.com } > Gadget Corner > Tech Newsgroups > Linux > Linux Networking

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-03-2008, 08:38 PM
=?ISO-8859-1?B?QW5kcukgSORuc2Vs?=
 
Posts: n/a
Loopback DNAT

Hi,

on a router I use

# iptables -t nat -A PREROUTING -p tcp -d 85.86.87.88 --dport 80 -j
DNAT --to-destination 10.0.0.1

to direct web traffic to an internal machine.

But when the router itself accesses 85.86.87.88:80 I get "connection
refused".
Shouldn't the "local" packet be NATed just like any other packet
coming from outside?

Regards,
André
Reply With Quote
  #2 (permalink)  
Old 07-03-2008, 11:15 PM
Pascal Hambourg
 
Posts: n/a
Re: Loopback DNAT

Hello,

André Hänsel a écrit :
>
> on a router I use
>
> # iptables -t nat -A PREROUTING -p tcp -d 85.86.87.88 --dport 80 -j
> DNAT --to-destination 10.0.0.1
>
> to direct web traffic to an internal machine.
>
> But when the router itself accesses 85.86.87.88:80 I get "connection
> refused".
> Shouldn't the "local" packet be NATed just like any other packet
> coming from outside?


No, locally generated packets don't go through the nat/PREROUTING chain.
Use the OUTPUT chain to DNAT locally initiated connections.
Reply With Quote
  #3 (permalink)  
Old 07-04-2008, 03:23 AM
=?ISO-8859-1?B?QW5kcukgSORuc2Vs?=
 
Posts: n/a
Re: Loopback DNAT

On Jul 4, 12:15*am, Pascal Hambourg <boite-a-s...@plouf.fr.eu.org>
wrote:
> Hello,
>
> André Hänsel a écrit :
>
>
>
> > on a router I use

>
> > # iptables -t nat -A PREROUTING -p tcp -d 85.86.87.88 --dport 80 -j
> > DNAT --to-destination 10.0.0.1

>
> > to direct web traffic to an internal machine.

>
> > But when the router itself accesses 85.86.87.88:80 I get "connection
> > refused".
> > Shouldn't the "local" packet be NATed just like any other packet
> > coming from outside?

>
> No, locally generated packets don't go through the nat/PREROUTING chain.
> Use the OUTPUT chain to DNAT locally initiated connections.


Thanks so far.

Could you give an overview which chains are traversed by local packets?
Reply With Quote
  #4 (permalink)  
Old 07-04-2008, 11:03 AM
Pascal Hambourg
 
Posts: n/a
Re: Loopback DNAT

[Supersedes previous message again, forgot to correct another mistake]

André Hänsel a écrit :
>
> Could you give an overview which chains are traversed by local packets?


- Locally generated packet routed through a non loopback interface :

[sending local process]
|
V
raw,mangle,nat(1),filter OUTPUT chains
|
V
mangle,nat(1) POSTROUTING chains
|
V
[output interface]

- Locally generated packet routed through the loopback interface :

[sending local process]
|
V
raw,mangle,nat(1),filter OUTPUT chains
|
V
mangle,nat(1) POSTROUTING chains
|
V
[loopback interface]
|
V
raw,mangle PREROUTING chain
|
V
mangle,filter INPUT chains
|
V
[receiving local process]

(1) Only packets creating a new connection go through the nat chains.
The trick is that a packet is not considered creating a new connection
any more after leaving the POSTROUTING chains, so when it loops back, it
does not go through the nat/PREROUTING chain.
Reply With Quote
Reply

  { mindfrost82.com } > Gadget Corner > Tech Newsgroups > Linux > Linux Networking


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

vB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 11:45 AM.


Powered by vBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
© 1999-2008 mindfrost82.com v11.0


Sponsors:
Business Credit Cards | Loans | Cheap Promotional Items | Mortgages | Libros



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114