Networking Forums

Networking Forums > Computer Networking > Linux Networking > iptables? redirect?

Reply
Thread Tools Display Modes

iptables? redirect?

 
 
M3ntos
Guest
Posts: n/a

 
      05-19-2005, 06:18 AM
Hello!

I'm trying to get all packets coming from localhost and going to a
specific host be redirected to go to my own localhost (don't know
whether I put it correctly - not native)
I've tried;
iptables -t nat -A OUTPUT -p all -d specific_ip -j REDIRECT
and:
iptables -t nat -A OUTPUT -p all -d specific_ip -j DNAT -to-destination
127.0.0.1
but they don't seem to work. I don't know what I am doing wrong

Does anyone has any idea?

Thanks in advance!

--
M3ntos
 
Reply With Quote
 
 
 
 
buzzer
Guest
Posts: n/a

 
      05-19-2005, 07:36 AM
M3ntos a écrit :
> Hello!
>
> I'm trying to get all packets coming from localhost and going to a
> specific host be redirected to go to my own localhost (don't know
> whether I put it correctly - not native)
> I've tried;
> iptables -t nat -A OUTPUT -p all -d specific_ip -j REDIRECT
> and:
> iptables -t nat -A OUTPUT -p all -d specific_ip -j DNAT -to-destination
> 127.0.0.1
> but they don't seem to work. I don't know what I am doing wrong
>
> Does anyone has any idea?
>
> Thanks in advance!
>

Hello !

There's no OUTPUT in nat !!

only PREROUTING, FORWARD and POSTROUTING !

if you want to redirect to localhost (like a transparent pop3 gateway
for antivirus) you should put your rule in PREROUTING.
don't forget to limit this rule to your localnet or to the card that's
in your lan !

Regards !

buzzer
 
Reply With Quote
 
M3ntos
Guest
Posts: n/a

 
      05-19-2005, 12:12 PM
buzzer wrote:
>> I'm trying to get all packets coming from localhost and going to a
>> specific host be redirected to go to my own localhost (don't know
>> whether I put it correctly - not native)
>> I've tried;
>> iptables -t nat -A OUTPUT -p all -d specific_ip -j REDIRECT
>> and:
>> iptables -t nat -A OUTPUT -p all -d specific_ip -j DNAT
>> -to-destination 127.0.0.1
>> but they don't seem to work. I don't know what I am doing wrong
>> Does anyone has any idea?
>> Thanks in advance!

>
> There's no OUTPUT in nat !!
>
> only PREROUTING, FORWARD and POSTROUTING !
>


??

For example:

"The NAT code allows you to insert DNAT rules in the OUTPUT chain, but
this is not fully supported in 2.4 (it can be, but it requires a new
configuration option, some testing, and a fair bit of coding, so unless
someone contracts Rusty to write it, I wouldn't expect it soon).

The current limitation is that you can only change the destination to
the local machine (e.g. `j DNAT --to 127.0.0.1'), not to any other
machine, otherwise the replies won't be translated correctly."

Some other tutorials are also talking about output in nat but not
thoroughly enough.
Besides I have 2.6. Maybe this is still a bug or something?

> if you want to redirect to localhost (like a transparent pop3 gateway
> for antivirus) you should put your rule in PREROUTING.
> don't forget to limit this rule to your localnet or to the card that's
> in your lan !


I've done it already for all (iptables -t nat -A PREROUTING -p all -d
specific_ip -j REDIRECT), because I really want to dnat to localhost all
packets going to a specific ip. But so far it only works for connections
from the local net and don't want to NAT packets from the localhost.

Any other clue?

--
M3ntos
 
Reply With Quote
 
buzzer
Guest
Posts: n/a

 
      05-20-2005, 08:16 AM
M3ntos a écrit :
> buzzer wrote:
>
> >
> > There's no OUTPUT in nat !!
> >
> >
> > only PREROUTING, FORWARD and POSTROUTING !
> >

>
> ??
>


you're right !

I do a mistake !! hook in nat are PREROUTING, POSTROUTING AND OUTPUT !
sorry !

I find a lot of match on google with your problem ! but nothing with a
solution ! It seems to be a bug in netfilter !

regards

buzzer
 
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
iptables redirect question. yozhang@gmail.com Linux Networking 1 12-09-2005 09:22 PM
Iptables {DNAT,REDIRECT} Akede Linux Networking 1 10-07-2004 03:06 AM
Iptables SSL redirect Fritz Bayer Linux Networking 6 07-20-2004 06:08 AM
iptables:redirect in an intranet? M F Linux Networking 0 11-15-2003 10:29 AM
iptables redirect = ! ipsec0 DaemonB Linux Networking 0 09-02-2003 07:23 AM



1 2 3 4 5 6 7 8 9 10 11