1/22/18

DNS / DNSSEC Workshop

Hong Kong 22-24 January 2018

Issue Date: Revision:

Overview

• DNS Overview • BIND DNS Configuration • Recursive and Forward DNS • Reverse DNS • Troubleshooting • DNS Security Overview • DNS Transactions • DNS Security Extensions (DNSSec) • DNSSec Key Management and Automation

2

1 1/22/18

Overview

• DNS Overview • BIND DNS Configuration • Recursive and Forward DNS • Reverse DNS • Troubleshooting • DNS Security Overview • DNS Transactions • DNS Security Extensions (DNSSec) • DNSSec Key Management and Automation

3

Domain Name System

• A lookup mechanism for translating objects into other objects – Mapping names to numbers and vice versa • A globally distributed, loosely coherent, scalable, reliable, dynamic database • Comprised of three components – A “name space” – Servers making that name space available – Resolvers (clients) query the servers about the name space • A critical piece of the Internet infrastructure

4

2 1/22/18

IP Addresses vs Domain Names

The Internet

DNS

www.apnic.net202.112.0.46 2001:0400::

2001:0C00:8888::My Computer www.apnic.net2001:0400::

5

Old Solution: hosts.txt

• A centrally-maintained file, distributed to all hosts on the Internet • Issues with having just one file – Becomes huge after some time – Needs frequent copying to ALL hosts

– Consistency // hosts.txt – Always out-of-date SERVER1 128.4.13.9 WEBMAIL 4.98.133.7 – Name uniqueness FTPHOST 200.10.194.33 – Single point of administration

This feature still exists: [Unix] /etc/hosts [Windows] c:\windows\hosts

6

3 1/22/18

DNS Features

• Global distribution – Shares the load and administration • Loose Coherency – Geographically distributed, but still coherent • Scalability – can add DNS servers without affecting the entire DNS • Reliability • Dynamicity – Modify and update data dynamically

7

DNS Features

• DNS is a client-server application • Requests and responses are normally sent in UDP packets, port 53 • Occasionally uses TCP, port 53 – for very large requests, e.g. zone transfer from primary to secondary

8

4 1/22/18

Querying the DNS – It’s all about IP! Root . .tv .gov x.y.z.a .in .jp .org .net .com .au www.example.edu.au? “Ask e.f.g.h” a.b.c.d “ ” www.example.edu.auAsk a.b.c.d ? www.example.edu.au“Ask i.j.k.l” ? .edu.au e.f.g.h “Go to m.n.o.p” www.example.edu.au? www.example.edu.au“go to ? local example.edu.au m.n.o.p” dns i.j.k.l p.q.r.s

www.example.edu.au w.x.y.z. m.n.o.p

9

The DNS Tree Hierarchy Root .

net org com arpa au jp …

apnic iana net edu com edu abc gu bnu

whois www training www www www www

FQDN = Fully Qualified Domain Name

ws1 ws2

10

5 1/22/18

Domains

• Domains are “namespaces” • Everything below .com is in the com domain • Everything below apnic.net is in the apnic.net domain and in the net domain

11

Domains Root . NET Domain AU Domain

net org com arpa au

apnic iana net edu com abc def

whois www training www www www APNIC.NET Domain

ws1 ws2 www.def.edu.au?

12

6 1/22/18

Delegation

• Administrators can create subdomains to group hosts – According to geography, organizational affiliation or any other criterion • An administrator of a domain can delegate responsibility for managing a subdomain to someone else – But this isn’t required • The parent domain retains links to the delegated subdomain – The parent domain “remembers” to whom the subdomain is delegated

13

Zones and Delegations

• Zones are “administrative spaces” • Zone administrators are responsible for a portion of a domain’s name space • Authority is delegated from parent to child

14

7 1/22/18

Zones Root . NET Domain

NET Zone net org com arpa

apnic iana APNIC.NET Zone

whois www training www

TRAINING.APNIC.NET Zone APNIC.NET Zone doesn’t APNIC.NET include TRAINING.APNIC.NET since it has been “delegated” Domain ns1 ns2

15

Name Servers

• Name servers answer ‘DNS’ questions • Several types of name servers – Authoritative servers Primary • master (primary) • slave (secondary) – Caching or recursive servers • also caching forwarders • Mixture of functions

Secondary

16

8 1/22/18

Root Servers

• The top of the DNS hierarchy

• There are 13 root name servers operated around the world [a-m].root-servers.net

• There are more than 13 physical root name servers – Each rootserver has an instance deployed via anycast

17

Root Servers

http://root-servers.org/

18

9 1/22/18

Root Server Deployment at APNIC

• Started in 2002, APNIC is committed to establish new root server sites in the AP region • APNIC assists in the deployment providing technical support. • Deployments of F, K and I-root servers in – Singapore, Hong Kong, China, Korea, Thailand, Malaysia, Indonesia, Philippines, Fiji, Pakistan, Bangladesh, Taiwan, Cambodia, Bhutan, and Mongolia

19

Resolver

• Or “stub” resolver • A piece of software (usually in the ) which formats the DNS request into UDP packets • A stub resolver is a minimal resolver that forwards all requests to a local recursive nameserver – The IP address of the local DNS server is configured in the resolver. • Every host needs a resolver – In , it uses /etc/resolv.conf • It is always a good idea to configure more than one nameserver

20

10 1/22/18

Recursive Nameserver

• The job of the recursive nameserver is to locate the authoritative nameserver and get back the answer • This process is iterative – starts at the root • Recursive servers are also usually caching servers • Prefer a nearby cache – Minimizes latency issues – Also reduces traffic on your external links • Must have permission to use it – Your ISP’s nameserver or your own

Recursive/Caching Nameserver

21

Authoritative Nameserver • A nameserver that is authorised to provide an answer for a particular domain – Can be more than one auth nameserver • Two types based on management method: – Primary (Master) and Secondary (Slave) • Only one primary nameserver – All changes to the zone are done in the primary • Secondary nameserver/s will retrieve a copy of the zonefile from the primary server – Slaves poll the master periodically Secondary • Primary server can “notify” the slaves

Primary Secondary

22

11 1/22/18

Resource Records

• Entries in the DNS zone file • Components:

Resource Record Function Label Name substitution for FQDN TTL Timing parameter, an expiration limit Class IN for Internet, CH for Chaos Type RR Type (A, AAAA, MX, PTR) for different purposes RDATA Anything after the Type identifier; Additional data

23

Common Resource Record Types

RR Type Name Functions A Address record Maps domain name to IP address www.example.com. IN A 192.168.1.1 AAAA IPv6 address record Maps domain name to an IPv6 address www.example.com. IN AAAA 2001:db8::1 NS Name server record Used for delegating zone to a nameserver example.com. IN NS ns1.example.com.

PTR Pointer record Maps an IP address to a domain name 1.1.168.192.in-addr.arpa. IN PTR www.example.com. CNAME Canonical name Maps an alias to a hostname web IN CNAME www.example.com. MX Mail Exchanger Defines where to deliver mail for user @ domain example.com. IN MX 10 mail01.example.com. IN MX 20 mail02.example.com.

24

12 1/22/18

Example: RRs in a zone file

apnic.net. 7200 IN SOA ns.apnic.net. admin.apnic.net. ( 2015050501 ; Serial 12h ; Refresh 12 hours 4h ; Retry 4 hours 4d ; Expire 4 days 2h ; Negative cache 2 hours )

apnic.net. 7200 IN NS ns.apnic.net. apnic.net. 7200 IN NS ns.ripe.net. www.apnic.net. 3600 IN A 192.168.0.2 www.apnic.net 3600 IN AAAA 2001:DB8::2

Label TTL Class Type Rdata

25

Places where DNS data lives

Changes do not propagate instantly

Might take up to ‘refresh’ Slave to get data from master

Upload of zone Not going to net if TTL>0 data is local policy

Cache server

Master

Slave server Registry DB

26

13 1/22/18

Delegating a Zone

• Delegation is passing of authority for a subdomain to another party • Delegation is done by adding NS records – Ex: if APNIC.NET wants to delegate TRAINING.APNIC.NET

training.apnic.net. NS ns1.training.apnic.net. training.apnic.net. NS ns2.training.apnic.net.

• Now how can we go to ns1 and ns2? – We must add a Glue Record

27

Glue Record

• Glue is a ‘non-authoritative’ data • Don’t include glue for servers that are not in the sub zones

Only this record needs glue

