Netfilter & Packet Dropping

Similar documents
What is Netfilter. Netfilter. Topics

Some of the slides borrowed from the book Computer Security: A Hands on Approach by Wenliang Du. Firewalls. Chester Rebeiro IIT Madras

Linux IP Networking. Antonio Salueña

IPtables and Netfilter

Netfilter Connection Tracking and NAT Implementation

Netfilter. Fedora Core 5 setting up firewall for NIS and NFS labs. June 2006

Packet Aggregation in Linux

The Research and Application of Firewall based on Netfilter

MONSTER. Managing an Operator s Network with Software Defined Networking and Segment Routing. Ing. Luca Davoli

Linux. Sirindhorn International Institute of Technology Thammasat University. Linux. Firewalls with iptables. Concepts. Examples

Cisco PCP-PNR Port Usage Information

NDN iptables match extension

Network Address Translation

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

netfilters connection tracking subsystem

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

sottotitolo A.A. 2016/17 Federico Reghenzani, Alessandro Barenghi

Università Ca Foscari Venezia

Once Only Drop Capability in the Linux Routing Software

A 10 years journey in Linux firewalling Pass the Salt, summer 2018 Lille, France Pablo Neira Ayuso

Suricata IDPS and Nftables: The Mixed Mode

IPv6 NAT. Open Source Days 9th-10th March 2013 Copenhagen, Denmark. Patrick McHardy

A proposed architecture for integrating Active Networks and MPLS 2 BACKGROUND

Evaluating the performance of Netfilter architecture in Private Realm Gateway

EVASIVE INTERNET PROTOCOL: END TO END PERFORMANCE

Network and Filesystem Security

Netfilter. Netfilter Frameworks CHAPTER 9

Firewalling. Alessandro Barenghi. May 19, Dipartimento di Elettronica e Informazione Politecnico di Milano barenghi - at - elet.polimi.

Toward an ebpf-based clone of iptables

Network Security Fundamentals

Linux Firewalls. Frank Kuse, AfNOG / 30

Firewalls. IT443 Network Security Administration Slides courtesy of Bo Sheng

2 Setting up the RDMA Framework for Development

Scalable Computing: Practice and Experience Volume 11, Number 4, pp

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

Computer Science Department


CS Computer and Network Security: Firewalls

2 Setting up the RDMA Framework for Development

Kernel Modules. Kartik Gopalan

CSC 474/574 Information Systems Security

python-iptables Documentation

Netfilter updates since last NetDev. NetDev 2.2, Seoul, Korea (Nov 2017) Pablo Neira Ayuso

Certification. Securing Networks

Design and implementation of packet filtering algorithm in 6LoWPAN access Internet

UNIVERSITY OF BOLTON SCHOOL OF CREATIVE TECHNOLOGIES COMPUTER AND NETWORK SECURITY SEMESTER TWO EXAMINATIONS 2016/2017 NETWORK SECURITY

Packet Filtering and NAT

Netfilter updates since last NetDev. NetDev 2.2, Seoul, Korea (Nov 2017) Pablo Neira Ayuso

Linux Kernel Module Programming. Tushar B. Kute,

Assignment 3 Firewalls

The Linux Network Subsystem

Firewalls. Firewall. means of protecting a local system or network of systems from network-based security threats creates a perimeter of defense

Firewalls. October 13, 2017

Understanding Load Balance and Policy Route. andrew zheng! edcwifi co limited

7.3 Simplest module for embedded Linux drivers

TD(08)006. The 11th COST 290 MC Meeting. Tampere University of Technology (TUT), Finland, May 27 28, WAN Emulator Software Tool

Network Administration

What is an L3 Master Device?

UNIVERSITY OF BOLTON SCHOOL OF CREATIVE TECHNOLOGIES COMPUTER NETWORKS AND SECURITY SEMESTER TWO EXAMINATIONS 2017/2018 NETWORK SECURITY

IP micromobility and QoS virtual network testbed

Lab Exercise Sheet 2 (Sample Solution)

Software Layers. Device Drivers 4/15/2013. User

Dual-stack Firewalling with husk

iptables and ip6tables An introduction to LINUX firewall

Module: Firewalls. Professor Patrick McDaniel Fall CSE543 - Introduction to Computer and Network Security

Make Your Own Linux Module CS 444/544

Packet Sniffing and Spoofing

Network Address Translation (NAT) Contents. Firewalls. NATs and Firewalls. NATs. What is NAT. Port Ranges. NAT Example

while the LAN interface is in the DMZ. You can control access to the WAN port using either ACLs on the upstream router, or the built-in netfilter

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

Abstraction via the OS. Device Drivers. Software Layers. Device Drivers. Types of Devices. Mechanism vs. Policy. Jonathan Misurda

Masquerading Made Simple HOWTO

CS 356: Computer Network Architectures. Lecture 10: IP Fragmentation, ARP, and ICMP. Xiaowei Yang

Firewall Management With FireWall Synthesizer

Laboratory 2 Dynamic routing using RIP. Iptables. Part1. Dynamic Routing

We are IntechOpen, the first native scientific publisher of Open Access books. International authors and editors. Our authors are among the TOP 1%

AODV Implementation Design and Performance Evaluation

Introduction to Firewalls using IPTables

