Chuir an t-údar i dteagmháil arís agus arís eile le gnéithe éagsúla d'oibríocht DNS i roinnt ábhar
Go dtí le déanaí, in ainneoin leochaileacht shoiléir tráchta DNS, atá fós, don chuid is mó, tarchurtha go soiléir, go gníomhartha mailíseacha ar thaobh na soláthraithe atá ag iarraidh a n-ioncam a mhéadú trí fhógraíocht a neadú in ábhar, gníomhaireachtaí slándála rialtais agus chinsireacht, chomh maith le go simplí coirpigh, an próiseas
Go fortunately, tá an scéal ag athrú. Go háirithe, forbróirí an bhrabhsálaí Firefox tóir
1. Fadhbanna DNS-thar-HTTPS
Ar an gcéad amharc, níl ach imoibriú dearfach ina chúis le tabhairt isteach mais DNS-thar-HTTPS i mbogearraí Idirlín. Mar sin féin, tá an diabhal, mar a deir siad, sna sonraí.
Is í an chéad fhadhb a chuireann teorainn le scóip úsáid fhorleathan na Roinne Sláinte ná an fócas atá aici ar thrácht gréasáin amháin. Go deimhin, is iad an prótacal HTTP agus a leagan reatha HTTP/2, ar a bhfuil an DoH bunaithe, bunús an WWW. Ach ní hé an Idirlíon amháin an gréasán. Tá go leor seirbhísí coitianta, mar shampla ríomhphost, teachtairí meandracha éagsúla, córais aistrithe comhad, sruthú ilmheán, etc., nach n-úsáideann HTTP. Mar sin, in ainneoin an dearcadh atá ag go leor de na RS mar uile-íoc, tarlaíonn sé go bhfuil sé neamh-infheidhme gan iarracht bhreise (agus neamhriachtanach) ar rud ar bith seachas teicneolaíochtaí brabhsálaí. Dála an scéil, is cosúil le DNS-over-TLS iarrthóir i bhfad níos fiúntaí don ról seo, a chuireann i bhfeidhm cuimsiú tráchta caighdeánach DNS sa phrótacal slán caighdeánach TLS.
Is í an dara fadhb, a d’fhéadfadh a bheith i bhfad níos suntasaí ná an chéad cheann, ná tréigean iarbhír dílárú dúchasach DNS de réir dearadh i bhfabhar freastalaí DoH amháin a shonraítear i socruithe an bhrabhsálaí a úsáid. Go háirithe, molann Mozilla seirbhís a úsáid ó Cloudflare. Sheol daoine mór le rá eile ar an Idirlíon, go háirithe Google, seirbhís chomhchosúil. Tarlaíonn sé nach méadaíonn cur i bhfeidhm DNS-thar-HTTPS san fhoirm ina bhfuil sé beartaithe ach spleáchas na n-úsáideoirí deiridh ar na seirbhísí is mó. Ní haon rún é gur féidir leis an bhfaisnéis is féidir le hanailís ar cheisteanna DNS a sholáthar fiú níos mó sonraí a bhailiú faoi, chomh maith lena cruinneas agus a ábharthacht a mhéadú.
I dtaca leis sin, bhí agus tá an t-údar ag tacú le cur chun feidhme mais ní DNS-thar-HTTPS, ach DNS-thar-TLS mar aon le DNSSEC/DANE mar mhodh uilíoch, slán agus nach bhfuil fabhrach do lárú breise ar an Idirlíon. chun slándáil tráchta DNS a chinntiú. Ar an drochuair, ar chúiseanna soiléire, ní féidir a bheith ag súil go dtabharfar isteach go tapa olltacaíocht do roghanna eile na Roinne Sláinte isteach i mbogearraí na gcliant, agus is é an réimse díograiseoirí teicneolaíochta slándála fós é.
Ach ós rud é go bhfuil DoH againn anois, cén fáth nach n-úsáidfeá é tar éis éalú ó fhaireachas féideartha ó chorparáidí trína bhfreastalaithe chuig ár bhfreastalaí DNS-thar-HTTPS féin?
2. Prótacal DNS-thar-HTTPS
Má fhéachann tú ar an gcaighdeán
De réir an chaighdeáin, ní thacaítear ach le HTTP/2 agus nasc slán TLS.
Is féidir iarratas DNS a sheoladh trí na modhanna caighdeánacha GET agus POST a úsáid. Sa chéad chás, déantar an t-iarratas a chlaochlú go teaghrán base64URL-ionchódaithe, agus sa dara háit, trí chorp an iarratais POST i bhfoirm dhénártha. Sa chás seo, úsáidtear cineál sonraí MIME speisialta le linn iarratais agus freagra DNS iarratas/dns-teachtaireacht.
root@eprove:~ # curl -H 'accept: application/dns-message' 'https://my.domaint/dns-query?dns=q80BAAABAAAAAAAAB2V4YW1wbGUDY29tAAABAAE' -v
* Trying 2001:100:200:300::400:443...
* TCP_NODELAY set
* Connected to eprove.net (2001:100:200:300::400) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
* CAfile: /usr/local/share/certs/ca-root-nss.crt
CApath: none
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
* TLSv1.3 (IN), TLS handshake, Finished (20):
* TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.3 (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
* ALPN, server accepted to use h2
* Server certificate:
* subject: CN=my.domain
* start date: Jul 22 00:07:13 2019 GMT
* expire date: Oct 20 00:07:13 2019 GMT
* subjectAltName: host "my.domain" matched cert's "my.domain"
* issuer: C=US; O=Let's Encrypt; CN=Let's Encrypt Authority X3
* SSL certificate verify ok.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x801441000)
> GET /dns-query?dns=q80BAAABAAAAAAAAB2V4YW1wbGUDY29tAAABAAE HTTP/2
> Host: eprove.net
> User-Agent: curl/7.65.3
> accept: application/dns-message
>
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* Connection state changed (MAX_CONCURRENT_STREAMS == 100)!
< HTTP/2 200
< server: h2o/2.3.0-beta2
< content-type: application/dns-message
< cache-control: max-age=86274
< date: Thu, 12 Sep 2019 13:07:25 GMT
< strict-transport-security: max-age=15768000; includeSubDomains; preload
< content-length: 45
<
Warning: Binary output can mess up your terminal. Use "--output -" to tell
Warning: curl to output it to your terminal anyway, or consider "--output
Warning: <FILE>" to save to a file.
* Failed writing body (0 != 45)
* stopped the pause stream!
* Connection #0 to host eprove.net left intact
Chomh maith leis sin aird a thabhairt ar an teideal rialú taisce: sa fhreagra ón bhfreastalaí gréasáin. Sa pharaiméadar aois uasta ina bhfuil an luach TTL don taifead DNS atá á thabhairt ar ais (nó an luach íosta má tá sraith díobh á thabhairt ar ais).
Bunaithe ar an méid thuas, tá roinnt céimeanna i bhfeidhmiú freastalaí DoH.
- Faigh iarratas HTTP. Más GET é seo díchódaigh an paicéad ó ionchódú base64URL.
- Seol an paicéad seo chuig an bhfreastalaí DNS.
- Faigh freagra ón bhfreastalaí DNS
- Faigh an luach íosta TTL sna taifid a fuarthas.
- Seol freagra ar ais chuig an gcliant trí HTTP.
3. Do fhreastalaí DNS-thar-HTTPS féin
Is é an bealach is simplí, is gasta agus is éifeachtaí chun do fhreastalaí DNS-thar-HTTPS féin a rith ná freastalaí gréasáin HTTP/2 a úsáid
Tacaíonn an rogha seo leis an bhfíric gur féidir cód do fhreastalaí DoH go léir a chur i bhfeidhm go hiomlán leis an ateangaire atá comhtháite le H2O féin
root@beta:~ # uname -v
FreeBSD 12.0-RELEASE-p10 GENERIC
root@beta:~ # cd /usr/ports/www/h2o
root@beta:/usr/ports/www/h2o # make extract
===> License MIT BSD2CLAUSE accepted by the user
===> h2o-2.2.6 depends on file: /usr/local/sbin/pkg - found
===> Fetching all distfiles required by h2o-2.2.6 for building
===> Extracting for h2o-2.2.6.
=> SHA256 Checksum OK for h2o-h2o-v2.2.6_GH0.tar.gz.
===> h2o-2.2.6 depends on file: /usr/local/bin/ruby26 - found
root@beta:/usr/ports/www/h2o # cd work/h2o-2.2.6/deps/
root@beta:/usr/ports/www/h2o/work/h2o-2.2.6/deps # git clone https://github.com/iij/mruby-socket.git
Клонирование в «mruby-socket»…
remote: Enumerating objects: 385, done.
remote: Total 385 (delta 0), reused 0 (delta 0), pack-reused 385
Получение объектов: 100% (385/385), 98.02 KiB | 647.00 KiB/s, готово.
Определение изменений: 100% (208/208), готово.
root@beta:/usr/ports/www/h2o/work/h2o-2.2.6/deps # ll
total 181
drwxr-xr-x 9 root wheel 18 12 авг. 16:09 brotli/
drwxr-xr-x 2 root wheel 4 12 авг. 16:09 cloexec/
drwxr-xr-x 2 root wheel 5 12 авг. 16:09 golombset/
drwxr-xr-x 4 root wheel 35 12 авг. 16:09 klib/
drwxr-xr-x 2 root wheel 5 12 авг. 16:09 libgkc/
drwxr-xr-x 4 root wheel 26 12 авг. 16:09 libyrmcds/
drwxr-xr-x 13 root wheel 32 12 авг. 16:09 mruby/
drwxr-xr-x 5 root wheel 11 12 авг. 16:09 mruby-digest/
drwxr-xr-x 5 root wheel 10 12 авг. 16:09 mruby-dir/
drwxr-xr-x 5 root wheel 10 12 авг. 16:09 mruby-env/
drwxr-xr-x 4 root wheel 9 12 авг. 16:09 mruby-errno/
drwxr-xr-x 5 root wheel 14 12 авг. 16:09 mruby-file-stat/
drwxr-xr-x 5 root wheel 10 12 авг. 16:09 mruby-iijson/
drwxr-xr-x 5 root wheel 11 12 авг. 16:09 mruby-input-stream/
drwxr-xr-x 6 root wheel 11 12 авг. 16:09 mruby-io/
drwxr-xr-x 5 root wheel 10 12 авг. 16:09 mruby-onig-regexp/
drwxr-xr-x 4 root wheel 10 12 авг. 16:09 mruby-pack/
drwxr-xr-x 5 root wheel 10 12 авг. 16:09 mruby-require/
drwxr-xr-x 6 root wheel 10 12 сент. 16:10 mruby-socket/
drwxr-xr-x 2 root wheel 9 12 авг. 16:09 neverbleed/
drwxr-xr-x 2 root wheel 13 12 авг. 16:09 picohttpparser/
drwxr-xr-x 2 root wheel 4 12 авг. 16:09 picotest/
drwxr-xr-x 9 root wheel 16 12 авг. 16:09 picotls/
drwxr-xr-x 4 root wheel 8 12 авг. 16:09 ssl-conservatory/
drwxr-xr-x 8 root wheel 18 12 авг. 16:09 yaml/
drwxr-xr-x 2 root wheel 8 12 авг. 16:09 yoml/
root@beta:/usr/ports/www/h2o/work/h2o-2.2.6/deps # cd ../../..
root@beta:/usr/ports/www/h2o # make install clean
...
Tá cumraíocht an fhreastalaí gréasáin caighdeánach go ginearálta.
root@beta:/usr/ports/www/h2o # cd /usr/local/etc/h2o/
root@beta:/usr/local/etc/h2o # cat h2o.conf
# this sample config gives you a feel for how h2o can be used
# and a high-security configuration for TLS and HTTP headers
# see https://h2o.examp1e.net/ for detailed documentation
# and h2o --help for command-line options and settings
# v.20180207 (c)2018 by Max Kostikov http://kostikov.co e-mail: [email protected]
user: www
pid-file: /var/run/h2o.pid
access-log:
path: /var/log/h2o/h2o-access.log
format: "%h %v %l %u %t "%r" %s %b "%{Referer}i" "%{User-agent}i""
error-log: /var/log/h2o/h2o-error.log
expires: off
compress: on
file.dirlisting: off
file.send-compressed: on
file.index: [ 'index.html', 'index.php' ]
listen:
port: 80
listen:
port: 443
ssl:
cipher-suite: ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS
cipher-preference: server
dh-file: /etc/ssl/dhparams.pem
certificate-file: /usr/local/etc/letsencrypt/live/eprove.net/fullchain.pem
key-file: /usr/local/etc/letsencrypt/live/my.domain/privkey.pem
hosts:
"*.my.domain":
paths: &go_tls
"/":
redirect:
status: 301
url: https://my.domain/
"my.domain:80":
paths: *go_tls
"my.domain:443":
header.add: "Strict-Transport-Security: max-age=15768000; includeSubDomains; preload"
paths:
"/dns-query":
mruby.handler-file: /usr/local/etc/h2o/h2odoh.rb
Is é an t-aon eisceacht ná an láimhseálaí URL /dns-cheist a bhfuil ár bhfreastalaí DNS-thar-HTTPS, scríofa i mruby agus glaoite tríd an rogha láimhseálaí, freagrach as i ndáiríre mruby.handler-comhad.
root@beta:/usr/local/etc/h2o # cat h2odoh.rb
# H2O HTTP/2 web server as DNS-over-HTTP service
# v.20190908 (c)2018-2019 Max Kostikov https://kostikov.co e-mail: [email protected]
proc {|env|
if env['HTTP_ACCEPT'] == "application/dns-message"
case env['REQUEST_METHOD']
when "GET"
req = env['QUERY_STRING'].gsub(/^dns=/,'')
# base64URL decode
req = req.tr("-_", "+/")
if !req.end_with?("=") && req.length % 4 != 0
req = req.ljust((req.length + 3) & ~3, "=")
end
req = req.unpack1("m")
when "POST"
req = env['rack.input'].read
else
req = ""
end
if req.empty?
[400, { 'content-type' => 'text/plain' }, [ "Bad Request" ]]
else
# --- ask DNS server
sock = UDPSocket.new
sock.connect("localhost", 53)
sock.send(req, 0)
str = sock.recv(4096)
sock.close
# --- find lowest TTL in response
nans = str[6, 2].unpack1('n') # number of answers
if nans > 0 # no DNS failure
shift = 12
ttl = 0
while nans > 0
# process domain name compression
if str[shift].unpack1("C") < 192
shift = str.index("x00", shift) + 5
if ttl == 0 # skip question section
next
end
end
shift += 6
curttl = str[shift, 4].unpack1('N')
shift += str[shift + 4, 2].unpack1('n') + 6 # responce data size
if ttl == 0 or ttl > curttl
ttl = curttl
end
nans -= 1
end
cc = 'max-age=' + ttl.to_s
else
cc = 'no-cache'
end
[200, { 'content-type' => 'application/dns-message', 'content-length' => str.size, 'cache-control' => cc }, [ str ] ]
end
else
[415, { 'content-type' => 'text/plain' }, [ "Unsupported Media Type" ]]
end
}
Tabhair faoi deara le do thoil go bhfuil an freastalaí taisce áitiúil freagrach as paicéid DNS a phróiseáil, sa chás seo
root@beta:/usr/local/etc/h2o # local-unbound verison
usage: local-unbound [options]
start unbound daemon DNS resolver.
-h this help
-c file config file to read instead of /var/unbound/unbound.conf
file format is described in unbound.conf(5).
-d do not fork into the background.
-p do not create a pidfile.
-v verbose (more times to increase verbosity)
Version 1.8.1
linked libs: mini-event internal (it uses select), OpenSSL 1.1.1a-freebsd 20 Nov 2018
linked modules: dns64 respip validator iterator
BSD licensed, see LICENSE in source package for details.
Report bugs to [email protected]
root@eprove:/usr/local/etc/h2o # sockstat -46 | grep unbound
unbound local-unbo 69749 3 udp6 ::1:53 *:*
unbound local-unbo 69749 4 tcp6 ::1:53 *:*
unbound local-unbo 69749 5 udp4 127.0.0.1:53 *:*
unbound local-unbo 69749 6 tcp4 127.0.0.1:53 *:*
Níl fágtha ach H2O a atosú agus féachaint cad a tharlóidh.
root@beta:/usr/local/etc/h2o # service h2o restart
Stopping h2o.
Waiting for PIDS: 69871.
Starting h2o.
start_server (pid:70532) starting now...
4. Tástáil
Mar sin, déanaimis na torthaí a sheiceáil trí iarratas tástála a sheoladh arís agus féachaint ar an trácht líonra ag baint úsáide as an bhfóntas tcpdump.
root@beta/usr/local/etc/h2o # curl -H 'accept: application/dns-message' 'https://my.domain/dns-query?dns=q80BAAABAAAAAAAAB2V4YW1wbGUDY29tAAABAAE'
Warning: Binary output can mess up your terminal. Use "--output -" to tell
Warning: curl to output it to your terminal anyway, or consider "--output
Warning: <FILE>" to save to a file.
...
root@beta:~ # tcpdump -n -i lo0 udp port 53 -xx -XX -vv
tcpdump: listening on lo0, link-type NULL (BSD loopback), capture size 262144 bytes
16:32:40.420831 IP (tos 0x0, ttl 64, id 37575, offset 0, flags [none], proto UDP (17), length 57, bad cksum 0 (->e9ea)!)
127.0.0.1.21070 > 127.0.0.1.53: [bad udp cksum 0xfe38 -> 0x33e3!] 43981+ A? example.com. (29)
0x0000: 0200 0000 4500 0039 92c7 0000 4011 0000 ....E..9....@...
0x0010: 7f00 0001 7f00 0001 524e 0035 0025 fe38 ........RN.5.%.8
0x0020: abcd 0100 0001 0000 0000 0000 0765 7861 .............exa
0x0030: 6d70 6c65 0363 6f6d 0000 0100 01 mple.com.....
16:32:40.796507 IP (tos 0x0, ttl 64, id 37590, offset 0, flags [none], proto UDP (17), length 73, bad cksum 0 (->e9cb)!)
127.0.0.1.53 > 127.0.0.1.21070: [bad udp cksum 0xfe48 -> 0x43fa!] 43981 q: A? example.com. 1/0/0 example.com. A 93.184.216.34 (45)
0x0000: 0200 0000 4500 0049 92d6 0000 4011 0000 ....E..I....@...
0x0010: 7f00 0001 7f00 0001 0035 524e 0035 fe48 .........5RN.5.H
0x0020: abcd 8180 0001 0001 0000 0000 0765 7861 .............exa
0x0030: 6d70 6c65 0363 6f6d 0000 0100 01c0 0c00 mple.com........
0x0040: 0100 0100 0151 8000 045d b8d8 22 .....Q...].."
^C
2 packets captured
23 packets received by filter
0 packets dropped by kernel
Léiríonn an t-aschur conas an t-iarratas chun an seoladh a réiteach example.com a fuarthas agus a phróiseáil go rathúil ag an bhfreastalaí DNS.
Níl fágtha anois ach ár bhfreastalaí a ghníomhachtú sa bhrabhsálaí Firefox. Chun seo a dhéanamh, ní mór duit roinnt socruithe a athrú ar na leathanaigh chumraíochta about: config.
Ar an gcéad dul síos, is é seo seoladh ár API ag a n-iarrfaidh an brabhsálaí faisnéis DNS isteach líonra.trr.uri. Moltar freisin an IP fearainn ón URL seo a shonrú le haghaidh réiteach IP slán ag baint úsáide as an mbrabhsálaí féin gan rochtain a fháil ar DNS isteach network.trr.bootstrapAddress. Agus ar deireadh, an paraiméadar féin líonra.trr.mód lena n-áirítear úsáid na Roinne Sláinte. Má shocraítear an luach go "3" cuirfear iallach ar an mbrabhsálaí DNS-thar-HTTPS amháin a úsáid le haghaidh réiteach ainmneacha, agus tabharfaidh an "2" níos iontaofa agus níos sláine tús áite don RS, rud a fhágfaidh an gnáthchuardach DNS mar rogha chúltaca.
5. BRABÚS!
An raibh an t-alt cabhrach? Ansin, le do thoil, ná bí cúthail agus tacaigh leis an airgead tríd an bhfoirm síntiús (thíos).
Foinse: will.com