training.apnic.net. NS ns1.training.apnic.net. training.apnic.net. NS ns2.training.apnic.net.

training.apnic.net. NS ns2.example.net. Glue training.apnic.net. NS ns1.example.net. Record ns1.training.apnic.net. A 10.0.0.1 ns2.training.apnic.net. A 10.0.0.2

28

14 1/22/18

Delegating training.apnic.net. from apnic.net.

ns.apnic.net ns.training.apnic.net

1. Add NS records and glue 1. Setup minimum two servers 2. Make sure there is no other data 2. Create zone file with NS records from the training.apnic.net. zone in 3. Add all training.apnic.net data the zone file

29

Remember ...

• Deploy multiple authoritative servers to distribute load and risk – Put your name servers apart from each other

• Use cache to reduce load to authoritative servers and response times

• SOA timers and TTL need to be tuned to the needs of the zone – For stable data, use higher numbers

30

15 1/22/18

Performance of DNS

• Server hardware requirements • OS and the DNS server running • How many DNS servers? • How many zones are expected to load? • How large are the zones? • Zone transfers • Where are the DNS servers located? • Bandwidth

31

Performance of DNS

• Are these servers Multihomed? • How many interfaces are to be enabled for listening? • How many queries are expected to receive? • Recursion • Dynamic updates • DNS notifications

32

16 1/22/18

33

Overview

• DNS Overview • BIND DNS Configuration • Recursive and Forward DNS • Reverse DNS • Troubleshooting • DNS Security Overview • DNS Transactions • DNS Security Extensions (DNSSec) • DNSSec Key Management and Automation

34

17 1/22/18

DNS Software

• DNS BIND – authoritative + recursive server • Unbound - caching DNS resolver • NSD – authoritative only nameserver • Microsoft DNS – provided with the Windows Server • Knot DNS – authoritative only nameserver • PowerDNS – data storage backends

35

BIND