Proxies in PromethOS. Gabriel Mueller. Semester Thesis SA th October 2006

Lecture 1. Virtualization, Linux kernel (modules and networking) and Netfilter Winter 15/16. Roei Ben-Harush 2015

Network Address Translation (NAT) Background Material for Overlay Networks Course. Jan, 2013

TCP/IP Stack Introduction: Looking Under the Hood!

MANAGING THE CAR CLOUD CONNECTION.

Problem Max. Points Act. Points Grader

Michael Rash DEFCON 12 07/31/2004

tcconfig Documentation

itmbench: Generalized API for Internet Traffic Managers

THE INTERNET PROTOCOL/1

Computer Security Spring Firewalls. Aggelos Kiayias University of Connecticut

NetFPGA Hardware Architecture

Dropping Packets in Ubuntu Linux using tc and iptables

Definition of firewall

THE INTERNET PROTOCOL INTERFACES

The Internet Protocol

Linux Kernel Development (LKD)

Firewall Configuration and Assessment

Ref: A. Leon Garcia and I. Widjaja, Communication Networks, 2 nd Ed. McGraw Hill, 2006 Latest update of this lecture was on

Loadable Kernel Modules

Working with Kernel Modules Lab Wind River Systems, Inc

Veryx ATTEST TM. Sample Test cases Overview. Conformance Test Suite. Internet Protocol version 4 (IPv4) Part Number: T / TCLS IPv /1.

Transcription:

Netfilter & Packet Dropping Netfilter provides a set of hooks is several points of the kernel network stack. The hooks can be exploited to define custom functions for manipulating IP packets Dropping Manipulation of header fields Etc. The hooks are triggered by the kernel after the execution of the functions that implement the network procedures

Netfilter Architecture An incoming IP packet travels in the kernel following a path

Netfilter Architecture Kernel path for incoming packets 1.Sanity checks (i.e., not truncated, IP checksum OK, etc) 2.Routing decision (it decides whether the packet is destined for another interface, or a local process) Local process: the netfilter framework is called again for the NF_IP_LOCAL_IN hook Another interface: the netfilter framework is called for the NF_IP_FORWARD hook 3.Final step (the packet passes a final netfilter hook the NF_IP_POST_ROUTING hook)

Netfilter Architecture When a hook is triggered, a customized function can manipulate the packet content Kernel modules can register to listen at any of the hooks described in the previous slide After manipulating a packet, the module returns a code to the claling function: NF_ACCEPT: continue traversal as normal NF_DROP: drop the packet; don't continue traversal NF_STOLEN: stole the packet from the path NF_QUEUE: queue the packet (for userspace handling) NF_REPEAT: call this hook again

Netfilter & Iptables The iptables tool has been developed over the netfilter framework Kernel modules can register a new table, and ask for a packet to traverse a given table Hooks registered with netfilter Prerouting Forwarding Postrouting Conntrack Mangle Mangle Mangle Src NAT Dst NAT Filter Conntrack QDisc

Registration of filtering functions Structure containing the function handle: static struct nf_hook_ops netfilter_ops_pre; Customized attributes of the hook: netfilter_ops_pre.hook = hook_pre_routing; netfilter_ops_pre.pf = PF_INET; netfilter_ops_pre.hooknum = NF_INET_PRE_ROUTING; netfilter_ops_pre.priority = NF_IP_PRI_FIRST; Registration of the hook ret = nf_register_hook(&netfilter_ops_pre);

Registration of filtering functions hook_pre_routing is the function implementing the packet filtering PF_INET: Internet Protocol Family NF_INET_PRE_ROUTING: the function is triggered before the routing decision NF_IP_PRI_FIRST: the registered function has the highest priority of execution The unregistration is performed using the following function: nf_unregister_hook(&netfilter_ops_pre);

Kernel Modules The kernel module implementing the filtering function needs to be cross-compiled for the um architecture The Makefile is very similar to the Makefile used to compile kernel modules In addition to indicating the directory which contains the headers and the objects of the Netkit kernel, it is necessary to define the architectures of the host and target machines ARCH=um SUBARCH=i386

Kernel Modules Makefile for the pkt_drop module obj-m += pkt_drop.o KERNELPATH="path/to/kernel/src" all: make -C $(KERNELPATH) M=$(shell pwd) ARCH=um SUBARCH=i386 modules clean: make -C $(KERNELPATH) M=$(shell pwd) ARCH=um SUBARCH=i386 clean

Example Packet dropping: A simple linux kernel module which defines a function that drops data packets before performing the routing decision. The function is registerd as a PREROUTING hook Note that some of the auxiliary functions defined by the kernel to access the header fields may NOT work See the code pkt_drop.c

Example pc1 pc2 Collision Domain B 10.0.0.0/8 Collision Domain C 11.0.0.0/8 r1 Collision Domain A 172.20.0.0/16 r2

Example The command insmod is usually used to load kernel modules insmod pkt_drop.ko drop_deg=5 (5 out of 10 ICMP echo reqs will be discarded) The command rmmod is usually used to unload kernel modules rmmod pkt_drop modprobe is an alternative command to load and unload modules modprobe -i pkt_drop.ko drop_deg=5 modprobe -r pkt_drop.ko