1 (edytowany przez krystianmen 2016-02-24 18:58:01)

Temat: iptables - iprange nie działa poprawnie

Hej,
Czy to co napisałem niżej jest poprawne? Bo niestety nie jestem wstanie wykluczyć IP i zawsze blokuje mi całą pulę

iptables -t nat -I PREROUTING -m iprange ! --src-range 192.168.1.200-192.168.1.200 -p tcp --dport 53 -j REDIRECT --to-ports 53
iptables -t nat -I PREROUTING -m iprange ! --src-range 192.168.1.200-192.168.1.200 -p udp --dport 53 -j REDIRECT --to-ports 53

mam doinstalowany moduł  iptables-mod-iprange

Pozdrawiam,
Krystian

2

Odp: iptables - iprange nie działa poprawnie

! -s 192.168.1.200 po prostu. Po co korzystasz z iprange jak masz jeden adres?

Masz niepotrzebny router, uszkodzony czy nie - chętnie przygarnę go.

3

Odp: iptables - iprange nie działa poprawnie

Korzystam z tego skryptu: https://gist.github.com/teffalump/7227752 który wygenerował mi taką formę.

Chcę wykluczyć działanie Adblocka na określonym IP. Ale to co pisałem wyżej niestety nie działa, "! -s 192.168.1.200" też nie działa.

4

Odp: iptables - iprange nie działa poprawnie

Pokaż co wpisałeś i pokaż wynik iptables -v -L -t nat

Masz niepotrzebny router, uszkodzony czy nie - chętnie przygarnę go.

5

Odp: iptables - iprange nie działa poprawnie

# iptables -v -L -t nat:

Chain PREROUTING (policy ACCEPT 14945 packets, 3249K bytes)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 REDIRECT   udp  --  wlan+  any     anywhere             anywhere             source IP range ! 192.168.1.200-192.168.1.210 udp dpt:domain redir ports 53
    0     0 REDIRECT   tcp  --  wlan+  any     anywhere             anywhere             source IP range ! 192.168.1.200-192.168.1.210 tcp dpt:domain redir ports 53
14945 3249K delegate_prerouting  all  --  any    any     anywhere             anywhere            

