[closed] Iptables und local redirect

Einrichten des lokalen Netzes, Verbindung zu anderen Computern und Diensten.
Antworten
debnuxer
Beiträge: 236
Registriert: 10.03.2012 12:12:21

[closed] Iptables und local redirect

Beitrag von debnuxer » 10.12.2012 12:55:53

Folgendes hatte ich eigentlich vor, aber das Redirect passiert einfach nicht:

Code: Alles auswählen

iptables -t nat -A OUTPUT -p tcp --dport 53 -m owner ! --uid-owner unbound -j REDIRECT --to-ports 53
iptables -t nat -A OUTPUT -p udp --dport 53 -m owner ! --uid-owner unbound -j REDIRECT --to-ports 53
iptables -A OUTPUT -p tcp --dport 53 -m owner --uid-owner unbound -j ACCEPT
iptables -A OUTPUT -p udp --dport 53 -m owner --uid-owner unbound -j ACCEPT

iptables -t nat -A OUTPUT -p tcp --dport 80,443,1080 -m owner ! --uid-owner privoxy -j REDIRECT --to-ports 8118
iptables -A OUTPUT -p tcp --dport 80,443,1080 -m owner --uid-owner privoxy -j ACCEPT
Das ipt_REDIRECT und ipt_owner Modul habe ich natürlich auch geladen und in der Ausgabe werden keine Fehler gemeldet.

Woran könnte das noch liegen?
Zuletzt geändert von debnuxer am 10.12.2012 20:34:34, insgesamt 2-mal geändert.
Das Leben ist wie ein überdimensionales Schachbrett.

Cae
Beiträge: 6349
Registriert: 17.07.2011 23:36:39
Wohnort: 2130706433

Re: Iptables und local redirect

Beitrag von Cae » 10.12.2012 13:08:53

"passiert einfach nicht" == Pakete gehen trotzdem nach draussen? == Pakete kommen nicht beim lokalen Ubound an? Mir ist nicht ganz klar, ob REDIRECT die Pakete dann in die INPUT-Kette schiebt (und man dort eine extra Regel braucht), oder ob sie direkt beim Interface rausfallen. Policy steht auf DROP? Vermutlich erreichst du durch Sniffen oder ein paar -j LOG-Zeilen Klaerung.

Gruss Cae
If universal surveillance were the answer, lots of us would have moved to the former East Germany. If surveillance cameras were the answer, camera-happy London, with something like 500,000 of them at a cost of $700 million, would be the safest city on the planet.

—Bruce Schneier

rendegast
Beiträge: 15041
Registriert: 27.02.2006 16:50:33
Lizenz eigener Beiträge: MIT Lizenz

Re: Iptables und local redirect

Beitrag von rendegast » 10.12.2012 13:19:49

Sollen da beliebige dns-Anfragen aus dem inneren Netz zum auf der Maschine laufenden
DNS-Server/-Cache geleitet werden?
Warum dann '-t nat -A OUTPUT'?
Eher '-t nat [-A|-I] PREROUTING -i inneres-interface'.
--dport 53 -m owner ! --uid-owner unbound -j REDIRECT --to-ports 53
Das '--to-ports' ist in dem Fall überflüssig:
REDIRECT
This target is only valid in the nat table, in the PREROUTING and OUTPUT chains, and user-
defined chains which are only called from those chains. It redirects the packet to the
machine itself by changing the destination IP to the primary address of the incoming interface
(locally-generated packets are mapped to the 127.0.0.1 address).

--to-ports port[-port]
This specifies a destination port or range of ports to use: without this, the destina‐
tion port is never altered.
This is only valid if the rule also specifies -p tcp or -p
udp.
mfg rendegast
-----------------------
Viel Eifer, viel Irrtum; weniger Eifer, weniger Irrtum; kein Eifer, kein Irrtum.
(Lin Yutang "Moment in Peking")

debnuxer
Beiträge: 236
Registriert: 10.03.2012 12:12:21

Re: Iptables und local redirect

Beitrag von debnuxer » 10.12.2012 19:36:31

Danke für die Antworten, es musste Output sein weil abgehend DNS Leaks verhindert
werden sollten.

Ausserdem ignorieren manche Browseraddons und automatische Updatefunktionen die
Proxyeinstellung im Browser.

Naja, das Redirect klappt endlich, aber beim Privoxy kommt trotzdem nichts an.

Aber das ist ein anderes Problem und gehört hier hin, deshalb erstelle ich einen neuen Threat.
Das Leben ist wie ein überdimensionales Schachbrett.

Antworten