EdgeRouter : 추가 서버의 DNS 필터링 활성화

으로 조지 발렌틴 Voina | 2015 년 10 월 18 일

댓글 0 개

모든 사람이 서버 추가를 싫어하므로 모든 PC 및 모바일 브라우저에서 AddBlock +를 사용하지만 여전히 광고 차단기를 사용하여 수행되는 추가 트래픽은 원하지 않습니다.
가장 좋은 해결책은 광고 사이트 에서 EdgeRouter Ubiquiti Networks ERLite-3 EdgeRouter Lite 를 간단히 차단하는 것 입니다. 이를위한 최선의 가이드는 다음과 같습니다.
EdgeMAX – EdgeRouter를 사용한 광고 차단 (컨텐츠 필터링)

추가 광고 서버를 보유하고 싶은 경우 (예 : 자습서의 스크립트에서 참조한 인터넷 리소스 목록에 루마니아어 광고 서버가 많이 포함되어 있지 않은 경우) 고유 한 목록을 만들어 사이트에서 호스팅 할 수 있습니다.
내 목록보기 : serverlist

내 라우터에 맞게 조정 된 자습서의 복제 된 단계를 참조하십시오.

1 단계 :
/config/user-data/update-adblock-dnsmasq.sh 파일을 만들고 다음 줄을 광고하십시오 (또는이 게시물에 첨부 된 파일을 다운로드하여 라우터의 / config / user-data 디렉토리에 복사 할 수도 있습니다). )


#!/bin/bash
ad_list_url="https://blog.voina.org/wp-content/uploads/2015/10/serverlist.txt"
#The IP address below should point to the IP of your router or to 0.0.0.0
pixelserv_ip="0.0.0.0"
ad_file="/etc/dnsmasq.d/dnsmasq.adlist.conf"
temp_ad_file="/etc/dnsmasq.d/dnsmasq.adlist.conf.tmp"
curl -s -k $ad_list_url | sed "s/127\.0\.0\.1/$pixelserv_ip/" > $temp_ad_file
if [ -f "$temp_ad_file" ]
then
#sed -i -e '/www\.favoritesite\.com/d' $temp_ad_file
mv $temp_ad_file $ad_file
else
echo "Error building the ad list, please try again."
exit
fi

/etc/init.d/dnsmasq force-reload

위 스크립트에는“#sed”로 시작하는 줄이 있습니다. 주석을 해제하고 수정하여 즐겨 찾는 사이트를 광고 차단 목록에서 제거하여 계속 지원할 수 있습니다. 원하는만큼 줄을 추가 할 수 있습니다. 한 가지 예는 다음과 같습니다.


sed -i -e '/ads\.stackoverflow\.com/d' $temp_ad_file

2 단계 :
실행 :


chmod a+x /config/user-data/update-adblock-dnsmasq.sh

스크립트를 실행 가능하게 만들기

3 단계 : /config/user-data/update-adblock-dnsmasq.sh
를 실행하여 테스트 합니다. 그러면 dnsmasq가 시작될 때마다 읽을 /etc/dnsmasq.d/dnsmasq.adlist.conf 파일이 생성됩니다.

노트 :

 

 

추가 목록에 대한 웹 자원의 대안은 내부 호스트 파일을 사용하고 sftp로 액세스하는 것입니다. 이것은 EdgeRouter 자체가 blog.voina.org 리소스를 볼 수 없기 때문에 내 설정의 솔루션이었습니다. 포트 전달이 작동하는 방식으로 인해 리소스가 숨겨져 있습니다. 목록을 업데이트하는 스크립트가 다음으로 변경됩니다.


#!/bin/bash

ad_list_url="sftp://internal_server_ip/media/storage/www/html/owncloud/wordpress/wp-content/uploads/2015/10/serverlist.txt"
#The IP address below should point to the IP of your router or to 0.0.0.0
pixelserv_ip="0.0.0.0"
ad_file="/etc/dnsmasq.d/dnsmasq.adlist.conf"
temp_ad_file="/etc/dnsmasq.d/dnsmasq.adlist.conf.tmp"
credentials="user:password"

curl -k -u $credentials $ad_list_url | sed "s/127\.0\.0\.1/$pixelserv_ip/" > $temp_ad_file

if [ -f "$temp_ad_file" ]
then
#sed -i -e '/www\.favoritesite\.com/d' $temp_ad_file
mv $temp_ad_file $ad_file
else
echo "Error building the ad list, please try again."
exit
fi
/etc/init.d/dnsmasq force-reload

새로운 광고 서버를 발견하는 가장 좋은 방법은 Ghostery Firefox 플러그인을 사용하는 것입니다. 플러그인이 찾아서 차단 한 서버를보고이를 사용자 정의 목록에 복사하십시오.

추가 서버의 두 번째 소스는 AddBlock + 플러그인으로 알 수없는 추가 서버를 차단하는 데 사용할 수 있습니다. 그런 다음 브라우저의 사용자 정의 AddBlock + 목록에서 추가 서버 이름을 복사하여 사용자 정의 목록에 추가 할 수 있습니다.

새 서버 추가가 serverlist.txt 리소스에 추가 된 후에는 EdgeRouter CLI에만 연결하고 관리자 (sudo -i)로 연결하고 /config/user-data/update-adblock-dnsmasq.sh를 다시 실행하면됩니다.

Posted by 레몬오백개