• Berkeley Internet Name Domain • The most widely-used open source DNS software on the Internet – Current version is Bind 9.10.4-P2 – Bind 9.9.9 is also current with Extended Support – Bind 9.8.x EOL as of Sep 2014 • Maintained by the Internet Systems Consortium (ISC) • Bind 10 is in development – New architecture – Bind 10.1.1 released on June 06 2013 – Has been concluded and renamed as Bundy (http://bundy-dns.de/)

36

18 1/22/18

Where to Get BIND

• Download source from the ISC website – http://www.isc.org – ftp://ftp.isc.org/isc/bind9 • Install from your distribution’s package manager • Some packages may also be required – OpenSSL is a necessary for DNSSEC

37

Unpacking BIND9

• When installing BIND from source, decompress the gzip file tar xvfz bind-9..tar.gz cd bind-9.

• What's in there? – A lot of stuff (dig, libraries, etc) – Configure scripts – Administrator's Reference Manual (ARM)

38

19 1/22/18

Building BIND9 from Source

• must be in the BIND 9 directory • Determine the appropriate includes and compiler settings ./configure --with-openssl • Build and compile make • Install the BIND package make install • Verify the installation which named named -v

39

Building BIND9 with Package Manager • Redhat/CentOS

yum –y install bind9

• Ubuntu / Debian

apt-get install bind9

40

20 1/22/18

Location of Executables

/usr/local/sbin – named – dnssec-keygen, dnssec-makekeyset, dnssec-signkey, dnssec- signzone – lwresd, named-checkconf, named-checkzone – rndc, rndc-confgen

/usr/local/bin – dig – host, isc-config.sh, nslookup – nsupdate

41

Named Configuration

• The BIND configuration file is called “named.conf” – Default location is in /etc/named.conf – Run named with –c option to specify a different location • Defines the zones and points to the corresponding zonefile • Defines global options • Logging can be turned on for troubleshooting

42

21 1/22/18

Named Configuration

• BIND Configuration file

• Options statement contains all global configuration options to be used as defaults by named. options { directory “/var/named/recursive”; };

• Zone statement defines the zones and any zone-specific option zone “myzone.net” { type master; file “db.myzone.net”; };

43

Root Hints

• Pointer to the root servers • Root hints file come in many names – db.cache, named.root, named.cache, named.ca • Get it from ftp://ftp.rs.internic.net/domain/ • Defined as follows in the config file zone “.” { type hint; file “root.hints”; };

44

22 1/22/18

What it looks like ftp://ftp.rs.internic.net/domain/

. 3600000 IN NS A.ROOT-SERVERS.NET. A.ROOT-SERVERS.NET. 3600000 A 198.41.0.4 A.ROOT-SERVERS.NET. 3600000 AAAA 2001:503:BA3E::2:30 ; operated by WIDE . 3600000 NS M.ROOT-SERVERS.NET. M.ROOT-SERVERS.NET. 3600000 A 202.12.27.33 M.ROOT-SERVERS.NET. 3600000 AAAA 2001:dc3::35

45

Configuring a Recursive Server

• The recursive server needs to know how to reach the top of the DNS hierarchy • It should also stop some queries such as those for localhost (127.0.0.1) • The following files are required to run a recursive/caching server: – named.conf – root.hints – localhost zone (db.localhost) – 0.0.127.in-addr.arpa zone (db.127.0.0.1) – ::1 IPv6 reverse zone (db.ip6)

46

23 1/22/18

Zones in a Recursive Server

• Loopback name in operating systems – Queries for this shouldn't use recursion – Configure a file to define the localhost zone – Localhost will map to 127.0.0.1 and ::1

zone “localhost” { type master; file db.localhost; };

• Reverse zone for the loopback – maps 127.0.0.1 (and ::1) to localhost

zone “0.0.127.in-addr.arpa” { type master; file db.127.0.0.1; };

47

Zones in a Recursive Server

• Reverse zone for IPv6 link-local address zone “8.B.D.0.1.0.0.2.ip6.arpa” { type master; file db.2001.db8; };

• Built-in empty zones will be created for RFC 1918, RFC 4193, RFC 5737 and RFC 6598

https://tools.ietf.org/html/rfc6303

48

24 1/22/18

Example named.conf options { zone "0.0.127.in-addr.arpa." { directory type master; "/var/named/recursive"; file ”db.127"; recursion yes; }; }; zone "." { zone "8.B.D.0.1.0.0.2.ip6.arpa." { type hint; type master; file "named.root"; file ”db.2001.db8"; }; }; zone "localhost." { type master; file "localhost"; };

49

Zone Files

• Contain the resource records defined in a particular zone • begins with a Start of Authority Record (SOA) @ SOA localhost. root.localhost. ( 20150505 ;serial no. 30m ;refresh 15m ;retry 1d ;expire 30m ;negative cache ttl ) • Common Zone File directives – $ORIGIN – $INCLUDE – $TTL – @ represents the current origin

50

25 1/22/18

Start of Authority (SOA) record

Domain_name. CLASS SOA hostname.domain.name. mailbox.domain.name ( Serial Number Refresh Retry Expire Minimum TTL )

• Serial Number – must be updated if any changes are made in the zone file • Refresh – how often a secondary will poll the primary server to see if the serial number for the zone has increased • Retry - If a secondary was unable to contact the primary at the last refresh, wait the retry value before trying again • Expire - How long a secondary will still treat its copy of the zone data as valid if it can't contact the primary. • Minimum TTL - The default TTL (time-to-live) for resource records

51

TTL Time Values

• The right value depends on your domain • Recommended time values for TLD (based on RFC 1912) Refresh 86400 (24h) Retry 7200 (2h) Expire 2592000 (30d) Min TTL 345600 (4d) • For other servers – optimize the values based on – Frequency of changes – Required speed of propagation – Reachability of the primary server – (and many others)

52

26 1/22/18

localhost zonefile

$TTL 86400 @ IN SOA localhost. root.localhost. ( 20150505 ; serial 1800 ; refresh 900 ; retry 69120 ; expire 1080 ; negative ttl ) NS localhost. A 127.0.0.1 AAAA ::1

53

0.0.127.in-addr.arpa zonefile

$TTL 86400 @ IN SOA localhost. root.localhost. ( 20150505 ; serial 1800 ;refresh 900 ;retry 69120 ;expire 1080 ;negative ttl )

NS localhost. 1 PTR localhost.

54

27 1/22/18

ip6.arpa zonefile

$TTL 86400 @ IN SOA localhost. root.localhost. ( 20150505 ; serial 1800 ;refresh 900 ;retry 69120 ;expire 1080 ;negative ttl )

NS localhost. 1 PTR localhost.

55

Assembling the files

• Create a directory in /var/named/ and copy the files

# mkdir recursive # ls 0.0.127.in-addr.arpa db.localhost root.hints

• The directory name and file names will be defined in named.conf • Now create a named.conf file in the same directory

56

28 1/22/18

Running the server

• From the directory

named -g -c named.conf

where: -c path to the configuration file -g run in the foreground

57

Testing the server

% dig @127.0.0.1 www.google.com

; <<>> DiG 9.8.3-P1 <<>> www.google.com ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 213 ;; flags: qr rd ra; QUERY: 1, ANSWER: 5, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION: ;www.google.com. IN A

;; ANSWER SECTION: www.google.com. 156 IN A 74.125.237.115 www.google.com. 156 IN A 74.125.237.113 www.google.com. 156 IN A 74.125.237.116 www.google.com. 156 IN A 74.125.237.114 www.google.com. 156 IN A 74.125.237.112

;; Query time: 27 msec ;; SERVER: 127.0.0.1#53(203.119.98.119) ;; WHEN: Thu Jul 11 13:46:29 2013 ;; MSG SIZE rcvd: 112

58

29 1/22/18

59

Overview

• DNS Overview • BIND DNS Configuration • Recursive and Forward DNS • Reverse DNS (for IPv4) • Troubleshooting • DNS Security Overview • DNS Transactions • DNS Security Extensions (DNSSec) • DNSSec Key Management and Automation

60

30 1/22/18

What is ‘Reverse DNS’?

• ‘Forward DNS’ maps names to numbers – svc00.apnic.net è192.168.1.100 – svc00.apnic.net è2001:DB8::1

• ‘Reverse DNS’ maps numbers to names – 192.168.1.100 è svc00.apnic.net – 2001:DB8::1 è svc00.apnic.net

Person (Host) Address (IPv4/IPv6)

61

Reverse DNS - why bother?

• Service denial – only allow access when fully reverse delegated – Example: anonymous ftp • Diagnostics – Used in tools such as traceroute • Spam identifications – Failed reverse lookup results in a spam penalty score • Registration responsibilities – APNIC members must make sure that all their address space are properly reverse delegated

62

31 1/22/18

Principles – DNS Tree Root . Mapping numbers to names - ‘reverse DNS’

net org com arpa

apnic iana in-addr

202 203 204 210 whois www training www 64

22 22. 64. 202. in-addr.arpa. ws1 ws2

63

Creating Reverse Zones

• Same as creating a forward zone file – SOA and initial NS records are the same as forward zone • Create additional PTR records • In addition to the forward zone files, you need the reverse zone files – Ex: for a reverse zone on a 203.176.189.0/24 block, create a zone file and name it as “db.203.176.189” (make it descriptive)

64

32 1/22/18

Pointer (PTR) Records

• Create pointer (PTR) records for each IP address

131.28.12.202.in-addr.arpa. IN PTR svc00.apnic.net.

or

131 IN PTR svc00.apnic.net.

65

Reverse Zone Example

$ORIGIN 1.168.192.in-addr.arpa.

@ 3600 IN SOA test.company.org. (

sys\.admin.company.org.

2002021301 ; serial

1h ; refresh

30M ; retry

1W ; expiry

3600 ) ; neg. answ. ttl

NS ns.company.org.

NS ns2.company.org.

1 PTR gw.company.org. router.company.org.

2 PTR ns.company.org.

66

33 1/22/18

Reverse Delegation

• /24 Delegations – Address blocks should be assigned or allocated – At least two name servers

• /16 Delegations – Same as /24 delegations – APNIC delegates entire zone to member

• < /24 Delegations – Read “Classless IN-ADDR.ARPA delegation” (RFC 2317)

67

APNIC & LIR Responsibilities

• APNIC – Manage reverse delegations of address block distributed by APNIC – Process requests for reverse delegation of network allocations

• LIR and members – Be familiar with APNIC procedures – Ensure that addresses are reverse-mapped – Maintain nameservers for allocations – Minimize pollution of DNS

68

34 1/22/18

Reverse Delegation Procedures

• Create a whois object for the reverse zone – This can be done in MyAPNIC • Verify nameserver and domain set up before submitting to the database • Provide the FQDN of two nameservers • Provide the maintainer password – Used to protect objects

69

Reverse Delegation Procedures

70

35 1/22/18

Whois domain object

Reverse Zone domain: 28.12.202.in-addr.arpa Descr: in-addr.arpa zone for 28.12.202.in-addr.arpa admin-c: NO4-AP tech-c: AIC1-AP Contacts zone-c: NO4-AP nserver: cumin.apnic.net Nameservers nserver: tinnie.apnic.net nserver: tinnie.arin.net mnt-by: MAINT-APNIC-AP Maintainers mnt-lower: MAINT-AP-DNS changed: [email protected] 20021023 changed: [email protected] 20040109 changed: [email protected] 20091007 changed: [email protected] 20111208 source: APNIC

71

Overview

• DNS Overview • BIND DNS Configuration • Recursive and Forward DNS • Reverse DNS (for IPv6) • Troubleshooting • DNS Security Overview • DNS Transactions • DNS Security Extensions (DNSSec) • DNSSec Key Management and Automation

72

36 1/22/18

Reverse DNS Tree – with IPv6 Root .

net org com arpa

apnic iana in-addr ip6

202 203 IPv6 addresses

64

22

73

IPv6 Representation in the DNS

• Forward lookup support: Multiple RR records for name to number – AAAA (Similar to A RR for IPv4 )

• Reverse lookup support: – Reverse nibble format for zone ip6.arpa

74

37 1/22/18

IPv6 Reverse Lookups – PTR records

• Similar to the IPv4 reverse record b.a.9.8.7.6.5.0.4.0.0.0.3.0.0.0.2.0.0.0.1.0.0.0.0.0.0.0.1.2.3.4.ip6.arpa. IN PTR test.ip6.example.com.

• Example: The reverse name lookup for a host with address 3ffe:8050:201:1860:42::1

$ORIGIN 0.6.8.1.1.0.2.0.0.5.0.8.e.f.f.3.ip6.arpa. 1.0.0.0.0.0.0.0.0.0.0.0.2.4.0.0 14400 IN PTR host.example.com.

75

IPv6 Forward and Reverse Mappings

• Existing A record will not accommodate the 128 bit addresses for IPv6 • BIND expects an A record data to be 32-bit address (in dotted-octet format) • An address record – AAAA (RFC 1886) • A reverse-mapping domain – ip6.arpa

76

38 1/22/18

IPv6 Forward Lookups

• Multiple addresses possible for any given name – Ex: in a multi-homed situation • Can assign A records and AAAA records to a given name/domain • Can also assign separate domains for IPv6 and IPv4

77

Example: Forward Zone

;; domain.edu

$TTL 86400

@ IN SOA ns1.domain.edu. root.domain.edu. (

2015050501 ; serial - YYYYMMDDXX

21600 ; refresh - 6 hours

1200 ; retry - 20 minutes

3600000 ; expire - long time

86400) ; minimum TTL - 24 hours

;; Nameservers

IN NS ns1.domain.edu.

IN NS ns2.domain.edu.

;; Hosts with just A records host1 IN A 1.0.0.1

;; Hosts with both A and AAAA records host2 IN A 1.0.0.2

IN AAAA 2001:468:100::2

78

39 1/22/18

Example: Reverse Zone

;; 0.0.0.0.0.0.1.0.8.6.4.0.1.0.0.2.rev ;; These are reverses for 2001:468:100::/64) ;; File can be used for both ip6.arpa and ip6.int. $TTL 86400 @ IN SOA ns1.domain.edu. root.domain.edu. ( 2015050501 ; serial - YYYYMMDDXX 21600 ; refresh - 6 hours 1200 ; retry - 20 minutes 3600000 ; expire - long time 86400) ; minimum TTL - 24 hours ;; Nameservers IN NS ns1.domain.edu. IN NS ns2.domain.edu. 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0 IN PTR host1.ip6.domain.edu 2.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0 IN PTR host2.domain.edu

79

80

40 1/22/18

Overview

• DNS Overview • BIND DNS Configuration • Recursive and Forward DNS • Reverse DNS • Troubleshooting and ACL • DNS Security Overview • DNS Transactions • DNS Security Extensions (DNSSec) • DNSSec Key Management and Automation

81

Why Troubleshoot?

