AdBlock med OS X Yosemite DNS Server. 
Sunday, 23 November, 22:25 - Teknologi
Konfiguration af DNS daemon foregår i /Library/Server/named/named.conf

Nederst i filen, før linien med }; indsættes include "/Library/Server/named/adList.conf"; som vist her:

       };
include "/Library/Server/named/adList.conf";
};


filen /var/named/adList.conf genereres af scriptet /usr/local/bin/getAdBloc.sh

Indhold af scriptet findes her:

#!/bin/bash

# Make sure the working directory is the same as where the script is located.
cd "$(dirname "$0")"

curl -s "http://pgl.yoyo.org/adservers/serverlist.php?hostformat=bindconfig;showintro=0;mimetype=plaintext" -o "/usr/local/bin/adList.conf"
cat adList.conf | grep ^zone > /Library/Server/named/adList.conf

serveradmin stop dns >/dev/null 2>&1
sleep 3
serveradmin start dns >/dev/null 2>&1

# script returns exit: 127 when run by launchd, without the next line !?
exit 0


Der skal bruges en fil der hedder /Library/Server/named/null.zone.file

FIlen skal indeholde dette :

; DNS NULL Zone File for host filtering
;
; - point all addresses to localhost
;

$TTL 86400 ; one day

@ IN SOA ns0.example.net. hostmaster.example.net. (
2002061000 ; serial number YYMMDDNN
28800 ; refresh 8 hours
7200 ; retry 2 hours
864000 ; expire 10 days
86400 ) ; min ttl 1 day
NS ns0.example.net.
NS ns1.example.net.
A 127.0.0.1
* IN A 127.0.0.1


For at automatisk at få opdateret AdBlock listen oprettes filen /Library/LaunchDaemons/net.update.dns.adblock.list.plist

Indhold af filen findes her:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC -//Apple Computer//DTD PLIST 1.0//EN http://www.apple.com/DTDs/PropertyList-1.0.dtd >
<plist version="1.0">
<dict>
<key>Label</key>
<string>net.update.dns.adblock.list</string>
<key>ProgramArguments</key>
<array>
<string>./getAdBloc.sh</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>5</integer>
<key>Minute</key>
<integer>0</integer>
<key>Weekday</key>
<integer>4</integer>
</dict>
<key>WorkingDirectory</key>
<string>/usr/local/bin</string>
</dict>
</plist>


FIlen loades ved hver boot, og kan loades og enables manuelt med denne kommando:

sudo launchctl load -w /Library/LaunchDaemons/net.update.dns.adblock.list.plist

Hvis det ønskes at opdateringer ikke skal køre automatisk mere bruges denne kommando:

sudo launchctl unload -w /Library/LaunchDaemons/net.update.dns.adblock.list.plist

Hold øje med datering på filen /Library/Server/named/adList.conf for at se om den opdateres som ønsket.

Referencer:
http://pgl.yoyo.org/ - - host / IP lister over reklame servere.
http://jacobsalmela.com/ - Inspiration fra et RPi projekt med samme formål.
http://launchd.info] - - launchd information
http://krypted.com/ - - OS X Yosemite Server og dns konfiguration.
tilføj kommentar ( 2108 visninger )   |  permalink   |  $star_image$star_image$star_image$star_image$star_image ( 3 / 1097 )

<<nav_first <Forrige | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | Næste> nav_last>>