Linux Networking: IP Packet Filter Firewalling



Similar documents
Firewalls. Firewall types. Packet filter. Proxy server. linux, iptables-based Windows XP s built-in router device built-ins single TCP conversation

Firewalls. October 23, 2015

+ iptables. packet filtering && firewall

Firewalls. Chien-Chung Shen

1:1 NAT in ZeroShell. Requirements. Overview. Network Setup

Linux firewall. Need of firewall Single connection between network Allows restricted traffic between networks Denies un authorized users

Linux Routers and Community Networks

Linux Firewall Wizardry. By Nemus

Firewall. IPTables and its use in a realistic scenario. José Bateira ei10133 Pedro Cunha ei05064 Pedro Grilo ei09137 FEUP MIEIC SSIN

Track 2 Workshop PacNOG 7 American Samoa. Firewalling and NAT

Optimisacion del ancho de banda (Introduccion al Firewall de Linux)

ipchains and iptables for Firewalling and Routing

Chapter 7. Firewalls

Assignment 3 Firewalls

Linux Firewall. Linux workshop #2.

Worksheet 9. Linux as a router, packet filtering, traffic shaping

How to Turn a Unix Computer into a Router and Firewall Using IPTables

Linux Firewalls (Ubuntu IPTables) II

CS Computer and Network Security: Firewalls

Linux: 20 Iptables Examples For New SysAdmins

Lab Objectives & Turn In

Network security Exercise 9 How to build a wall of fire Linux Netfilter

Network Security Exercise 10 How to build a wall of fire

How To Set Up An Ip Firewall On Linux With Iptables (For Ubuntu) And Iptable (For Windows)

CS Computer and Network Security: Firewalls

Netfilter / IPtables

Intro to Linux Kernel Firewall

THE HONG KONG POLYTECHNIC UNIVERSITY Department of Electronic and Information Engineering

Firewall implementation and testing

Linux Administrator (Advance)

Netfilter. GNU/Linux Kernel version 2.4+ Setting up firewall to allow NIS and NFS traffic. January 2008

CSC574 - Computer and Network Security Module: Firewalls

Main functions of Linux Netfilter

Packet Filtering Firewall

Dynamic Host Configuration Protocol (DHCP) 02 NAT and DHCP Tópicos Avançados de Redes

Linux Cluster Security Neil Gorsuch NCSA, University of Illinois, Urbana, Illinois.

Definition of firewall

Building a Home Gateway/Firewall with Linux (aka Firewalling and NAT with iptables )

CSE331: Introduction to Networks and Security. Lecture 12 Fall 2006

Firewalls, NAT and Intrusion Detection and Prevention Systems (IDS)

CIT 480: Securing Computer Systems. Firewalls

Protecting and controlling Virtual LANs by Linux router-firewall

CIT 480: Securing Computer Systems. Firewalls

Linux MDS Firewall Supplement

Managing Multiple Internet Connections with Shorewall

Firewalls N E T W O R K ( A N D D ATA ) S E C U R I T Y / P E D R O B R A N D Ã O M A N U E L E D U A R D O C O R R E I A

ΕΠΛ 674: Εργαστήριο 5 Firewalls

How To Set Up A Network Map In Linux On A Ubuntu 2.5 (Amd64) On A Raspberry Mobi) On An Ubuntu (Amd66) On Ubuntu 4.5 On A Windows Box

Firewall Examples. Using a firewall to control traffic in networks

How To Understand A Firewall

Firewalls with IPTables. Jason Healy, Director of Networks and Systems

Linux Networking Basics

Firewalls (IPTABLES)

TECHNICAL NOTES. Security Firewall IP Tables

Install and configure a Debian based UniFi controller

FIREWALL AND NAT Lecture 7a

Internet Protocol: IP packet headers. vendredi 18 octobre 13

ΕΠΛ 475: Εργαστήριο 9 Firewalls Τοίχοι πυρασφάλειας. University of Cyprus Department of Computer Science

Firewalls. Pehr Söderman KTH-CSC

Load Balancing Trend Micro InterScan Web Gateway

Network Security. Routing and Firewalls. Radboud University Nijmegen, The Netherlands. Autumn 2014

Firewall. Vyatta System. REFERENCE GUIDE IPv4 Firewall IPv6 Firewall Zone Based Firewall VYATTA, INC.

10.4. Multiple Connections to the Internet

CIS 433/533 - Computer and Network Security Firewalls

Linux MPS Firewall Supplement

Load Balancing Sophos Web Gateway. Deployment Guide

Firewall. Vyatta System. REFERENCE GUIDE IPv4 Firewall IPv6 Firewall Zone Based Firewall VYATTA, INC.

CSE543 - Computer and Network Security Module: Firewalls

How to protect your home/office network?

How to Secure RHEL 6.2 Part 2

Packet filtering with Linux

21.4 Network Address Translation (NAT) NAT concept

Load Balancing Clearswift Secure Web Gateway

Lecture 18: Packet Filtering Firewalls (Linux) Lecture Notes on Computer and Network Security. by Avi Kak

Load Balancing McAfee Web Gateway. Deployment Guide