Chain INPUT (policy ACCEPT 8372 packets, 588K bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain OUTPUT (policy ACCEPT 2381 packets, 185K bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain POSTROUTING (policy ACCEPT 240 packets, 38484 bytes)
 pkts bytes target     prot opt in     out     source               destination         
 3802  388K delegate_postrouting  all  --  any    any     anywhere             anywhere            

Chain MINIUPNPD (1 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain delegate_postrouting (1 references)
 pkts bytes target     prot opt in     out     source               destination         
 3802  388K postrouting_rule  all  --  any    any     anywhere             anywhere             /* user chain for postrouting */
  115 29940 zone_lan_postrouting  all  --  any    br-lan  anywhere             anywhere            
 3562  350K zone_wan_postrouting  all  --  any    eth0.2  anywhere             anywhere            

Chain delegate_prerouting (1 references)
 pkts bytes target     prot opt in     out     source               destination         
14945 3249K prerouting_rule  all  --  any    any     anywhere             anywhere             /* user chain for prerouting */
 3460  430K zone_lan_prerouting  all  --  br-lan any     anywhere             anywhere            
11485 2819K zone_wan_prerouting  all  --  eth0.2 any     anywhere             anywhere            

Chain postrouting_lan_rule (1 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain postrouting_rule (1 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain postrouting_wan_rule (1 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain prerouting_lan_rule (1 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain prerouting_rule (1 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain prerouting_wan_rule (1 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain zone_lan_postrouting (1 references)
 pkts bytes target     prot opt in     out     source               destination         
  115 29940 postrouting_lan_rule  all  --  any    any     anywhere             anywhere             /* user chain for postrouting */

Chain zone_lan_prerouting (1 references)
 pkts bytes target     prot opt in     out     source               destination         
 3460  430K prerouting_lan_rule  all  --  any    any     anywhere             anywhere             /* user chain for prerouting */

Chain zone_wan_postrouting (1 references)
 pkts bytes target     prot opt in     out     source               destination         
 3562  350K postrouting_wan_rule  all  --  any    any     anywhere             anywhere             /* user chain for postrouting */
 3562  350K MASQUERADE  all  --  any    any     anywhere             anywhere            

Chain zone_wan_prerouting (1 references)
 pkts bytes target     prot opt in     out     source               destination         
11485 2819K MINIUPNPD  all  --  any    any     anywhere             anywhere            
11485 2819K prerouting_wan_rule  all  --  any    any     anywhere             anywhere             /* user chain for prerouting */

6

Odp: iptables - iprange nie działa poprawnie

Nie ma tu reguły którą miałeś mieć, tylko tylko inna (nawet od tego co pokazałeś w pierwszym poście): source IP range ! 192.168.1.200-192.168.1.210

Masz niepotrzebny router, uszkodzony czy nie - chętnie przygarnę go.

7

Odp: iptables - iprange nie działa poprawnie

A bo próbowałem już wszystkich ustawień.

Po wprowadzeniu nowych ustawień muszę zawsze wykonać: /etc/init.d/firewall restart??

8

Odp: iptables - iprange nie działa poprawnie

Jeżeli dodałeś to do konfiga - tak. Jeżeli dodałeś ręcznie - nie.

Napisałeś że nie działa reguła więc pokazuj konfigi i dane po jej wprowadzeniu. Bo jak sam tam mieszasz i jest już cokolwiek innego to co mi po takich logach? Mam z kuli wróżyć dlaczego nie działa?

Masz niepotrzebny router, uszkodzony czy nie - chętnie przygarnę go.

9

Odp: iptables - iprange nie działa poprawnie

sorry za zamęt ale tak to jest jak robi się na ślepo wink

Obecny mój stan:

firewall.user

iptables -t nat -I PREROUTING ! -s 192.168.1.200 -p tcp --dport 53 -j REDIRECT --to-ports 53
iptables -t nat -I PREROUTING ! -s 192.168.1.200 -p udp --dport 53 -j REDIRECT --to-ports 53

iptables -v -L -t nat

Chain PREROUTING (policy ACCEPT 1174 packets, 182K bytes)
 pkts bytes target     prot opt in     out     source               destination         
    4   258 REDIRECT   udp  --  any    any    !192.168.1.200        anywhere             udp dpt:domain redir ports 53
    0     0 REDIRECT   tcp  --  any    any    !192.168.1.200        anywhere             tcp dpt:domain redir ports 53
 1175  182K delegate_prerouting  all  --  any    any     anywhere             anywhere            

Chain INPUT (policy ACCEPT 746 packets, 102K bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain OUTPUT (policy ACCEPT 194 packets, 13251 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain POSTROUTING (policy ACCEPT 12 packets, 1297 bytes)
 pkts bytes target     prot opt in     out     source               destination         
  497 66724 delegate_postrouting  all  --  any    any     anywhere             anywhere            

Chain MINIUPNPD (1 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain delegate_postrouting (1 references)
 pkts bytes target     prot opt in     out     source               destination         
  497 66724 postrouting_rule  all  --  any    any     anywhere             anywhere             /* user chain for postrouting */
    5   803 zone_lan_postrouting  all  --  any    br-lan  anywhere             anywhere            
  485 65427 zone_wan_postrouting  all  --  any    eth0.2  anywhere             anywhere            

Chain delegate_prerouting (1 references)
 pkts bytes target     prot opt in     out     source               destination         
 1175  182K prerouting_rule  all  --  any    any     anywhere             anywhere             /* user chain for prerouting */
 1056  155K zone_lan_prerouting  all  --  br-lan any     anywhere             anywhere            
  119 27118 zone_wan_prerouting  all  --  eth0.2 any     anywhere             anywhere            

Chain postrouting_lan_rule (1 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain postrouting_rule (1 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain postrouting_wan_rule (1 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain prerouting_lan_rule (1 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain prerouting_rule (1 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain prerouting_wan_rule (1 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain zone_lan_postrouting (1 references)
 pkts bytes target     prot opt in     out     source               destination         
    5   803 postrouting_lan_rule  all  --  any    any     anywhere             anywhere             /* user chain for postrouting */

Chain zone_lan_prerouting (1 references)
 pkts bytes target     prot opt in     out     source               destination         
 1056  155K prerouting_lan_rule  all  --  any    any     anywhere             anywhere             /* user chain for prerouting */

Chain zone_wan_postrouting (1 references)
 pkts bytes target     prot opt in     out     source               destination         
  485 65427 postrouting_wan_rule  all  --  any    any     anywhere             anywhere             /* user chain for postrouting */
  485 65427 MASQUERADE  all  --  any    any     anywhere             anywhere            

Chain zone_wan_prerouting (1 references)
 pkts bytes target     prot opt in     out     source               destination         
  119 27118 MINIUPNPD  all  --  any    any     anywhere             anywhere            
  119 27118 prerouting_wan_rule  all  --  any    any     anywhere             anywhere             /* user chain for prerouting */

pomimo to na 192.168.1.200 adblock działa

10

Odp: iptables - iprange nie działa poprawnie

Reguła działa, pakiety się łapią. Tylko - co w ogóle chciałeś tym osiągnąć robiąc przekierowanie portu 53 na ... 53?

Masz niepotrzebny router, uszkodzony czy nie - chętnie przygarnę go.

11

Odp: iptables - iprange nie działa poprawnie

Chciałem to IP dodać do wykluczeń aby na nim nie działał Adblock postawiony na routerze.

12

Odp: iptables - iprange nie działa poprawnie

Po prostu ustaw na kliencie inne serwery dns, nie 192.168.1.1.

Masz niepotrzebny router, uszkodzony czy nie - chętnie przygarnę go.

13

Odp: iptables - iprange nie działa poprawnie

Twoje rozwiązanie działa wyśmienicie! Ustawiłem DNS 8.8.8.8.

A może masz pomysł dlaczego nie działa to rozwiązanie z iptables?

14

Odp: iptables - iprange nie działa poprawnie

Bo raczej źle się do tego zabierasz - wszystko co idzie do routera na port 53 powinieneś przekierować na zewnętrzny host port 53. Choć takie rozwiązanie jest dobre, dopóki nie zostanie wymuszenie korzystania z routera.

Masz niepotrzebny router, uszkodzony czy nie - chętnie przygarnę go.

15

Odp: iptables - iprange nie działa poprawnie

Zrobiłem takie coś:

iptables -t nat -I PREROUTING -m iprange --src-range 192.168.1.200-192.168.1.210 -p tcp --dport 53 -j DNAT --to 8.8.8.8
iptables -t nat -I PREROUTING -m iprange --src-range 192.168.1.200-192.168.1.210 -p udp --dport 53 -j DNAT --to 8.8.8.8

Wygląda teraz że, jest ok. Czyli addblock nie działa na 192.168.1.200-192.168.1.210 a na pozostałych IP działa.

Dziękuję Cezary za pomoc!