Skip to contentSkip to conversation

REDIRECT

DISCUSSION r00t 2 participants 3 messages Dec 13, 2004 netfilter

lore
Share & tools
lore

r00t

author
#0 lore raw

Hi all,

Quoted 5 lines
Quoted 2 lines

How to i make by libipq this rule:
-j REDIRECT --to-ports 3128 ?

You don't.
REDIRECT or other NAT related operations must be done in the kernel.

Ok, but if i use this:

-A PREROUTING -p tcp -j QUEUE
-A PREROUTING -i eth1 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 3128

And in the program:

ipq_set_verdict(h, m->packet_id,NF_ACCEPT, 0, NULL);

the packet not going to second rule(REDIRECT)

Sorry to my english
Best regards, Meg

author
#1 lore raw

Hi, r00t.

Quoted 11 lines
Quoted 5 lines
Quoted 2 lines

How to i make by libipq this rule:
-j REDIRECT --to-ports 3128 ?

You don't.
REDIRECT or other NAT related operations must be done in the kernel.

Ok, but if i use this:

(quoted diff) +0 -2
-A PREROUTING -p tcp -j QUEUE
-A PREROUTING -i eth1 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 3128
Quoted 5 lines

And in the program:

ipq_set_verdict(h, m->packet_id,NF_ACCEPT, 0, NULL);

the packet not going to second rule(REDIRECT)

-A FORWARD -p tcp -j QUEUE
or
-t nat -p tcp -j QUEUE

this right by iptables, but not work

Signature · 2 lines
Best regards,
 Meg                          mailto:[email protected]
#2 lore raw
In reply to r00t

Review

Quoted 4 lines · On Mon, 13 Dec 2004, r00t wrote:

Ok, but if i use this:

(quoted diff) +0 -2
-A PREROUTING -p tcp -j QUEUE
-A PREROUTING -i eth1 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 3128

You can't. QUEUE terminates the PREROUTING hook.

You need to queue before nat PREROUTING if you want to apply NAT rules on packets after QUEUE reinjects them to the kernel, i.e. from mangle or raw tables.

Regards
Henrik