Project 2: Firewall Design (Phase I)

Internet Firewall CSIS Internet Firewall. Spring 2012 CSIS net13 1. Firewalls. Stateless Packet Filtering

Module: Firewalls. Professor Patrick McDaniel Spring CMPSC443 - Introduction to Computer and Network Security

Load Balancing Bloxx Web Filter. Deployment Guide

Linux Home Networking II Websites At Home

Stateful Firewalls. Hank and Foo

Network Address Translation (NAT)

Matthew Rossmiller 11/25/03

Guardian Digital WebTool Firewall HOWTO. by Pete O Hara

Cisco Configuring Commonly Used IP ACLs

Firewall Firewall August, 2003

Firewall Configuration and Assessment

Lecture 18: Packet Filtering Firewalls (Linux) Lecture Notes on Computer and Network Security. by Avi Kak

Computer Firewalls. The term firewall was originally used with forest fires, as a means to describe the

Linux as an IPv6 dual stack Firewall

VENKATAMOHAN, BALAJI. Automated Implementation of Stateful Firewalls in Linux. (Under the direction of Ting Yu.)

IP Address: the per-network unique identifier used to find you on a network

Technical Support Information

NAT REFERENCE GUIDE. VYATTA, INC. Vyatta System NAT. Title

Transcription:

Linux Networking: IP Packet Filter Firewalling David Morgan Firewall types Packet filter Proxy server 1

Linux Netfilter Firewalling Packet filter, not proxy Centerpiece command: iptables Starting point: packet structure details IP packet structure Source Address Destination Address Protocol Number IP s Data Payload 2

Payload types - subprotocols Src Dest 17 UDP (17) packet Src Dest 1 ICMP (1) packet Src Dest 6 TCP (6) packet and others UDP packet structure Source Port Destination Port UDP s Data Payload 3

UDP/IP packet structure Source Address Destination Address Source Port UDP s Data Payload Destination Port IP s payload is a UDP packet Address? Port? Address number a Machine designator identifies one among multiple machines on a network 19818620355 identifies linuxcom on internet 19813724143 identifies whitehousegov Port number a Task designator identifies one among multiple tasks in a machine 80 identifies web server running on linuxcom 22 identifies secure shell server running on linuxcom 4

Address? Port? Two address-port pairs uniquely define a process to process conversation across a network Source Address Destination Address Source Port Destination Port eg, when President Bush browses linuxcom: 19813724143 (whitehousegov) 19818620355 (linuxcom) 62102 80 TCP packet structure Source Port Sequence # Destination Port Acknowledgment TCP s Data Payload 5

TCP/IP packet structure Source Address Source Port Destination Address Destination Port Sequence # TCP s Data Payload Acknowledgment IP s payload is a TCP packet ICMP packet structure ICMP-type Code Checksum header of subject/wayward IP packet or other ICMP-type dependent payload 6

ICMP/IP packet structure Source Address Destination Address ICMP-type Code Checksum header of subject/wayward IP packet or other ICMP-type dependent payload IP s payload is an ICMP packet UDP packet example Used for internet name service inquiries [root@emach1 /root]# ping wwwacmecom 63370 53 wwwacmecom s IP address please 7

TCP packet example Used for webserver-to-webbrowser traffic 80 1050 Sequence # Acknowledgment website text & images ICMP packet example Used for echo (ping) requests [root@emach1 /root]# ping wwwacmecom 8 Code Checksum echo request are you there? 8

ICMP packet example and for echo (ping) relies 0 Code Checksum echo reply yes I m here Firewall = ruleset An in-memory datastructure by whose elements packets that appear at interfaces are evaluated A corresponding series of commands, each invocation of which populates the table with a single element Elements are called rules 9

Firewall - iptables low level - iptables command (to compose individual rule) middle level - Ziegler firewall (a particular ruleset) high level firewalllocal (custom extensions to firewall) Iptables organization Tables (have chains) filter table nat table Chains (contain rules) filter nat INPUT chain PREROUTING chain OUTPUT POSTROUTING FORWARD 10

An Individual Rule Condition - Examines and qualifies a packet Action - Operates on the packet if it qualifies compare programming language if structure What a Rule says If a packet s header looks like this, then here s what to do with the packet looks like this eg goes to a certain (range of) address(es) or uses the telnet port, 23 or is an ICMP packet what to do eg pass it discard it 11

iptables -t filter -A OUTPUT -o eth1 -p tcp --sport 23 --dport 1024:65535 -s 19216840/24 -d 0000/0 j ACCEPT Table for this rule Rule action -A add rule to chain/list -D delete rule from chain/list -P default policy for chain/list Rule chain/list (tables contain chains) INPUT OUTPUT FORWARD PREROUTING POSTROUTING Packet qualifiers By interface and direction protocol source port number(s) destination port number(s) source address (range) destination address (range) Packet disposition ACCEPT DROP REJECT SNAT DNAT What a Chain is ordered checklist of regulatory rules Multiple rules, for packets with particular characteristics Single rule for default (catch-all) policy operation Packet tested against rules in succession First matching rule determines what to do to packet If packet matches no rule Chain s default policy determines what to do to packet 12

