170 likes | 179 Views
Training. Firewalls An Introduction. Overview. Theory IP Packets, Filtering IP chains, Chain Policies Firewall Rules Filtering ATM Vision Interfaces Firewall Implementation Examples. IP Packets. 32 Bit. Version. IHL. Type of Service. Total Length. Identification. Flags.
E N D
Training Firewalls An Introduction
Overview • Theory • IP Packets, Filtering • IP chains, Chain Policies • Firewall Rules • Filtering • ATM Vision • Interfaces • Firewall Implementation • Examples
IP Packets 32 Bit Version IHL Type of Service Total Length Identification Flags Fragment offset Time to Live Protocol Header Checksum IP Header Source Address Destination Address Options Padding IP Data Data (1 Bytes – 64 kBytes) IHL: Internet Header Length
IP Filtering • Filtering can be performed on • Interfaces (Source or Destination) • Source address • Source port • Destination address • Destination port
IP Chains Loopback Device (lo) ACCEPT REDIRECT C H E C K S U M S A N I T Y R O U T I N G ACCEPT Input Chain Forward Chain Output Chain REJECT DENY REJECT DENY REJECT DENY DENY DENY LOCAL PROCESS
Chains • Default chains: • „input“ chain • 1st chain for received packets • „output“ chain • chain for all outgoing packets • „forward chain • chain for received packets with another destination than the local system • User defined chains • Any name (8 char. Max.) except „input“, „output“, „forward“ „ACCEPT“, „DENY“, „REJECT“, “REDIRECT” and „RETURN“ • grouping of rules (easier maintenance)
Policy • Firewall policies • ACCEPT Pass the packet • REJECT Discard the packet, but send response • DENY Discard the packet, no response
Firewall Rules • Rules are applied to a chain • Rules are defining a filter criteria • Multiple rules can exist per chain • Each packet traverses through the list of rules until a match occures • In case of a match the packet is treated according to the target of the rule • If there is no match the policy of the chain is taken as target • Targets are: „ACCEPT“, „REJECT“, „DENY“, „REDIRECT“, „RETURN“ or any user defined chain.
Filtering by Address • Source Address -s • Destination Address -d • Address Formats: • Address/Maskbits i.e. 192.168.0.0/24 • Adddress/Mask i.e. 192.168.0.0/255.255.255.0
Filtering by Interface • The interface is related to the chain: • „input“ chain: Interface the packet was received by • „output““ and „forward“ chain: Interface the packet will be send out
Filtering by Protocol • Option -p • Protocol names/numbers are listed in /etc/protocols • ICMP (1) – Internet Control Message Protocol • ECHO, REDIRECT, UNREACHABLE • TCP (6) – Transmission control Protocol • TELNET, SSH, RLOGIN, FTP, ... • UDP (17) – User datagram Protocol • SNMP, MAIL, DNS, ...
Filtering by Service • The service name or number follows a source or destination address • The service names and numbers are listed in /etc/services, i.e.: • Ranges are specified by min:max ftp-data 20 ftp 21 ssh 22 telnet 23 smtp 25 time 37 domain 53 http 80 pop3 110 ntp 123 snmp 161 snmptrap 162 syslog 514 router 520 timed 525 vision 9600
User defined Chains Received TCP packet from 192.168.1.1 to 1.2.3.4: Chain „input“ Rule1: -p icmp –j REJECT Chain „Test“ Rule2: -p TCP –j Test Rule1: -s 192.168.1.1 Rule2: -d 192.168.1.1 Rule3: -p UDP –j DENY
ATM Vision IP Interfaces ATM VISION clip0 clip0 eth0 10/100BaseT FIREWALL clip0 clip0 clip0 eth1 10BaseT lane0 LOCAL PROCESSES 2 * Ethernet Ports N * CLIP (Classical IP) N * LANE (LAN Emulation)
Commands • -P Set chain policy ipchains –P <chain> <policy> • -A Add rule ipchains –A <chain> <filter> [-j target] • -D Delete rule # of a chain ipchains –D <chain> <rule> • -F Delete all rules of a chain ipchains –F <chain> • -N Create a new chain ipchains –N <chain name> • -X Delete a chain ipchains –X <chain name>
Examples Drop all packets directed to 192.168.1.1: sysconf ipchains –A output –d 192.168.1.1/32 –j DENY Command Add Output chain Destination address Target DENY Accept only telnet connections from 10.0.0.1: sysconf ipcahins –P input –DENY sysconf ipchains –A input –s 10.0.0.1/32 23 –j ACCEPT Command Add Input chain Source address Target ACCEPT