to ipchains (2.2.x) and ipfwadm (2.0.x) • Callback function hooks on network stack • stateless/stateful packet filtering (IPv4 and IPv6) • network address and port translation, eg. NAT/NAPT • OSI Layer 2 (Link)
Arriving on an interface, after checksum validation • INPUT – Before delivery to local process • FORWARD – between one interface to another (important for routers!) • POSTROUTING – Before leaving an interface • OUTPUT – After being generated by a local process
more matching criteria + Target (action) • First match which satisfies matching criteria wins (ordering!) • No Match criteria All packets considered → • No Target PacketCounter++ and ByteCounter++ →
next stage of processing. Stop traversing the current chain • DROP – Discontinue processing entirely. Do not check against any other rule, table, chain. (Stealth!) • REJECT – Same as DROP, but provide feedback (example: icmp-host-prohibited) • QUEUE – Send the packet to UserSpace (ie. code not in the kernel, development) • RETURN – Discontinue processing this user-defined chain and return from where it previously left
and making decisions on how they should be handled • Accounting – Monitor network traffic volumes by checking packet count and byte sizes • Connection tracking – Matching related packets (example, FTP, control/data transfer) • Packet Mangling – Modifying packet headers (net address, port,…) or payload
– SNAT (Source), DNAT (Destination), connection tracking • Masquerading – Special type of SNAT, computer rewrites packets to make them appear like they come from itself – Share internet connection with a dynamic IP • Port-Forwarding – Type of DNAT. Firewall accepts traffic to itself, but rewrites the packets to be destined to another machine. – Replies are rewritten as well to look like they come from itself • Load-balancing – Distributing connections across a group of internal hosts for higher throughput. – Example: port-forwarding so destination address is selected in a round-robin fashion
reach it from the outside? – Not without port forwarding :) • Which Tables and Chains are involved? – NAT PREROUTING – FILTER INPUT! Remember the flow! → – * Depending on the destination, FILTER FORWARD
iptables -t nat -A POSTROUTING -o eth0 -s 192.168.123.0/24 -j MASQUERADE • iptables -t nat -A POSTROUTING -s 192.168.123.0/24 -o eth0 -j SNAT --to-source 10.0.2.15 • Masquerading: we don’t know the source address ahead of time or can change, so we bind to the interface. – No intervention, but slight overhead • SNAT: we know the source address and is static – No (added) overhead, needs intervention should the address change
on port 8081, 8082 and 8083. Make available on port 8080 • Haven’t we seen this before? – NAT Prerouting DNAT + Filter INPUT (or FORWARD) – -m statistic