Operationally comparable if [ condition A ] action Alpha; exit endif if [condition B ] action Beta; exit endif if [condition C ] action Gamma; exit endif action <default>; exit What happens? action for first true condition (if any) otherwise default action Multiple chains Input chain When arriving at an interface, do we let a packet come in? Output chain When departing from an interface, do we let a packet go out? Forwarding chain When traversing this machine to another, do we let a packet pass between interfaces? 13

Filter traversal by packets incoming routing decision FORWARD outgoing INPUT OUTPUT local process local process A 4-rule filtering firewall iptables -t filter -A INPUT -i eth1 -p tcp --sport 1024:65535 --dport 23 -s 0000/0 -d 19216841/32 j ACCEPT iptables -t filter -A OUTPUT -o eth1 -p tcp --sport 23 --dport 1024:65535 -s 19216841/32 -d 0000/0 j ACCEPT iptables -t filter -P INPUT DROP iptables -t filter -P OUTPUT DROP Executed in chronological sequence as shown, resultant 2-chain firewall permits telnet access between this machine 19216841 and others via eth1 And nothing else 14

Priority of chronology = priority of effect iptables -t filter -A INPUT -i eth1 -p tcp --sport 1024:65535 --dport 23 -s 64111/32 -d 19216841/32 j DROP iptables -t filter -A INPUT -i eth1 -p tcp --sport 1024:65535 --dport 23 -s 0000/0 -d 19216841/32 j ACCEPT iptables -t filter -A OUTPUT -o eth1 -p tcp --sport 23 --dport 1024:65535 -s 19216841/32 -d 0000/0 j ACCEPT iptables -t filter -P INPUT DROP iptables -t filter -P OUTPUT DROP EXCEPT no telnet from machine 64111, because first rule eclipses second since it preceded it (Second not reached, never applied) nat table: rules that alter packet Masquerading iptables -t nat -A POSTROUTING -o eth1 -s 10000/8 -j SNAT --to 21683185193 Pinholing (port forwarding) iptables -t nat -A PREROUTING -i eth1 -d 21683185193/32 -p tcp --dport 5631 -j DNAT --to 21683185193 15

Firewall ruleset philosophies Optimistic/lax set everything open apply selective closures Pessimistic/strict set everything closed apply selective openings Set everyting closed iptables -P INPUT DROP iptables -P OUTPUT DROP iptables -P FORWARD DROP 16

Firewall persistence firewall is memory-resident volatile across reboot re-create at bootime by init script containing individual iptables commands (eg, Zeigler), or iptables-restore and iptables-save (eg, RedHat) Init script basics UNIX has a conventional method to uniformly start/stop services one script per service in /etc/rcd/initd scripts accept parameters start, stop, or restart if firewall s script is: /etc/rcd/initd/firewall start it with: /etc/rcd/initd/firewall start, or service firewall start 17

Zeigler-style firewall Zeigler firewall in /etc/rcd/initd/firewall configuration file in /etc/firewall/firewallconf firewall script full of individual iptables invocations (ie, rules) config files set variables for conditional evaluation in main firewall script Zeigler Firewall - files & organization Config file /etc/firewall/firewallconfiptables ping = ok telnet = not ok ftp= ok Customizations file /etc/firewall/firewalllocaliptables let managers ssh allow intra-traffic on our DMZ Customizations, executed early, have priority inform supplement Main firewall /etc/rcd/initd/firewall #!/bin/sh # # firewall start/stop script --- # read the config file for selections /etc/firewall/firewallconfiptables --- # call local customizations file /etc/firewall/firewalllocaliptables --- --- if <ping ok> rule to allow ping if <telnet ok> rule to allow telnet if <ftp ok> rule to allow ftp 18

RedHat-default-style firewall firewall stored whole in /etc/sysconfig/iptables utility pair: iptables-restore, iptables-save use their own (ascii) format installtime high/medium/low security write different /etc/sysconfig/iptables init script /etc/rcd/initd/iptables iptablesrestores from /etc/sysconfig/iptables modified firewall can be stored for future by service iptables save RedHat Firewall - files & organization Init script /etc/rcd/initd/iptables Executables /sbin/iptables-restore /sbin/iptables-save #!/bin/sh # # firewall start/stop script --- --- --- --- start() iptables-restore < /etc/sysconfig/iptables stop() restart() save() iptables-save > /etc/sysconfig/iptables Rules-storage file /etc/sysconfig/iptables (in iptables-save/restore format) *filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0] :RH-Lokkit-0-50-INPUT - [0:0] -A INPUT -j RH-Lokkit-0-50-INPUT -A RH-Lokkit-0-50-INPUT -i lo -j ACCEPT etc 19

Please see http://wwwiptablesorg/ Linux Firewalls, 2 nd edition, Robert Zeigler, New Riders, 2002 http://linux-firewall-toolscom/ (Zeigler s site) http://wwwmalibytenet/iptables/scripts/fwscri ptshtml (3 rd -party derivative of Ziegler fw) 20