By the end of this lesson you can
- Describe the DHCP DORA exchange and why relay is needed
- Configure a router as DHCP server, relay agent and client
- Explain DNS record types and why DNS uses both UDP and TCP
- Use the four NAT address terms correctly
- Configure and verify static NAT and PAT
DHCP: how a PC gets its address
Typing addresses into every PC does not scale and invites mistakes. DHCP hands out the address, mask, default gateway, DNS servers and a lease time. The client uses UDP port 68 and the server UDP port 67.
Broadcasts do not cross routers, so a server in the data centre never hears a Discover from a branch LAN. The fix is a relay agent: ip helper-address 10.0.0.10 on the router interface facing the clients turns the broadcast into a unicast to the server, and includes the interface address (192.168.10.1) so the server knows which pool to use. A router can also be a DHCP server itself, or a DHCP client with ip address dhcp, which is common on an internet facing interface.
DNS: names to addresses
People type names; packets need addresses. DNS resolves one to the other. Your PC asks its configured resolver, which finds the answer (asking other servers if needed) and caches it.
| Record | Holds |
|---|---|
| A | An IPv4 address for a name |
| AAAA | An IPv6 address for a name |
| CNAME | An alias pointing to another name |
| MX | The mail server for a domain |
| PTR | Reverse lookup: address to name |
| NS | Which servers are authoritative for a zone |
DNS mostly uses UDP port 53, and TCP port 53 for large answers and zone transfers, so "DNS is only UDP" is wrong. On a router, ip name-server sets the resolver it uses itself, and no ip domain-lookup (lesson 3.3) stops it trying to resolve every mistyped command.
NAT and PAT
Private ranges (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16) are not routed on the internet. NAT on the edge router rewrites them to public addresses on the way out and back again for the replies.
| Term | Meaning | In the lab |
|---|---|---|
| Inside local | The real, usually private, address of the inside host | 192.168.10.100 |
| Inside global | The public address that represents the inside host | 203.0.113.2 |
| Outside global | The real address of the remote host | 198.51.100.10 |
| Outside local | How the remote host appears from inside; usually the same as outside global | 198.51.100.10 |
| Type | Mapping | Use |
|---|---|---|
| Static NAT | One inside address to one public address, permanently | Publishing a server |
| Dynamic NAT | Inside hosts borrow addresses from a pool, one to one while in use | Rare today; runs out when the pool is used up |
| PAT (overload) | Many inside hosts share one public address, told apart by port | Almost every home and office |
R1(config)#access-list 1 permit 192.168.10.0 0.0.0.255
R1(config)#ip nat inside source list 1 interface GigabitEthernet0/0/2 overload
R1(config)#interface GigabitEthernet0/0/0
R1(config-if)#ip nat inside
R1(config)#interface GigabitEthernet0/0/2
R1(config-if)#ip nat outside
R1(config)#ip nat inside source static 10.0.0.10 203.0.113.3NAT hides internal addresses, but it is not a security policy: a static mapping publishes the server to the whole internet. Use an ACL or firewall to allow only the ports you mean to publish, and keep that server patched and separated. Also note that clear ip nat translation * drops every active session through the router.
Practise on R1
R1's interfaces are addressed. The DHCP clients and the internet traffic in this console are modelled for you so the show commands have something to display.
Missions 0/12
Flashcards: do you remember?
Tap a card to flip it. Try to answer in your head first; recalling is what makes it stick.
Quick quiz
Instant feedback on every answer. Score 70% or more to pass this lesson's quiz.
Q1Why does a PC in another subnet not reach a central DHCP server by default?
ip helper-address relays it.
Q2Which address is the inside global?
Inside global is how the inside host appears outside.
Q3Many hosts share one public IP. Which NAT type?
Port numbers keep the sessions apart.
Q4Which record maps a name to an IPv6 address?
AAAA is the IPv6 equivalent of A.
Q5What does a DHCP starvation attack do?
Real clients then get no lease, and a rogue server can step in.
Q6A static NAT mapping publishes an internal server. What should accompany it?
NAT changes addresses; it does not enforce policy.
Hands-on lab
Packet Tracer lab 3.10: central DHCP with relay, DNS, and PAT to the internet
You need: Cisco Packet Tracer (free with a Cisco Networking Academy account; version 9.0.1 was the current download on the NetAcad Resource Hub when this lesson was written). Devices: 2 x ISR4331 (R1 and ISP), 2 x 2960, 2 x PC-PT, 2 x Server-PT. 203.0.113.0/24 and 198.51.100.0/24 are documentation ranges (RFC 5737) standing in for public space.
Simulator lab, zero risk. This lab runs inside Cisco Packet Tracer, so it touches no real network. Packet Tracer is free with a Cisco Networking Academy account (netacad.com). It simulates a subset of Cisco IOS, so where support for a feature is uncertain we say so instead of promising it works.
Topology and addressing
| Device | Interface | IPv4 address / prefix | Default gateway or note |
|---|---|---|---|
| R1 | Gi0/0/0 | 192.168.10.1/24 | ip nat inside, ip helper-address 10.0.0.10 |
| R1 | Gi0/0/1 | 10.0.0.1/24 | ip nat inside |
| R1 | Gi0/0/2 | 203.0.113.2/29 | ip nat outside |
| ISP | Gi0/0/0 / Gi0/0/1 | 203.0.113.1/29 / 198.51.100.1/24 | no route to 192.168.10.0 needed |
| Server-DHCP-DNS | Fa0 | 10.0.0.10/24 | gateway 10.0.0.1 |
| Web-Internet | Fa0 | 198.51.100.10/24 | gateway 198.51.100.1, HTTP on |
Server services
On Server-DHCP-DNS, open Services, DHCP: create a pool for 192.168.10.0/24 starting at 192.168.10.100 with default gateway 192.168.10.1 and DNS server 10.0.0.10, and turn the service on. Then Services, DNS: turn it on and add an A record
web.cwm.labpointing to 198.51.100.10.Relay
R1(config)#interface GigabitEthernet0/0/0 R1(config-if)#ip helper-address 10.0.0.10Set both PCs to DHCP in their IP Configuration and confirm they receive .100 and up.
Optional: router as the DHCP server instead
R1(config)#ip dhcp excluded-address 192.168.10.1 192.168.10.99 R1(config)#ip dhcp pool LAN10 R1(dhcp-config)# network 192.168.10.0 255.255.255.0 R1(dhcp-config)# default-router 192.168.10.1 R1(dhcp-config)# dns-server 10.0.0.10Remove the helper address if you try this, or you will have two servers answering.
PAT for the LAN
R1(config)#access-list 1 permit 192.168.10.0 0.0.0.255 R1(config)#ip nat inside source list 1 interface GigabitEthernet0/0/2 overload R1(config)#interface GigabitEthernet0/0/0 R1(config-if)#ip nat inside R1(config)#interface GigabitEthernet0/0/1 R1(config-if)#ip nat inside R1(config)#interface GigabitEthernet0/0/2 R1(config-if)#ip nat outside R1(config)#ip route 0.0.0.0 0.0.0.0 203.0.113.1The ISP has no route back to 192.168.10.0/24, and needs none. That is the point of NAT.
Static NAT for the DNS server (demo only)
R1(config)#ip nat inside source static 10.0.0.10 203.0.113.3From Web-Internet, ping 203.0.113.3 or run
nslookup web.cwm.lab 203.0.113.3. In real life publish only the ports you need and filter with an ACL.Dynamic NAT with a pool (in a copy of the file)
R1(config)#no ip nat inside source list 1 interface GigabitEthernet0/0/2 overload R1(config)#ip nat pool PUBLIC 203.0.113.4 203.0.113.6 netmask 255.255.255.248 R1(config)#ip nat inside source list 1 pool PUBLICWith three pool addresses, a fourth inside host cannot get out until a translation times out. Adding
overloadto the pool line turns it into PAT over the pool.Test and verify
PC1>ipconfig /all R1#show ip nat translations R1#show ip nat statistics R1#show ip dhcp binding R1#show ip dhcp poolFrom PC1, browse
http://web.cwm.lab. Briefly trydebug ip nat, then turn it off withundebug all.
You are done when: PC1 ipconfig /all shows an address from .100 up, gateway 192.168.10.1 and DNS 10.0.0.10. show ip nat translations lists entries with inside global 203.0.113.2 and different ports for different inside locals, plus the static entry for 10.0.0.10. PC1 opens http://web.cwm.lab.
Packet Tracer limits and notes
- Server-PT DHCP and DNS services work for simple pools and A records. How Packet Tracer matches a Server-PT pool to the relay address in every version is UNVERIFIED; if a PC gets no lease, check that the pool's gateway sits in the PC's subnet.
- Packet Tracer's
show ip nat statisticsoutput is shorter than real IOS. - Which DNS record types beyond A and CNAME Packet Tracer's DNS server supports is UNVERIFIED for every version.
- Packet Tracer simulates a subset of IOS. If a command here is rejected in your version, note it, skip that step and carry on; the concept still applies to real Cisco gear.
Download the lab checklist (.txt) Print it or keep it open beside Packet Tracer.
Key takeaways
- DHCP is DORA over UDP 67 and 68; relay it across routers with ip helper-address.
- DNS uses UDP 53 and TCP 53; whoever controls your DNS controls where names go.
- Know the four NAT terms: inside local, inside global, outside local, outside global.
- PAT (overload) lets a whole site share one public address.
- NAT is not a firewall; filter what you publish.
Finished the sections, quiz and lab? Mark the lesson complete. Progress is saved only in this browser.