• What Can Go Wrong? – Misconfigured zone – Misconfigured server – Misconfigured host – Misconfigured network

82

41 1/22/18

Tools

• BIND Logging Facility • named's built-in options • ping and traceroute • tcpdump and wireshark • dig and nslookup

83

The Best Way To Handle Mistakes

• Assume You Will Make Them • Prepare The Name Server via Logging

84

42 1/22/18

BIND Logging

• Telling named which messages to send – category specification • Telling named where to send messages – channel specification

85

BIND channels

• BIND can use syslog • BIND can direct output to other files

channel my_dns_log { file "seclog" versions 3 size 10m; print-time yes; print-category yes; print-severity yes; severity debug 3; };

86

43 1/22/18

BIND Categories

• BIND has many categories • Short descriptions of each can be found in the Administrator's Reference Manual (ARM)

category queries { my_dns_log; };

87

So You've Set Up A Server

• What tests should be done? • Test if the server up – Is the (right) server running? – Is the machine set up correctly? • Test if data is being served – Has the zone loaded? – Have zone transfers happened?

88

44 1/22/18

Checking the Configuration

• To see named start, use the -g flag – Keeps named process in the foreground – Prints some diagnostics – But does not execute logging

• When satisfied (i.e. no errors), kill the process and start without –g flag to run in the background

• Other option – % named-checkconf (check for syntax only)

89

Is the Server Running?

• Make sure the server is running – dig @127.0.0.1 version.bind chaos txt • This makes the name server do the simplest lookup it can - its version string • This also confirms which version you started – Common upgrade error: running the old version

90

45 1/22/18

Is the Server Data Correct?

• Check the serial number to make sure the zone has loaded

dig @127.0.0.1 soa

• Also test changed data in case you forgot to update the serial number • In the secondary server, this check is made to see if the zone transferred

91

Is the Server Reachable?

• If the dig tests fail, its time to test the environment (machine, network)

ping

• This tests basic network flow, common errors – Network interface not UP – Routing to machine not correct

• Pinging locally is useful – Confirms that the IP address is correctly configured

92

46 1/22/18

Is the Server Listening?

• If the server does not respond, but machine responds to ping – look at system log files – telnet server 53 – firewall running?

• Server will run even if it can't open the network port – logs will show this – telnet opens a TCP connection, tests whether port was opened at all

93

Using the Tools

• named itself • Dig or nslookup • host diagnostics • packet sniffers

94

47 1/22/18

Built in to named

• named -g to retain command line named -g -c

• named -d – sets the debug output volume – 's aren't strictly defined – -d 3 is popular, -d 99 gives a lot of detail

95

dig

• domain internet groper • best tool for testing • shows query and response syntax • Included in the software

96

48 1/22/18

Flags Flags Meaning AA Authoritative answer RD Recursion desired RA Recursion Available AD Authenticated Data (DNSSEC only) CD

Status Response Code 0 - NOERR No error 1 - FORMERR Format error 2 - SERVFAIL Nameserver unreachable 3 - NXDOMAIN Domain name not existing 4 - NOTIMPL Not implemented 5 - REFUSED Request refused

97

Non-BIND Tools

• Tools to make sure the environment is right – Tools to look at server machine – Tools to test network – Tools to see what messages are on the network

98

49 1/22/18

ifconfig

• Interface configuration ifconfig -a

• An operating system utility that shows the status of interfaces • Warning, during boot up, ifconfig may configure interfaces after named has started – named can't open delayed addresses

99

ping

• Checks routing, machine health – Most useful if run from another host – Could be reason "no servers are reached" – Can be useful on local machine - to see if the interface is properly configured

100

50 1/22/18

traceroute

• If ping fails, traceroute can help pinpoint where trouble lies – the problem may be routing – if so - it's not named that needs fixing! – but it is important to know

101

tcpdump and wireshark

• Once confident in the environment, problems with DNS setup may exist • To see what is happening in the protocol, use traffic sniffers • These tools can help debug "forwarding" of queries

102

51 1/22/18

103

Overview

• DNS Overview • BIND DNS Configuration • Recursive and Forward DNS • Reverse DNS • Troubleshooting and ACL • DNS Security Overview • DNS Transactions • DNS Security Extensions (DNSSec) • DNSSec Key Management and Automation

104

52 1/22/18

Address Match List

• Elements: – Individual IP addresses – Addresses or netmask pairs – Names of other ACLs – Key names

• Used for: – Restricting queries & zone xfer – Authorizing dynamic updates – Selecting interfaces to listen on – Sorting responses

105

Notes on Address Match list

• Elements must be separated by “ ; ” • The list must be terminated with a “ ; ” • Elements of the address match list are checked sequentially • To negate elements of the address match list prepend them with “!” • Use acl statement to name an address match list • ACL must be defined before it can be used elsewhere

106

53 1/22/18

Example: Address match lists

• For network 192.168.0.0 255.255.255.0 { 192.168.0.0/24; }

• For network plus loopback { 192.168.0.0/24; 127.0.0.1; ::1; }

• Addresses plus key name { 192.168.0.0/24; 127.0.0.1; example.com;}

107

ACL Statement

• Syntax: acl { address match list>};

• Example:

acl internal { 127.0.0.1; 192.168.0/24; }; acl dynamic-update { key dhcp.apnic.net; };

108

54 1/22/18

Notes on ACL Statement

• The ACL name need not be quoted

• There are four predefined ACLs: – any (Any IP address) – none (No IP address) – localhost (loopback, 127.0.0.1) – localnets (all networks that is directly connected to the server)

109

Blackhole options { blackhole { ACL-name or itemized list; }; };

110

55 1/22/18

Allow-transfer zone "myzone.example." { type master; file "myzone.example."; allow-transfer { ACL-name or itemized list; }; };

111

Allow-Query zone "myzone.example." { type master; file "myzone.example."; allow-query { ACL-name or itemized list; }; };

112

56 1/22/18

