Routing, NAT and firewalls
Unit 4 of 5 in Networking fundamentals.
You will be able to explain what a router, NAT and a firewall each do to a packet and why a firewall should deny by default.
Lesson
Routers move packets between networks
A router is a device that performs the network-layer forwarding function. Older documents called these devices gateways. The selection of a path for a datagram is called routing, and each router along the way looks at the destination address and passes the datagram on toward it.
Your own machine makes the same kind of choice for every packet it sends, and the routing-table lab in this unit lets you see it.
NAT: sharing one public address
Private addresses cannot be used on the public internet, so something must translate them. Basic NAT maps IP addresses from one group to another. Network Address Port Translation maps many addresses and their ports into a single address and its ports. Together they connect a realm of private addresses to an external realm of globally unique addresses.
Many organizations use private addresses inside because most internal hosts never need to be reached from outside, and some use gateways so that only a few systems are visible from the internet.
Firewalls: rules about what may pass
NIST defines firewalls as devices or programs that control the flow of network traffic between networks or hosts that have differing security postures. The most basic feature is the packet filter. Older firewalls that were only packet filters did not keep track of the state of each flow, so they could not associate multiple requests in a single session. Stateful inspection improves on this by tracking the state of connections and blocking packets that deviate from the expected state.
NIST also notes that a firewall at the edge protects internal hosts only in part: it cannot recognize all forms of attack, and attacks from one internal host to another often never pass through a network firewall. That is the reason for host-based firewalls and for splitting a network into zones.
Deny by default
For the firewall policy, NIST recommends blocking traffic the organization does not need. This practice is called deny by default. It decreases the risk of attack, can reduce the volume of traffic on the network, and is described as more secure than permitting everything that is not explicitly forbidden, because hosts, networks and applications keep changing.
NIST lists NAT among the technologies many firewalls use to hide internal addresses. The packet filter is the part NIST describes as providing access control for host addresses and communication sessions, so treat address hiding as a side effect and not as a substitute for a rule set.
Key points
- A router forwards datagrams toward their destination address; your machine uses a default gateway.
- NAT maps private addresses to public ones; NAPT shares one address using ports.
- A packet filter is the most basic firewall feature; stateful inspection tracks each flow.
- Deny by default is the recommended firewall policy.
- An edge firewall alone cannot see internal host-to-host traffic.
Sources
- RFC 1812: Requirements for IP Version 4 Routers
- RFC 791: Internet Protocol
- RFC 3022: Traditional IP Network Address Translator (Traditional NAT)
- RFC 1918: Address Allocation for Private Internets
- NIST SP 800-41 Rev. 1: Guidelines on Firewalls and Firewall Policy
Lecture
Network segmentation and zero trust: A talk on splitting a network into zones and what zero trust adds, the next step after this unit.
Practice in the labs
Trace how a packet leaves your machine, then build a host firewall that denies by default.
- Trace your routing table and NAT: how a packet actually leaves your machine: You follow a packet out of your own machine through the routing table and NAT, step by step.
- Set up a host firewall with UFW: A short lab that sets a default of deny for incoming traffic with one explicit allow.
- Build a host firewall with nftables: You build a rule set by hand with a rollback ready, which shows what a firewall policy really is.
Also try, in the simulators
- A default route to the upstream (Network Builder exercise): You give a router an address and a default route toward the upstream, the routing idea of this unit in a drawn network.
- A firewall that allows one service (Network Builder exercise): You replace an allow-everything firewall rule with one that permits a single service, deny by default made visible.
Knowledge check
- What is the function of a router? Answer: It performs the network-layer forwarding function toward the destination address. RFC 1812 describes routers as devices that perform the network layer forwarding function of the Internet protocol suite.
- What does 'deny by default' mean for a firewall? Answer: Block traffic the organization does not need and allow only what is required. NIST SP 800-41 describes blocking traffic that is not needed as deny by default and says it is more secure than permitting all traffic that is not explicitly forbidden.
- Why is an edge firewall alone not enough? Answer: Attacks between internal hosts often do not pass through it. NIST notes perimeter firewalls cannot recognize all attacks, and attacks sent from one internal host to another often do not pass through network firewalls.
Back to the syllabus or see all classes.