Ein bisschen Technik und mehr

Schlagwort: PiHole

PiHole – Bypass – Teil 3 (menno)

Falls alle Stränge reißen, hat man über den integrierten DHCP-Server des Pi Holes noch eine weitere Variante, bestimmten Clients freien geleit ins Internet zu gewähren.

Das ganze funktioniert über die Datei:
/etc/dnsmasq.d/04-pihole-static-dhcp.conf

#dhcp-host=mac,name,ip_address (for every host in my network) 
#
dhcp-host=11:22:33:44:55:66,NAMEDESCLIENTS,192.168.1.x,set:red 
#
dhcp-option=tag:red,option:dns-server,8.8.8.8

Dort kann man direkt einen passenden DNS für jeden Client hinterlegen.

Das hat bei mir zumindest das gewünschte Ergebnis gebracht.
Nun tauchen die Clients auch gar nicht mehr in den Logs vom PI Hole auf.

Fertig!

PiHole – Bypass – Teil 2

Memo an mich:
Falls ich mal wieder stundenlang auf der Suche bin, wo ich meine Ausschlüsse, die das Pi Hole umgehen dürfen, nicht wieder finde.

Es ist hier: /etc/dnsmasq.d/05-bypass.conf

Das ganze sieht dann ungefähr so aus:

## The contents here bypass pihole by mac address

## This will go straight to Googles DNS Servers.
dhcp-option=tag:googlesdns1,6,8.8.8.8
dhcp-option=tag:googlesdns2,6,8.8.4.4

## This will go straight to Opendns Servers.
dhcp-option=tag:opendns1,6,208.67.222.220
dhcp-option=tag:opendns2,6,208.67.222.222
## OpenDNS FamilyShield
dhcp-option=tag:opendns3,6,208.67.222.123
dhcp-option=tag:opendns4,6,208.67.220.123

## Level3 DNS
dhcp-option=tag:Level3DNS1,6,4.2.2.1
dhcp-option=tag:Level3DNS2,6,4.2.2.2

## Comodo Secure DNS
dhcp-option=tag:ComodoSecureDNS,6,8.26.56.26
dhcp-option=tag:ComodoSecureDNS,6,8.20.247.20

## Norton
## P1 - malware, phishing schemes, and scams.
dhcp-option=tag:norton1,6,199.85.126.10
dhcp-option=tag:norton2,6,199.85.127.10
## P2 - Pornography
dhcp-option=tag:norton3,6,199.85.126.20
dhcp-option=tag:norton4,6,199.85.127.20
## P3 - Security + Pornography + Other
dhcp-option=tag:norton5,6,199.85.126.30
dhcp-option=tag:norton6,6,199.85.127.30

########################################################################

## Instructions
## First set your tag, and dns server.
## dhcp-option=tag:YOURTAGHERE,6,IPADDRESSOFDNSSERVER
## You then simply need to replace MA:CA:DD:R:ES:SS
## I have set up the standard DNS servertags above.
## Below are examples of how to set a mac address to bypass pihole.

## Your Device that goes to Google DNS
#dhcp-host=MA:CA:DD:R:ES:SS,set:googlesdns1

## Your Device that goes to OpenDNS
#dhcp-host=MA:CA:DD:R:ES:SS,set:opendns1

## Your Device that goes to custom DNS Server
#dhcp-host=MA:CA:DD:R:ES:SS,set:YOURTAGHERE

PiHole – Geräte Bypass

Update:

Das Vorgehen ist seit der Version 5 von PiHole nicht mehr relevant, kann und sollte also ignoriert werden!

Pro’s:

  • Pi Hole muss nicht als DHCP Server laufen
  • Ein reload vom dnsmasq ist nicht notwendig
  • Funktioniert für einzelne Geräte
  • Als Pi Hole Script verwendbar (kann beispielsweise ein Teil von piholeEnable() sein, ${3} funktioniert für PC/Mac/Mobile)

Con’s:

  • Das device caching vom Pi Hole kann Probleme verursachen

# Allow masquerading from local network
iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -j MASQUERADE

# Enable DNS redirection for device via Mac Address (FA:KE:94:60:D2:6E)
iptables -t nat -A PREROUTING -m mac --mac-source FA:KE:94:60:D2:6E -p tcp --dport 53 -j DNAT --to-destination 8.8.8.8:53
iptables -t nat -A PREROUTING -m mac --mac-source FA:KE:94:60:D2:6E -p udp --dport 53 -j DNAT --to-destination 8.8.8.8:53

OR

# Enable DNS redirection for device via IP Address (192.168.1.50)
iptables -t nat -A PREROUTING -s 192.168.1.50 -p tcp --dport 53 -j DNAT --to-destination 8.8.8.8:53
iptables -t nat -A PREROUTING -s 192.168.1.50 -p udp --dport 53 -j DNAT --to-destination 8.8.8.8:53

# Disable DNS redirection for device via Mac Address (FA:KE:94:60:D2:6E)
iptables -t nat -D PREROUTING -m mac --mac-source FA:KE:94:60:D2:6E -p tcp --dport 53 -j DNAT --to-destination 8.8.8.8:53
iptables -t nat -D PREROUTING -m mac --mac-source FA:KE:94:60:D2:6E -p udp --dport 53 -j DNAT --to-destination 8.8.8.8:53

OR

# Disable DNS redirection for device via IP Address (192.168.1.50)
iptables -t nat -A PREROUTING -s 192.168.1.50 -p tcp --dport 53 -j DNAT --to-destination 8.8.8.8:53
iptables -t nat -A PREROUTING -s 192.168.1.50 -p udp --dport 53 -j DNAT --to-destination 8.8.8.8:53

# View current rules for NAT table
iptables -L -vt nat

Präsentiert von WordPress & Theme erstellt von Anders Norén