Listen-on options { listen-on port # { ACL- name or itemized list;}; };

113

Masters masters name { masters_list | ip_addr };

Ex: masters nsX { 192.168.0.1; 2001:db8::1 ; }; zone “example.com” { type slave; masters { nsX; }; file “/link/to/db.example.com”; };

114

57 1/22/18

Summary

• ACLs and Configuration options can be used to create simple split DNS • It is cumbersome and difficult to maintain • Good operational practice suggests that ACLs and configuration options be reviewed regularly to ensure that they accurately reflect the desired behavior

115

Views

• a powerful new feature of BIND 9 that lets a name server answer a DNS query differently depending on who is asking • useful for implementing split DNS setup without having to run multiple servers

116

58 1/22/18

Views view view_name [class] { match-clients { address_match_list } ; match-destinations { address_match_list } ; match-recursive-only yes_or_no ; [ view_option; ...] [ zone_statement; ...] };

117

Example Config view "internal" { // This should match our internal networks. match-clients { 10.0.0.0/8; }; // Provide recursive service to internal clients only. recursion yes; // Provide a complete view of the example.com zone // including addresses of internal hosts. zone "example.com" { type master; file "example-internal.db"; }; };

118

59 1/22/18

Example Config (2) view "external" { // Match all clients not matched by the previous view. match-clients { any; };

// Refuse recursive service to external clients. recursion no;

// Provide a restricted view of the example.com zone // containing only publicly accessible hosts. zone "example.com" { type master; file "example-external.db"; }; };

119

120

60 1/22/18

Overview

• DNS Overview • BIND DNS Configuration • Recursive and Forward DNS • Reverse DNS • Troubleshooting • DNS Security Overview • DNS Transactions • DNS Security Extensions (DNSSec) • DNSSec Key Management and Automation

121

Crypto Review

• Most security applications use crypto algorithms – Symmetric key – Public key crypto – One-way hash functions

122

61 1/22/18

Symmetric Key Crypto

• Uses a single key to encrypt and decrypt data • Also known as a secret-key or private key algorithm • The key must be kept a “secret” to maintain security • key lengths ranging from 40 to 256 bits • Examples of symmetric key algorithms: – DES, 3DES, AES, IDEA, RC5, RC6, Blowfish

123

Symmetric Encryption

ENCRYPTION DECRYPTION ALGORITHM ALGORITHM Plaintext Ciphertext Plaintext

Encryption Key Decryption Key

Symmetric Key Shared Key Shared Key Cryptography

Same shared secret key

124

62 1/22/18

Asymmetric Key Crypto

• Uses a public-private keypair • Also called public key crypto • Use one key to sign data, then the other key to verify • Examples: – RSA, DSA, El Gamal, Diffie-Hellman, PKCS

125

Asymmetric Encryption

ENCRYPTION DECRYPTION ALGORITHM ALGORITHM Plaintext Ciphertext Plaintext

Encryption Key Decryption Key

Asymmetric Key Public Key Private Key Cryptography

Different keys

126

63 1/22/18

Hash Functions

• produces a condensed representation of a message • takes an input message of arbitrary length and outputs fixed-length code – The fixed-length output is called the hash or message digest • A form of signature that uniquely represents the data • Uses: – Verifying file integrity - if the hash changes, it means the data is either compromised or altered in transit. – Digitally signing documents – Hashing passwords

127

Hash Functions

• Message Digest (MD) Algorithm – Outputs a 128-bit fingerprint of an arbitrary-length input – MD4 is obsolete, MD5 is widely-used

• Secure Hash Algorithm (SHA) – SHA-1 produces a 160-bit message digest similar to MD5 – Widely-used on security applications (TLS, SSL, PGP, SSH, S/MIME, IPsec) – SHA-256, SHA-384, SHA-512 can produce hash values that are 256, 384, and 512-bits respectively

128

64 1/22/18

Digital Signature

• a message appended to a packet • used to prove the identity of the sender and the integrity of the packet • how it works: – sender signs the message with own private key – receiver uses the sender’s public key to verify the signature

129

Message Authentication Code

• Provides integrity and authenticity • How it works: – In the sender side, the message is passed through a MAC algorithm to get a MAC (or Tag) – In the receiver side, the message is passed through the same algorithm – The output is compared with the received tag and should match • Uses the same secret key • Can also use hash function to generate the MAC, called Hash-based Message Authentication Code (HMAC)

130

65 1/22/18

DNS Security - Background

• The original DNS protocol wasn’t designed with security in mind • As the Internet grows, it has become less trustworthy • Some security problems: – Using reverse DNS to impersonate hosts – Software bugs (buffer overflows, bad pointer handling) – Cache poisoning (putting inappropriate data into the cache)

131

DNS Protocol Vulnerability

• DNS data can be corrupted as it transfers between primary server, resolver or forwarder • There is no way to check the validity of DNS data – Resolver implementation can be exploited (predictable transaction ID, buffer overflow, pointer handling) – Caching forwarders can be polluted – Corrupted DNS data might end up in caches and stay there for a long time • DNS transactions can be compromised – Primary server sending data to wrong secondary server

132

66 1/22/18

DNS: Data Flow

Zone administrator 1 4

Zone file master Caching forwarder

2 3 5 Dynamic updates slaves resolver

133

DNS Vulnerabilities Corrupting data Impersonating master Cache impersonation Zone administrator 1 4

Zone file master Caching forwarder

2 3 5 Dynamic updates slaves resolver Cache pollution by Data spoofing Unauthorized updates

Server protection Data protection

134

67 1/22/18

DNS Cache Poisoning

1 www.example.com 192.168.1.99 3 I want to access www.example.com 2001:DB8::9 QID=64569 www.example.com (pretending to be QID=64570 the authoritative QID=64571 match! zone)

2 QID=64571 Client DNS Caching Root/GTLD Server

QID=64571 3 Webserver www.example.com 192.168.1.1 (192.168.1.1 www.example.com 2001:DB8::1 2001:DB8::1) ns.example.com

135

DNS Amplification

• A type of reflection attack combined with amplification – Source of attack is reflected off another machine – Traffic received is bigger (amplified) than the traffic sent by the attacker • UDP packet’s source address is spoofed

136

68 1/22/18

DNS Amplification

Root/GTLD Queries for www.example.com

DNS Recursive server

ns.example.com www.example.com 192.168.1.1 www.example.com 2001:DB8::1 Compromised Machines (spoofed IP)

Victim Machine

Attacker

137

Open Resolvers

• DNS servers that answer recursive queries from any host on the Internet – pose some “significant threat” to the global network infrastructure • Often used in DNS-based DDoS attacks • There’s a project that maps out open resolvers on the Internet – Open Resolver Project - http://openresolverproject.org/ • Some utility available to check if running an open resolver

138

69 1/22/18

Open Resolvers

Reference: Open Resolver Project

Open Resolvers Statistics

Source: DNS Measurement Factory

140

70 1/22/18

DNS Changer

• “Criminals have learned that if they can control a user’s DNS servers, they can control what sites the user connects to the Internet.” • How: infect computers with a malicious software (malware) • A malware changes the user’s DNS settings with that of the attacker’s DNS servers • Points the DNS configuration to DNS resolvers in specific address blocks and use it for their criminal enterprise

Source: DCWG

141

DNS Changer

• IP addresses used by malware. These blocks have now been cleaned and re-allocated. – 85.225.112.0 through 85.255.127.255 – 67.210.0.0 through 67.210.15.255 – 93.188.160.0 through 93.188.167.255 – 77.67.83.0 through 77.67.83.255 – 213.109.64.0 through 213.109.79.255 – 64.28.176.0 through 64.28.191.255 • An adhoc group – DNS Changer Working Group – was created in 2012 to help remediate these malicious DNS servers

Source: DCWG

142

71 1/22/18

DNS Hijacking

• Also called DNS redirection • Can be achieved when – User’s DNS settings has been modified through malware – DNS server has been compromised to provide incorrect responses

143

DNS-Based DDoS attacks are common and remarkably simple

144

72 1/22/18

Case: Attack at Spamhaus

http://blog.cloudflare.com/deep-inside-a-dns-amplification-ddos-attack http://blog.cloudflare.com/the-ddos-that-knocked-spamhaus-offline-and-ho

Case: DNS Query Floods

• (May 2014) Targeted a chat service provider under Akamai • Bandwidth used maxed at 119 Gbps • Resulted to 110 Mpps – one of the highest packet-per- second (pps) rate for Akamai in 2014

Source: Prolexic Q2 2014 Global Attack Report 146

73 1/22/18

Case: DDoS attack on DNS Provider NS1

http://arstechnica.com/information-technology/2016/05/major-dns-provider-hit-by-mysterious-focused-ddos-attack/

147

Why is DNS prone to DDoS attacks?

DNS uses UDP – UDP = best effort, connectionless transmission – Easy to spoof the source address – Similar case with NTP, SNMP, SSDP, Chargen protocols Each query returns large responses – EDNS0 allows DNS messages to carry bigger data – DNSSEC returns large replies It’s usually open to all – Open resolvers

https://www.us-cert.gov/ncas/alerts/TA14-017A

148

74 1/22/18

Basic DNS Security Practices

• Run the most recent version of the DNS software or apply the latest patch • Restrict queries • Prevent unauthorized zone transfers • Run BIND with the least privilege (use chroot) • Randomize source ports • Secure the box • Implement TSIG and DNSSEC

DNS DDoS Mitigation

• Set up monitoring to know when you are being attacked – Use previous statistics to know your baseline load • Avoid single point of failure – DNS server, router, firewall, uplinks, etc – Authoritative nameservers must be geographically distributed • Provision for your DNS infrastructure – Find your DNS capacity (using tools like dnsperf) – Be ready to deploy more as needed • Deploy anycast – Attack is isolated in one group at a time – Alternatively use cloud-based DNS providers • Don’t run an open resolver!

150

75 1/22/18

Response Rate Limiting (RRL)

• Protects against DNS amplification attack • Implemented in CZ-NIC Knot (v1.2-RC3), NLNetLabs NSD (v3.2.15), and ISC BIND 9 (v9.9.4) release

rate-limit { responses-per-second 5; log-only yes; };

• If using older versions, a patch is available from – http://ss.vix.su/~vjs/rrlrpz.html – patch –p0 -l

151

Sender Policy Framework (SPF)

• Using DNS for email validation • Checks the sender IP address • Defined in RFC 4408 with updates in RFC 6652 apnic.net. 3600 IN TXT "v=spf1 mx a:clove.apnic.net a:asmtp.apnic.net ip4:203.119.93.0/24 ip4:203.119.101.0/24 ip4:203.89.255.141/32 ip4:203.190.232.30/32 ip4:122.248.232.184/32 include:_spf.google.com -all"

152

76 1/22/18

DANE

• DNS-Based Authentication of Named Entities • RFC 6698 (proposed standard) • “secure method to associate the certificate that is obtained from the TLS server with a domain name using DNS” • Adds a TLSA resource record

153

DNS RPZ

• Resource Policy Zone • Developed for ISC Bind. Built in from version 9.8 • Turns a recursive DNS server into a “DNS firewall” • “reputation-based” zones • Like creating a reputation server for recursive DNS servers – Function is similar to DNSBL for email SMTP servers • Blocks DNS resolution to malicious hosts

154

77 1/22/18

155

Overview

• DNS Overview • BIND DNS Configuration • Recursive and Forward DNS • Reverse DNS • Troubleshooting • DNS Security Overview • DNS Transactions • DNS Security Extensions (DNSSec) • DNSSec Key Management and Automation

156

78 1/22/18

Transactions - Protected Vulnerabilities

Impersonating master Zone administrator

Zone file master Caching forwarder

Dynamic updates slaves resolver

Unauthorized updates DNS query/response, zone transfers, Dynamic updates

157

DNS Transactions

• Remote Name Daemon Controller (RNDC) – Protects the remote CLI administration using shared key – Prevents unauthorized access to named

• Transaction Signature (TSIG) – Protects transactions using shared keys between both parties

• SIG(0) – Protects transactions using asymmetric key (public and private keypair)

158

79 1/22/18

What is Transaction Signature?

• A mechanism for protecting a message from primary to secondary (and vice versa) • Provides secure communication of queries and responses – Also protects zone transfers and dynamic updates • How? – A keyed-hash is applied so recipient can verify the message source • Based on a shared secret - both sender and receiver are configured with it

159

TSIG example

verification

AXFR AXFR

Sig ... Sig ... Query: AXFR

Slave Master KEY: KEY: %sgs!f23fv %sgs!f23fv

Response: Zone SOA SOA … … SOA SOA

Sig ... Sig ...

verification

160

80 1/22/18

TSIG steps

1. Generate secret

2. Communicate secret

3. Configure servers

4. Test

161

TSIG - Names and Secrets

• TSIG name – A name is given to the key, the name is what is transmitted in the message (so receiver knows what key the sender used)

• TSIG secret value – A value determined during key generation – Usually seen in Base64 encoding

162

81 1/22/18

TSIG – Generating a Secret

• dnssec-keygen – A simple tool to generate keys – Used here to generate TSIG keys

dnssec-keygen -a -b -n host

163

TSIG – Generating a Secret

• Example

> dnssec-keygen –a HMAC-SHA256 –b 256 –n HOST ns1- ns2.pcx.net

This will generate the key Kns1-ns2.pcx.net.+157+15921

>ls Kns1-ns2.pcx.net.+157+15921.key Kns1-ns2.pcx.net.+157+15921.private

164

82 1/22/18

TSIG – Generating a Secret

• TSIG is used in server configuration, not in zone file • Could be confusing because it looks like RR

ns1-ns2.pcx.net. IN KEY 128 3 157 nEfRX9…bbPn7lyQtE=

165

TSIG – Configuring Servers

• Configuring the key

key { algorithm ...; secret ...;}

• Making use of the key

server x { key ...; }

where x is the IP address of the other server

166

83 1/22/18

Configuration Example – named.conf Primary server 192.168.1.100 Secondary server 192.168.1.200

key ns1-ns2.pcx. net { key ns1-ns2.pcx.net { algorithm hmac-md5; algorithm hmac-md5; secret "APlaceToBe"; secret "APlaceToBe"; }; }; server 192.168.1.200 { server 192.168.1.100 { keys {ns1-ns2.pcx.net;}; keys {ns1-ns2.pcx.net;}; }; }; zone "my.zone.test." { zone "my.zone.test." { type master; type slave; file “db.myzone”; file “myzone.backup”; allow-transfer { masters {192.168.1.100;}; key ns1-ns2.pcx.net ;}; }; };

You can save this in a file and refer to it in the named.conf using ‘include’ statement: include “/var/named/master/tsig-key-ns1-ns2”;

167

TSIG Testing - dig

• You can use dig to check TSIG configuration – dig @ AXFR -k

dig @localhost example.net AXFR \ -k Kns1-ns2.pcx.net.+157+15921.key

• A wrong key will give “Transfer failed” and will be logged on the server’s using the security-category

168

84 1/22/18

TSIG Testing - Time

• TSIG is time sensitive • Message protection expires in 5 minutes – Make sure time is synchronized – For testing, set the time – In operations, (secure) NTP is needed

169

TSIG steps

1. Generate secret dnssec-keygen -a -b -n host 2. Communicate secret scp @: 3. Configure servers key { algorithm ...; secret ...;} server x { key ...; } 4. Test dig @ AXFR -k

170

85 1/22/18

171

Overview

• DNS Overview • BIND DNS Configuration • Recursive and Forward DNS • Reverse DNS • Troubleshooting • DNS Security Overview • DNS Transactions • DNS Security Extensions • DNSsec Key Management and Automation

172

86 1/22/18

Vulnerabilities protected by DNSKEY / RRSIG / NSEC Cache impersonation Zone administrator

Zone file master Caching forwarder

Dynamic updates slaves resolver

Cache pollution by Data spoofing

173

What is DNSSEC?

• DNS Security Extensions • Protects the integrity of data in DNS by establishing a chain of trust • A form of digitally signing the data to attest its validity • Uses public key cryptography – each link in the chain has a public/private key pair • Provides a mechanism to: – establish authenticity and integrity of data – delegate trust to third parties or parent zones

174

87 1/22/18

DNSSEC History

• 1990: Steven Bellovin discovers a major flaw in the DNS • 1995: Bellovin publishes his research; DNSSEC becomes a topic within IETF • 1998: Dan Kaminsky discovers some security flaw • 1999: RFC 2535, the DNSSEC protocol, is published • 2005: Three new RFCs published to update RFC2535 – RFC 4033 (DNS Security Introduction and Requirements) – RFC 4034 (Resource Records for DNS Security Extensions) – RFC 4035 (Protocol Modifications)

https://wiki.tools.isoc.org/DNSSEC_History_Project

175

DNSSEC History

• 2005: In October, Sweden (.SE) becomes the first ccTLD to deploy DNSSEC • 2008: new DNSSEC record created to address privacy concerns (RFC 5155) • 2010 – In July 15, the root zone was signed – In July 29, .edu was signed – In December 9, .net was signed • 2011: In March 31, .com was signed

https://wiki.tools.isoc.org/DNSSEC_History_Project

176

88 1/22/18

How DNSSEC Works

• Records are signed with private key to prove its authenticity and integrity • The signatures are published in DNS • Public key is also published so record signatures can be verified • Child zones also sign their records with their private key • Parent signs the hash of child zone’s public key to prove authenticity

177

How DNSSEC Works

Authoritative servers Sign their zones Answer queries with the record requested Also send the digital signature corresponding to the record

Validating Resolvers Authenticates the responses from the server Data that is not validated results to a “SERVFAIL” error

89 1/22/18

New Concepts in DNSSEC

• New resource records • Chain of trust • Key generation and signing • Validation

179

New Resource Records

Resource Function Record RRSIG Resource Record Signature Signature over RRset made using private key DNSKEY DNS Key Public key needed for verifying a RRSIG DS Delegation Signer Pointer for building chains of authentication NSEC / Next Secure indicates which name is the next NSEC3 one in the zone and which type codes are available for the current name

180

90 1/22/18

New Resource Records

• RRsets are signed with private key to prove its authenticity and integrity • The signatures are published in DNS as RRSIG • Public DNSKEY is also published so RRSIG can be verified • Child zones also sign their records with their private key • Parent signs the child zone’s DS record to prove authenticity

181

RRs and RRsets

• Resource Record – each entry in the zonefile

www.example.net. 7200 IN A 192.168.1.1

• RRset - RRs with same name, class and type

www.example.net. 7200 IN A 192.168.1.1 web1.example.net. 7200 IN A 10.0.0.1 web2.example.net. 7200 IN A 172.16.0.20

In DNSSEC, RRsets are signed and not the individual RRs

182

91 1/22/18

DNSKEY

• Contains the zone’s public key • Uses public key cryptography to sign and authenticate DNS resource record sets (RRsets). • Example: 16-bit field flag; 256 if ZSK, 257 if KSK Protocol octet DNSKEY algorithm number irrashai.net. IN DNSKEY 256 3 5 ( AwEAAagrVFd9xyFMQRjO4DlkL0dgUCtogviS+FG9Z6Au3h1ERe4EIi3L X49Ce1OFahdR2wPZyVeDvH6X4qlLnMQJsd7oFi4S9Ng+hLkgpm/n+otE kKiXGZzZn4vW0okuC0hHG2XU5zJhkct73FZzbmBvGxpF4svo5PPWZqVb H48T5Y/9 ) ; key id = 3510

Public key (base64)

183

DNSKEY

• Also contains some timing metadata – as a comment in the key file

; This is a key-signing key, keyid 19996, for myzone.net. ; Created: 20121102020008 (Fri Nov 2 12:00:08 2012) ; Publish: 20121102020008 (Fri Nov 2 12:00:08 2012) ; Activate: 20121102020008 (Fri Nov 2 12:00:08 2012)

184

92 1/22/18

RRSIG

• The private part of the key-pair is used to sign the resource record set (Rrset) • The digital signature per RRset is saved in an RRSIG record irrashai.net. 86400 NS NS.JAZZI.COM.RR type signed Digital signature algorithm 86400 NS NS.IRRASHAI.NET. Number of labels in the 86400 RRSIG NS 5 2 86400 ( signed name 20121202010528 20121102010528 3510 irrashai.net. Signature expiry Y2J2NQ+CVqQRjQvcWY256ffiw5mp0OQTQUF8 Date signed vUHSHyUbbhmE56eJimqDhXb8qwl/Fjl40/km lzmQC5CmgugB/qjgLHZbuvSfd9W+UCwkxbwx 3HonAPr3C+0HVqP8rSqGRqSq0VbR7LzNeayl BkumLDoriQxceV4z3d2jFv4ArnM= )

185

NSEC Record

• Next Secure • Forms a chain of authoritative owner names in the zone • Lists two separate things: – Next owner name (canonical ordering) – Set of RR types present at the NSEC RR’s owner name • Also proves the non-existence of a domain • Each NSEC record also has a corresponding RRSIG

myzone.net. NSEC blog.myzone.net. A NS SOA MX RRSIG NSEC DNSKEY

186

93 1/22/18

NSEC RDATA

• Points to the next domain name in the zone – also lists what are all the existing RRs for “name” – NSEC record for last name “wraps around” to first name in zone

• Used for authenticated denial-of-existence of data – authenticated non-existence of TYPEs and labels

187

NSEC Record – Example

$ORIGIN example.net. @ SOA … NS NS.example.net. DNSKEY …

NSEC mailbox.example.net. SOA NS NSEC DNSKEY RRSIG mailbox A 192.168.10.2 NSEC www.example.net. A NSEC RRSIG WWW A 192.168.10.3 TXT Public webserver NSEC example.net. A NSEC RRSIG TXT

188

94 1/22/18

NSEC3

• NSEC allows an attacker to walk through the linked list to find all the records in the zone file. This is called zone walking. • NSEC3 uses a hashing algorithm to list the next available domain in “hashed” format • It is still possible for an attacker to do zone walking, although at a higher computation cost.

189

DS Record

• Delegation Signer • Establishes authentication chains between DNS zones • Must be added in the parent’s zonefile • In this example, irrashai.net has been delegated from .net. This record is added in the.net zone file

Key ID DNSKEY algorithm (RSASHA1) irrashai.net. IN NS ns1.irrashai.net. Digest type: 1 = SHA1 NS ns2.irrashai.net. 2 = SHA256 IN DS 19996 5 1 ( CF96B018A496CD1A68EE7 C80A37EDFC6ABBF8175 ) IN DS 19996 5 2 ( 6927A531B0D89A7A4F13E11031 4C722EC156FF926D2052C7D8D70C50 14598CE9 )

190

95 1/22/18

DS Record

• indicates that delegated zone is digitally signed • Verifies that indicated key is used for the delegated zone • Parent is authoritative for the DS of the child zone – Not for the NS record delegating the child zone – DS should not be added in the child zone

191

Chain of Trust

• Establishes a chain of trust from parent to child zone • How? – Parent does not sign child zone – Parent only signs a pointer to the child zone (key) – DS RECORD • The root is on top of the chain

192

96 1/22/18

Creation of keys

• In practice, we use two keypairs – one to sign the zones, another to sign the other key • Using a single key or both keys is an operational choice (RFC allows both methods) • If using a single key-pair: – Zones are digitally signed using the private key – Public key is published using DNSKEY RR – When key is updated, DS record must again be sent to parent zone • To address this administrative load, two keypairs will be used

193

Types of Keys

Zone Signing Key (ZSK) Sign the RRsets within the zone Signed by the KSK Uses flag 256

Key Signing Key (KSK) Signs the ZSK Pointed to by the parent zone Acts as the security entry point

97 1/22/18

Signature Expiration

• Keys do not expire – Still a good practice to generate new ones regularly for added security • Signatures have validity period – By default set to 30 days – This info is added in the key metadata • Expired signatures will not validate – Must re-sign the zones

195

DNSSEC Algorithms

New algorithms such as ECDSA and GOST are faster and can generate smaller keys and signatures

http://www.iana.org/assignments/dns-sec-alg-numbers/dns-sec-alg-numbers.xhtml

196

98 1/22/18

DNSSEC Deployment in ccTLDs

http://rick.eng.br/dnssecstat/

197

DNSSEC Deployment in ccTLDs

http://rick.eng.br/dnssecstat/

198

99 1/22/18

DNSSEC Validation Rate

http://stats.labs.apnic.net/dnssec

199

DNSSEC for Registries and Hosting Providers • Sign your zones • Before fully implementing: – Plan about key rollover – Think about securing your keys – What happens if your key gets compromised • Support more and newer algorithms (such as ECDSA)

200

100 1/22/18

DNSSEC for Network Service Providers • Enable DNSSEC on your recursive servers and validate responses – Deploy DNSSEC-validating resolvers • Before you fully implement: – Domains that can’t be validated will be inaccessible – Be prepared to answer helpdesk queries related to this

201

202

101 1/22/18

Implementing DNSSEC

203

DNSSEC in the Resolver

• Recursive servers that are dnssec-enabled can validate signed zones • Enable DNSSEC validation dnssec-validation yes; • The AD bit in the message flag shows if validated

204

102 1/22/18

DNSSEC Validation

• Other options if you don’t have a validating resolver – validator add-on for your web browser • ex: https://www.dnssec-validator.cz/ – Online web tools • http://dnsviz.net/ • http://dnssec-debugger.verisignlabs.com/ • Use an open DNSSEC-validating resolver – DNS-OARC’s ODVR (link) • 149.20.64.20 (BIND9), 149.20.64.21 (Unbound) – Google Public DNS • 8.8.8.8 or 8.8.4.4

205

DNSSEC - Setting up a Secure Zone

• Enable DNSSEC in the configuration file (named.conf) – dnssec-enable yes; dnssec-validation yes; • Create key pairs (KSK and ZSK) – dnssec-keygen -a rsasha1 -b 1024 -n zone myzone.net • Publish your public key • Signing the zone • Update the config file – Modify the zone statement, replace with the signed zone file • Test with dig

206

103 1/22/18

Updating the DNS Configuration

• Enable DNSSEC in the configuration file (named.conf) options { directory “….” dnssec-enable yes; dnssec-validation yes; };

• Other options that can be added later auto-dnssec { off | allow | maintain} ;

– These options are used to automate the signing and key rollover

207

Generating Key Pairs

• Generate ZSK and KSK

dnssec-keygen -a rsasha1 -b 1024 -n zone

Default values are RSASHA1 for algorithm, 1024 bits for ZSK and 2048 bits for KSK

The command above can be simplified as: dnssec-keygen –f KSK

This generates four files.

Note: There has to be at least one public/private key pair for each DNSSEC zone

208

104 1/22/18

Generating Key Pairs

• To create ZSK

dnssec-keygen -a rsasha1 -b 1024 -n zone myzone.net

• To create KSK

dnssec-keygen -a rsasha1 -b 2048 -f KSK -n zone myzone.net

209

Generating Key Pairs - Reverse

• To create ZSK

dnssec-keygen -a rsasha1 -b 1024 -n zone 100.168.192.in-addr.arpa

• To create KSK

dnssec-keygen -a rsasha1 -b 2048 -f KSK -n zone 100.168.192.in-addr.arpa

210

105 1/22/18

Publishing the Public Key

• Using $INCLUDE you can call the public key (DNSKEY RR) inside the zone file

$INCLUDE /path/Kmyzone.net.+005+33633.key ; ZSK $INCLUDE /path/Kmyzone.net.+005+00478.key ; KSK

• You can also manually enter the DNSKEY RR in the zone file

211

Signing the Zone

• Sign the zone using the secret keys:

dnssec-signzone –o -N INCREMENT -f -k

dnssec-signzone –o myzone.net db.myzone.net Kmyzone.net.+005+33633

• Once you sign the zone a file with a .signed extension will be created – db.myzone.net.signed

212

106 1/22/18

Signing the Zone

• Note that only authoritative records are signed – NS records for the zone itself are signed – NS records used for delegations are not signed – DS records are signed – Glue records are not signed • Notice the difference in file size – db.myzone.net vs. db.myzone.net.signed

213

Smart Signing

• Searches the key repository for any keys that will match the zone being signed

options { keys-directory { “path/to/keys”; };

• Then the command for smart signing is dnssec-signzone –S db.myzone.net

214

107 1/22/18

Publishing the Zone

• Reconfigure to load the signed zone. Edit named.conf and point to the signed zone.

zone “” { type master; # file “db.myzone.net”; file “db.myzone.net.signed”; };

215

Publishing the Zone – Reverse

• Reconfigure to load the signed zone. Edit named.conf and point to the signed zone.

zone “” { type master; # file “db.192.168.100”; file “db.192.168.100.signed”; };

216

108 1/22/18

Testing the Server

• Ask a dnssec-enabled server and see whether the answer is signed

dig @localhost www.apnic.net +dnssec +multiline

217

Testing with Dig dig @localhost www.irrashai.net +dnssec (+multiline)

218

109 1/22/18

Testing with Dig – Reverse dig @localhost -x 192.168.100.100 +dnssec

219

Pushing the DS record

• The DS record must be published by the parent zone. • Contact the parent zone to communicate the KSK to them.

• There are proposals in the IETF DNSOP WG to address this: – Automating DNSSEC Delegation Trust Maintenance (link) – Child to Parent Synchronization in DNS (link)

220

110 1/22/18

Pushing DS Records for Forward Zone

Example form for Godaddy

221

Pushing DS Record for Reverse Zone

Using MyAPNIC

DS record added in the domain object

222

111 1/22/18

Ways to Deploy DNSSEC

• As part of the DNS software used DNSSEC tools for BIND, – Manual key management NSD, PowerDNS, etc – Can be quite complex – For static environment – Some means of automation using • option commands and scripts • Use with a hardware security module (HSM) HSM, – Semi-automatic OpenDNSSEC – Good for dynamic environment • Using an external appliance – ‘dnssec-in-a-box’ DNS Appliance – Fully automates key generation, signing and rollover

223

Hardware Security Module

• Cryptographic devices used for storage of the encryption keys – Smart cards, PCI cards, USB tokens • It also speeds up the cryptographic key generation • Implements PKCS#11 (Cryptographic Token Key Interface) – A standard interface or API to cryptographic tokens

224

112 1/22/18

DNSSEC Signer Appliance

DNS Master DNSSEC Signer DNS Server • Creates the zones • Signs the zones • Answer queries as per usual • Propagates the signed zones

• Can be a pure signer or packaged with an IPAM or a DNS server • In pure signer, the hardware appliance interfaces between the master/slave servers • Examples: Secure64, Xelerance, SolidDNS, etc

225

226

113 1/22/18

Overview

• DNS Overview • BIND DNS Configuration • Recursive and Forward DNS • Reverse DNS • Troubleshooting • DNS Security Overview • DNS Transactions • DNS Security Extensions (DNSSec) • DNSsec Key Management and Automation

227

KSK Key Rollover

Using Double signing • When you change the KSK keys, the DS record in the parent zone must also be updated

dnssec-signzone –o myzone.net –N increment –f -k Kmyzone.net.+005+11111 db.myzone.net \ Kmyzone.net.+005+67890

• Send the new DS record to the parent, and wait for it to propagate • Remove the old key and re-sign

228

114 1/22/18

KSK Key Rollover

Using Pre-publication • In this method, the new key will be published but will not be used for signing yet.

dnssec-keygen –K keydir –f ksk –A none rndc loadkeys

• Publish both keys, but use only the old one for signing • Wait for the propagation time and TTL of the DNSKEY RR to expire.

229

KSK Key Rollover

• Then use dnssec-settime once you are ready to sign the zone. Use the new key for zone signing, leaving the old one published.

dnssec-settime –K keydir –A now Kmyzone.net.+005+12345 rndc loadkeys myzone.net

• Wait for the propagation and TTL in the old zone. Set the old key to no longer sign with the key, but leaves it in the zone.

dnssec-settime –K keydir -I now Kmyzone.net.+005+12345 rndc loadkeys myzone.net

• Now remove the old keys. This completely removes the keys.

dnssec-settime –K keydir -D now Kmyzone.net.+005+12345 rndc loadkeys myzone.net

230

115 1/22/18

Other Options – Automated Signing

• Using RNDC

• Add the option to named.conf auto-dnssec allow;

• Then you can use the commands: rndc loadkeys zone rndc sign zone

231

DNSSEC Operational Practices RFC 6781 • Lists down choices and decisions available when deploying DNSSEC • Keep the chain of trust – Broken chains result in data being marked as Bogus – Shared responsibility by admins • Key generation and storage – The motivations to differentiate KSK and ZSK are purely operational – Timing parameters – Key compromise and risk of cryptanalysis – Keys should be large enough to avoid all known crypto attacks during the effectivity period of the key – zone private keys and the zone file master copy to be signed be kept and used in off-line https://tools.ietf.org/html/rfc6781

232

116 1/22/18

DNSSEC Operational Practices RFC 6781 • Signature generation, key rollover and policies – Data published in previous versions still live in caches – ZSK can be rolled without taking into account the DS record from parent – KSK rollover requires interaction with the parent – Emergency key rollover • Motivation to deploy NSEC3 over NSEC – Prevention of zone enumeration

https://tools.ietf.org/html/rfc6781

233

DNSSEC Practice Statement – RFC 6841 • a means for stakeholders to evaluate the strength and security of the DNSSEC chain of trust • DNSSEC Policies (DPs) – security requirements and standards to be implemented for a DNSSEC-signed zone • DNSSEC Practice Statement (DPS) – practice disclosure document; states how the management of a given zone implements procedures and controls at a high level

https://tools.ietf.org/html/rfc6841

234

117 1/22/18

DNSSEC Practice Statement

• The DPS for Root Zone Signing Key (ZSK) is published – https://www.iana.org/dnssec/icann-dps.txt • Published DPS of TLD operators .SE's DNSSEC Practice Statement www.iis.se/docs/se-dnssec-dps-eng.pdf .CL's DNSSEC Practice Statement http://www.nic.cl/dnssec/en/dps.html .NET DNSSEC Practice Statement http://www.verisigninc.com/assets/20100925-NET+DPS- FINAL.pdf

235

DNSSEC Guides

• Good Practice Guide for Deploying DNSSEC – ENISA – Published 2010 • Secure Domain Name System Deployment Guide – NIST – Published 2013

236

118 1/22/18

237

Intro to OpenDNSSEC

238

119 1/22/18

What is OpenDNSSEC?

Input • An open source turn-key solution Adapter for managing DNSSEC

• The goal is to simplify the signing Unsigned Security process and minimize the zone Module workload on the admin

Signer KASP • Uses PKCS#11 for key storage Engine enforcer • Check out the documentation

– https://wiki.opendnssec.org/display Signed Key and /DOCS zone Signing Policy

Output Adapter

Reference: http://www.opendnssec.org/about/

239

Installation (on CentOS 6.1)

• Install dependencies – LDS (DNS programming library) – libxml2 (libxml2, libxml2-dev, libxml2-utils) – Java – SQLite (sqlite3, libsqlite3, libsqlite3-dev) – MySQL – optional • Install a Hardware Security Module (HSM) – Or an equivalent software emulation • Install OpenDNSSEC

240

120 1/22/18

SoftHSM Installation

• Software-only implementation of an HSM • Dependencies – At least Botan 1.10.0 and OpenSSL 0.9.8 • Install from a repository or source tar xvzf softhsm-.tar.gz cd softhsm- ./configure make sudo make install • Edit the configuration file and specify the slots to be used vi /etc/softhsm.conf 0:/var/softhsm/slot0.db

241

SoftHSM

• Although the HSM has been defined, it has to be initialized softhsm --init-token –slot 0 –label “opendnssec” • Check that this HSM repository is configured in OpenDNSSEC’s conf.xml