2020-03-29

利用免費資源 Oracle Cloud / AdGuard Home / Surge 在手機上擋廣告



最近看到 AdGuard Home 可以架 DNS Server 來擋廣告,又發現 Surge 可以改 iOS 行動網路連線的 DNS,因此想到利用 Oracle Cloud 的免費 vpc 來搭建相關服務來擋手機上的廣告。




環境準備: 

Oracle Cloud

我是採用 ubuntu 的 image, 建立完用,可以利用 ubuntu 帳號 ssh 登入去操作。



AdGuard Home

可參考『是時候裝一套 AdGuard Home 全局擋廣告神器了!』 進行設定
我的設定檔如下: 
bind_host: 0.0.0.0
bind_port: 80
users:
- name:
password:
language: ""
rlimit_nofile: 0
web_session_ttl: 720
dns:
bind_host: 0.0.0.0
port: 53
statistics_interval: 1
querylog_enabled: true
querylog_interval: 90
querylog_memsize: 0
protection_enabled: true
blocking_mode: default
blocking_ipv4: ""
blocking_ipv6: ""
blocked_response_ttl: 10
ratelimit: 60
ratelimit_whitelist: []
refuse_any: true
bootstrap_dns:
- 9.9.9.10
- 149.112.112.10
- 2620:fe::10
- 2620:fe::fe:10
all_servers: true
edns_client_subnet: false
aaaa_disabled: false
allowed_clients: []
disallowed_clients:
- 47.89.192.12
- 74.82.47.2
- 198.108.66.223
- 74.82.47.50
- 162.243.130.38
- 94.102.51.22
- 139.162.117.40
- 141.212.123.189
- 185.244.39.90
- 192.145.127.42
- 15.236.60.157
- 45.148.10.91
- 52.73.169.169
- 129.250.206.86
- 146.88.240.4
- 192.241.237.108
- 80.82.77.139
blocked_hosts: []
parental_block_host: family-block.dns.adguard.com
safebrowsing_block_host: standard-block.dns.adguard.com
cache_size: 4194304
upstream_dns:
- https://1.1.1.1/dns-query
- https://1.0.0.1/dns-query
- tls://101.101.101.101
- '[/esunbank.com.tw/]tls://101.101.101.101'
- '[/bankofamerica.com.tw/]tls://101.101.101.101'
- https://dns10.quad9.net/dns-query
- 168.95.1.1
- 168.95.192.1
- 9.9.9.9
- 8.8.8.8
filtering_enabled: true
filters_update_interval: 24
parental_enabled: false
safesearch_enabled: true
safebrowsing_enabled: false
safebrowsing_cache_size: 1048576
safesearch_cache_size: 1048576
parental_cache_size: 1048576
cache_time: 30
rewrites: []
blocked_services: []
tls:
enabled: false
server_name: ""
force_https: false
port_https: 443
port_dns_over_tls: 853
allow_unencrypted_doh: false
strict_sni_check: false
certificate_chain: ""
private_key: ""
certificate_path: ""
private_key_path: ""
filters:
- enabled: true
url: https://adguardteam.github.io/AdGuardSDNSFilter/Filters/filter.txt
name: AdGuard Simplified Domain Names filter
id: 1
- enabled: true
url: https://adaway.org/hosts.txt
name: AdAway
id: 2
- enabled: true
url: https://hosts-file.net/ad_servers.txt
name: hpHosts - Ad and Tracking servers only
id: 3
- enabled: true
url: https://www.malwaredomainlist.com/hostslist/hosts.txt
name: MalwareDomainList.com Hosts List
id: 4
- enabled: true
url: https://cdn.jsdelivr.net/gh/neoFelhz/neohosts@gh-pages/basic/hosts.txt
name: Neo Basic Hosts
id: 1584876443
- enabled: true
url: https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
name: StevenBlack
id: 1584876444
- enabled: true
url: https://raw.githubusercontent.com/CHEF-KOCH/NSABlocklist/master/HOSTS/HOSTS
name: NSABlocklist
id: 1584876445
- enabled: true
url: https://zerodot1.gitlab.io/CoinBlockerLists/hosts
name: CoinBlockerLists
id: 1584876446
- enabled: true
url: https://gitlab.com/CHEF-KOCH/cks-filterlist/raw/master/hosts/Ads-tracker.txt
name: CHEF-KOCH
id: 1584876447
- enabled: true
url: https://easylist-downloads.adblockplus.org/easylistchina.txt
name: EasyList China
id: 1584876448
- enabled: true
url: https://easylist-downloads.adblockplus.org/easyprivacy.txt
name: EasyPrivacy
id: 1584876449
- enabled: true
url: https://raw.githubusercontent.com/cjx82630/cjxlist/master/cjx-annoyance.txt
name: CJX's Annoyance List
id: 1584876450
- enabled: true
url: https://www.i-dont-care-about-cookies.eu/abp/
name: I don't care about cookies
id: 1584876451
whitelist_filters: []
user_rules: []
dhcp:
enabled: false
interface_name: ""
gateway_ip: ""
subnet_mask: ""
range_start: ""
range_end: ""
lease_duration: 86400
icmp_timeout_msec: 1000
clients: []
log_file: ""
verbose: false
schema_version: 6

Surge

  1. 設定 DNS ,指到 ubuntu 的 ip
  2. 啟動 Surge

設定完的成果

 

 

 

 

 

 

 

 

各國的 IP CIDR 格式可以參考:
https://github.com/herrbischoff/country-ip-blocks