Www.LinuxCabal.com.

Slides:



Advertisements
Similar presentations
Ipchains and Iptables Linux operating system natively supports packet-filtering rules: Kernel versions 2.2 and earlier support the ipchains command. Kernel.
Advertisements

Leone From global measurements to local management UC3M: inHome NAT detection RFC recommender ICMP UDP TCP Miguel Ángel Díaz, Francisco Valera.
Mateti/PacketFilters1 Packet Filtering Prabhaker Mateti Prabhaker Mateti.
1 Network Address Translation (NAT) Relates to Lab 7. Module about private networks and NAT.
Packet Filtering CS-480b Dick Steflik. Stateless Packet Filters A border router configured to pass or reject packets based on information in the header.
1 Firewall & IP Tables. 2 Firewall IP Tables FIREWALLS All previous security measures cannot prevent Eve from sending a harmful message to a system.
LİNUX-ROUTER-1 Gw1: GW2: ISP1 eth eth /30 LİNUX-ROUTER-2 Gw1: Gw2: eth1.
System Administration Network Tools. ping Test connectivity / latency (RTT) ICMP echo request/reply Variants ◦ARP ping  Send ARP instead  May also ping.
CIS 193A – Lesson10 Protecting Your Network. CIS 193A – Lesson10 Focus Question What information contained in packets can be used as matching criteria.
Cs490ns - cotter1 Firewalls What they do. How they work.
IPTables Tips and Tricks: More Than Just ACCEPT and DROP
NetFilter – IPtables Firewall –Series of rules to govern what Kind of access to allow on your system –Packet filtering –Drop or Accept packets NAT –Network.
07/11/ L10/1/63 COM342 Networks and Data Communications Ian McCrumRoom 5B18 Tel: voice.
Packet Filtering and Firewall
IPtables Objectives –to learn the basics of iptables Contents –Start and stop IPtables –Checking IPtables status –Input and Output chain –Pre and Post.
Computer Networks II By: Ing. Hector M Lugo-Cordero, MS.
Iptables and apache 魏凡琮 (Jerry Wei). Agenda iptables apache.
Firewalls A device that screens incoming and outgoing network traffic and allows or disallows traffic based on a set of rules The “device” –Needs at least.
1 Tutorial 6: Networking Utilities & Firewall. 2 Internet Control Message Protocol (ICMP) designed to compensate for the deficiencies of IP protocol.
Access Control List (ACL)
Review the key networking concepts –TCP/IP reference model –Ethernet –Switched Ethernet –IP, ARP –TCP –DNS.
Firewalling With Netfilter/Iptables. What Is Netfilter/Iptables? Improved successor to ipchains available in linux kernel 2.4/2.6. Netfilter is a set.
IPtables Objectives Contents Practicals Summary
 network appliances to filter network traffic  filter on header (largely based on layers 3-5) Internet Intranet.
Firewall Tutorial Hyukjae Jang Nc lab, CS dept, Kaist.
Le firewall Technofutur. Table des matières Schémas du réseau Routage sans VPN Routage avec VPN Le NAT Le firewall.
CSN09101 Networked Services Week 6 : Firewalls + Security Module Leader: Dr Gordon Russell Lecturers: G. Russell.
Network Configuration in Linux
1 Network Address Translation (NAT) and Dynamic Host Configuration Protocol (DHCP) Relates to Lab 7. Module about private networks and NAT.
ACCESS CONTROL LIST.
Unit - III. Providing a Caching Proxy Server (1) A caching proxy server is software that stores (caches) frequently requested internet objects such as.
Firewall C. Edward Chow CS691 – Chapter 26.3 of Matt Bishop Linux Iptables Tutorial by Oskar Andreasson.
IPTABLES -FIREWALL. IPTABLES IPTABLE BASIC IMPORTANT FILES SIMPLE SECURITY IMPLEMENTATION (GRAPHICAL WAY) IMPLEMENTING FIREWALL RULE WITH EXAMPLE (COMMAND.
Introduction to Linux Firewall
Allow / express forward Drop NAT Policy Engine Enhancement Frame Ingress WebOS Policy Engine MAC source/dest address IP /not IP source/dest address /range.
A network primer (or refresher) Henning Schulzrinne (based on slides from Kurose/Ross)
Access Control List (ACL) W.lilakiatsakun. Transport Layer Review (1) TCP (Transmission Control Protocol) – HTTP (Web) – SMTP (Mail) UDP (User Datagram.
Firewalls Chien-Chung Shen The Need for Firewalls Internet connectivity is essential –however it creates a threat (from the network) vs.
LINUX® Netfilter The Linux Firewall Engine. Overview LINUX® Netfilter is a firewall engine built into the Linux kernel Sometimes called “iptables” for.
Linux Firewall Iptables.
Routing with Linux 'cause you really love the command line
Installing Systems on a Simulated Subnet North Carolina System Administrators.
防火牆 Firewall All rights reserved. No part of this publication and file may be reproduced, stored in a retrieval system, or transmitted in any form or.
Basic Linux Desktop Security © Konrad Rosenbaum this presentation is protected by the GNU General Public License version 2 or any newer.
Firewalls. A Firewall is: a) Device that interconnects two networks b) Network device that regulates the access to an internal network c) Program that.
Firewalls and DMZ Dr. X. Firewalls Filtering traffic based on policy Policy determines what is acceptable traffic Access control over traffic Accept or.
Managing and Directing Network Traffic with Linux
Network and System Security Risk Assessment
IPtables Objectives to learn the basics of iptables Contents
Firewall Operating systems I800
Network Address Translation (NAT)
Advanced Cybersecurity
ECE 544: Middlebox lab Abhigyan Sharma.
Mateti/PacketFilters
© 2003, Cisco Systems, Inc. All rights reserved.
Network Address Translation (NAT)
Unix Linux Administration I
Network and System Security Risk Assessment
Packet Filtering Dick Steflik.
IPtables Objectives to learn the basics of iptables Contents
IPtables Objectives Contents Practicals Summary
Chapter 4: Access Control Lists (ACLs)
Setting Up Firewall using Netfilter and Iptables
Firewalls By conventional definition, a firewall is a partition made
From ACCEPT to MASQUERADE Tim(othy) Clark (eclipse)
Firewalls.
Chapter 4: outline 4.1 Overview of Network layer data plane
Presentation transcript:

www.LinuxCabal.com

Un Lugar Donde Confiar Muros Contrafuegos Con Netfilter/IPTables

Un Lugar Donde Confiar

Un Lugar Donde Confiar

Un Lugar Donde Confiar

Un Lugar Donde Confiar

Un Lugar Donde Confiar

Un Lugar Donde Confiar

Un Lugar Donde Confiar

Un Lugar Donde Confiar

1er. Generation: ipFWadmin Un Lugar Donde Confiar 1er. Generation: ipFWadmin 2nd. Generation: ipChains 3re. Generation: Netfilter/ipTables

Un Lugar Donde Confiar

ISO/OSI Model Un Lugar Donde Confiar Application Presentation Session Transport Network Link Physical

Un Lugar Donde Confiar Tables filter nat raw mangle

Un Lugar Donde Confiar raw PREROUTING OUTPUT

mangle INPUT OUTPUT FORWARD PREROUTING POSTROUTING Un Lugar Donde Confiar mangle INPUT OUTPUT FORWARD PREROUTING POSTROUTING

Un Lugar Donde Confiar nat PREROUTING OUTPUT POSTROUTING

NAT Un Lugar Donde Confiar 192.168.1.51 eth0 207.214.84.142 eth0 eth1 192.168.51.1

Un Lugar Donde Confiar filter INPUT OUTPUT FORWARD

Un Lugar Donde Confiar

RULES/REGLAS iptables [-t table] -N Chain Un Lugar Donde Confiar RULES/REGLAS iptables [-t table] -N Chain iptables [-t table] -A Chain RuleSpec iptables [-t table] -F [Chain] iptables [-t table] -L [Chain] iptables [-t table] -I Chain [#] RuleSpec iptables [-t table] -D Chain # iptables [-t table] -E OldChain NewChain iptables [-t table] -P Chain Target iptables [-t table] -R Chain # RuleSpec

Parámetros [!] -i, --in-interface nombre Un Lugar Donde Confiar Parámetros [!] -i, --in-interface nombre [!] -o, --out-interface nombre [!] -s, --source dirección/[mascara] [!] -d, --destinación dirección/[mascara]

-p, --protocol tcp|udp|icmp|all Un Lugar Donde Confiar -p, --protocol tcp|udp|icmp|all [!] --dport puerto[:puerto] [!] --sport puerto[:puerto] [!] --tcp-flags mask oblig Ops: SYN ACK FIN RST URG PSH ALL NONE [!] --syn [!] --tcp-option número

-m, --match Un Lugar Donde Confiar iprange [!] --src-range ip-ip iprange [!] --dst-range ip-ip mac [!] --mac-source xx:xx:xx:xx:xx:xx multiport [!] --source-ports puerto[,puerto[,puerto:puerto...]] multiport [!] --destination-ports puerto[,puerto[,puerto:puerto...]] multiport [!] --ports puerto[,puerto[,puerto:puerto...]] owner [!] --uid-owner # [!] --gid-owner # [!] --pid-owner # conntrack --ctstate INVALID|NEW|ESTABLISHED|RELATED tcp|udp [!] --source-port puerto[:puerto] tcp|udp [!] --destination-port puerto[:puerto] tcp [!] --tcp-flags mask oblig Ops: SYN|ACK|FIN|RST|URG|PSH|ALL [!] --syn [!] --tcp-option número

-m, --match connlimit Un Lugar Donde Confiar : # limit the number of parallel HTTP requests to 16 per class C sized network (24 bit netmask) iptables -p tcp --syn --dport 80 -m connlimit --connlimit-above 16 --connlimit-mask 24 -j REJECT

-j Targets ACCEPT QUEUE User Defined DROP RETURN Chain Un Lugar Donde Confiar -j Targets ACCEPT QUEUE User Defined DROP RETURN Chain REJECT --reject-with type LOG --log-prefix --log-level BALANCE --to-destination ipaddr-ipaddr MASQUERADE SNAT DNAT REDIRECT --to-ports puerto[-puerto]

Vamos crear un muro contrafuego Un Lugar Donde Confiar Vamos crear un muro contrafuego Verifica que tiene FORWARD_IPV4=yes en su /etc/sysconfig/network O net.ipv4.ip_forward = 1 en su /etc/sysctl.conf service iptables start Iptables-save

Un Lugar Donde Confiar Muro de Fuego eth0 LAN Inalámbrica Hub/Switch Router/ADSLMódem Muro de Fuego eth0 LAN Inalámbrica Hub/Switch eth2 LAN

iptables -t raw -P PREROUTING ACCEPT Un Lugar Donde Confiar iptables -t raw -P PREROUTING ACCEPT iptables -t mangle -P OUTPUT ACCEPT iptables -t nat -P OUTPUT ACCEPT iptables -t filter -P INPUT ACCEPT

iptables-save Un Lugar Donde Confiar # Generated by iptables-save v1.4.0 on Mon Sep 8 16:45:26 2008 *filter :INPUT ACCEPT [29:2054] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [17:2426] COMMIT # Completed on Mon Sep 8 16:45:26 2008 *nat :PREROUTING ACCEPT [1:42] :POSTROUTING ACCEPT [1:132] :OUTPUT ACCEPT [1:132] *mangle :PREROUTING ACCEPT [37:2508] :INPUT ACCEPT [37:2508] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [24:3320] :POSTROUTING ACCEPT [24:3320] COMMIT # Completed on Mon Sep 8 16:45:26 2008 # Generated by iptables-save v1.4.0 on Mon Sep 8 16:45:26 2008 *raw :PREROUTING ACCEPT [39:2612] :OUTPUT ACCEPT [26:3600]

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE Un Lugar Donde Confiar iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE o iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to-source 192.168.51.1

iptables-save Un Lugar Donde Confiar # Generated by iptables-save v1.4.0 on Mon Sep 8 16:57:16 2008 *nat :PREROUTING ACCEPT [1:42] :POSTROUTING ACCEPT [12:968] :OUTPUT ACCEPT [12:968] -A POSTROUTING -o eth0 -j SNAT --to-source 192.168.51.1 COMMIT # Completed on Mon Sep 8 16:57:16 2008

Un Lugar Donde Confiar iptables -t filter -N block iptables -A block -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT iptables -A block -i eth1 -m conntrack --ctstate NEW -j ACCEPT iptables -A block -j LOG --log-prefix "IPTables:block " --log-level 6 iptables -A block -j DROP

iptables-save Un Lugar Donde Confiar # Generated by iptables-save v1.4.0 on Mon Sep 8 17:09:37 2008 *filter :INPUT ACCEPT [768:36126] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [746:61346] :block - [0:0] -A block -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT -A block -i eth1 -m conntrack --ctstate NEW -j ACCEPT -A block -j LOG --log-prefix "IPTables:block " --log-level 6 -A block -j DROP COMMIT # Completed on Mon Sep 8 17:09:37 2008

iptables -A FORWARD -j block Un Lugar Donde Confiar iptables -A FORWARD -j block

iptables-save Un Lugar Donde Confiar # Generated by iptables-save v1.4.0 on Mon Sep 8 19:35:06 2008 *filter :INPUT ACCEPT [3060:148984] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [2997:236170] :block - [0:0] -A FORWARD -j block -A block -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT -A block -i eth1 -m conntrack --ctstate NEW -j ACCEPT -A block -j LOG --log-prefix "IPTables:block " --log-level 6 -A block -j DROP COMMIT # Completed on Mon Sep 8 19:35:06 2008

Un Lugar Donde Confiar iptables -A INPUT ! -i eth2 -p tcp --dport 22 -j ACCEPT iptables -A INPUT ! -i eth2 -p tcp --dport 25 -j ACCEPT iptables -A INPUT ! -i eth2 -p tcp --dport 53 -j ACCEPT iptables -A INPUT ! -i eth2 -p udp --dport 53 -j ACCEPT iptables -A INPUT ! -i eth2 -p tcp --dport 80 -j ACCEPT iptables -A INPUT ! -i eth2 -p tcp --dport 443 -j ACCEPT iptables -A INPUT ! -i eth2 -p tcp --dport 993 -j ACCEPT iptables -A INPUT ! -i eth2 -p tcp --dport 995 -j ACCEPT iptables -A INPUT -i lo -j ACCEPT iptables -A INPUT -j block

iptables-save Un Lugar Donde Confiar *filter :INPUT ACCEPT [3097:151128] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [3187:276550] :block - [0:0] -A INPUT -i eth2 -p tcp -m tcp --dport 22 -j ACCEPT -A INPUT -i eth2 -p tcp -m tcp --dport 25 -j ACCEPT -A INPUT -i eth2 -p tcp -m tcp --dport 53 -j ACCEPT -A INPUT -i eth2 -p udp -m udp --dport 53 -j ACCEPT -A INPUT -i eth2 -p udp -m udp --dport 80 -j ACCEPT -A INPUT -i eth2 -p tcp -m tcp --dport 443 -j ACCEPT -A INPUT -i eth2 -p tcp -m tcp --dport 993 -j ACCEPT -A INPUT -i eth2 -p udp -m udp --dport 995 -j ACCEPT -A INPUT -i lo -j ACCEPT -A INPUT -j block -A FORWARD -j block -A block -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT -A block -i eth1 -m conntrack --ctstate NEW -j ACCEPT -A block -j LOG --log-prefix "IPTables:block " --log-level 6 -A block -j DROP COMMIT

Un Lugar Donde Confiar iptables -t raw -A PREROUTING -d 192.168.51.255/32 -j LOG --log-prefix "IPTables:raw:De0BCast: " --log-level 6 iptables -t raw -A PREROUTING -d 192.168.51.255/32 -j DROP iptables -t raw -A PREROUTING -d 192.168.51.0/32 -j LOG --log-prefix "IPTables:raw:De0Net: " --log-level 6 iptables -t raw -A PREROUTING -d 192.168.51.0/32 -j DROP iptables -t raw -A PREROUTING -d 192.168.69.255/32 -j LOG --log-prefix "IPTables:raw:De1BCast: " --log-level 6 iptables -t raw -A PREROUTING -d 192.168.69.255/32 -j DROP iptables -t raw -A PREROUTING -d 192.168.69.0/32 -j LOG --log-prefix "IPTables:raw:De1Net: " --log-level 6 iptables -t raw -A PREROUTING -d 192.168.69.0/32 -j DROP iptables -t raw -A PREROUTING -d 10.0.69.255/32 -j LOG --log-prefix "IPTables:raw:De2BCast: " --log-level 6 iptables -t raw -A PREROUTING -d 10.0.69.255/32 -j DROP iptables -t raw -A PREROUTING -d 10.0.69.0/32 -j LOG --log-prefix "IPTables:raw:De2Net: " --log-level 6 iptables -t raw -A PREROUTING -d 10.0.69.0/32 -j DROP iptables -t raw -A PREROUTING -d 0.0.0.0/32 -j LOG --log-prefix "IPTables:raw:DGNet: " --log-level 6 iptables -t raw -A PREROUTING -d 0.0.0.0/32 -j DROP iptables -t raw -A PREROUTING -d 255.255.255.255/32 -j LOG --log-prefix "IPTables:raw:DGBCast: " --log-level 6 iptables -t raw -A PREROUTING -d 255.255.255.255/32 -j DROP

Un Lugar Donde Confiar iptables -t raw -A PREROUTING -s 192.168.51.255/32 -j LOG --log-prefix "IPTables:raw:Se0BCast: " --log-level 6 iptables -t raw -A PREROUTING -s 192.168.51.255/32 -j DROP iptables -t raw -A PREROUTING -s 192.168.51.0/32 -j LOG --log-prefix "IPTables:raw:Se0Net: " --log-level 6 iptables -t raw -A PREROUTING -s 192.168.51.0/32 -j DROP iptables -t raw -A PREROUTING -s 192.168.69.255/32 -j LOG --log-prefix "IPTables:raw:Se1BCast: " --log-level 6 iptables -t raw -A PREROUTING -s 192.168.69.255/32 -j DROP iptables -t raw -A PREROUTING -s 192.168.69.0/32 -j LOG --log-prefix "IPTables:raw:Se1Net: " --log-level 6 iptables -t raw -A PREROUTING -s 192.168.69.0/32 -j DROP iptables -t raw -A PREROUTING -s 10.0.69.255/32 -j LOG --log-prefix "IPTables:raw:Se2BCast: " --log-level 6 iptables -t raw -A PREROUTING -s 10.0.69.255/32 -j DROP iptables -t raw -A PREROUTING -s 10.0.69.0/32 -j LOG --log-prefix "IPTables:raw:Se2Net: " --log-level 6 iptables -t raw -A PREROUTING -s 10.0.69.0/32 -j DROP

Un Lugar Donde Confiar iptables -t raw -A PREROUTING -m iprange --src-range 10.0.0.0-10.0.68.255 -j LOG --log-prefix "IPTables:raw:S10: " --log-level 6 iptables -t raw -A PREROUTING -m iprange --src-range 10.0.0.0-10.0.68.255 -j DROP iptables -t raw -A PREROUTING -m iprange --src-range 10.0.70.0-10.255.255.255 -j LOG --log-prefix "IPTables:raw:S10: " --log-level 6 iptables -t raw -A PREROUTING -m iprange --src-range 10.0.70.0-10.255.255.255 -j DROP iptables -t raw -A PREROUTING -m iprange --src-range 192.168.0.0-192.168.50.255 -j LOG --log-prefix "IPTables:raw:S192: " --log-level 6 iptables -t raw -A PREROUTING -m iprange --src-range 192.168.0.0-192.168.50.255 -j DROP iptables -t raw -A PREROUTING -m iprange --src-range 192.168.52.0-192.168.68.255 -j LOG --log-prefix "IPTables:raw:S192: " --log-level 6 iptables -t raw -A PREROUTING -m iprange --src-range 192.168.52.0-192.168.68.255 -j DROP iptables -t raw -A PREROUTING -m iprange --src-range 192.168.70.0-192.168.255.255 -j LOG --log-prefix "IPTables:raw:S192: " --log-level 6 iptables -t raw -A PREROUTING -m iprange --src-range 192.168.70.0-192.168.255.255 -j DROP iptables -t raw -A PREROUTING -s 0.0.0.0/32 -j LOG --log-prefix "IPTables:raw:SGNet: " --log-level 6 iptables -t raw -A PREROUTING -s 0.0.0.0/32 -j DROP iptables -t raw -A PREROUTING -s 255.255.255.255/32 -j LOG --log-prefix "IPTables:raw:SGBCast: " --log-level 6 iptables -t raw -A PREROUTING -s 255.255.255.255/32 -j DROP # microsoft-ds netbios-ns iptables -t raw -A PREROUTING -p udp -m multiport --dports 135,445 -j LOG --log-prefix "IPTables:raw:ms-ds: " --log-level 6 iptables -t raw -A PREROUTING -p udp -m multiport --dports 135,445 -j DROP iptables -t raw -A PREROUTING -p udp -m udp --dport 137:139 -j LOG --log-prefix "IPTables:raw:ms-ds: " --log-level 6 iptables -t raw -A PREROUTING -p udp -m udp --dport 137:139 -j DROP iptables -t raw -A PREROUTING -p udp -m udp --sport 137 --dport 1024:65535 -j LOG --log-prefix "IPTables:raw:ms-ds: " --log-level 6 iptables -t raw -A PREROUTING -p udp -m udp --sport 137 --dport 1024:65535 -j DROP iptables -t raw -A PREROUTING -p udp -m multiport --dports 135,139,445 -j LOG --log-prefix "IPTables:raw:ms-ds: " --log-level 6 iptables -t raw -A PREROUTING -p tcp -m multiport --dports 135,139,445 -j DROP

Un Lugar Donde Confiar # messenger "multicast" broadcast address for UPnP devices iptables -t raw -A PREROUTING -p udp -m udp --dport 1900 -j LOG --log-prefix "IPTables:raw:UPnP: " --log-level 6 iptables -t raw -A PREROUTING -p udp -m udp --dport 1900 -j DROP # UPnP Device Host service iptables -t raw -A PREROUTING -p udp -m udp --dport 5000 -j LOG --log-prefix "IPTables:raw:UPnP: " --log-level 6 iptables -t raw -A PREROUTING -p tcp -m tcp --dport 5000 -j DROP iptables -t raw -A PREROUTING -m pkttype --pkt-type broadcast -j LOG --log-prefix "IPTables:raw:GBCast: " --log-level 6 iptables -t raw -A PREROUTING -m pkttype --pkt-type broadcast -j DROP iptables -t raw -A PREROUTING -m pkttype --pkt-type multicast -j LOG --log-prefix "IPTables:raw:GMCast: " --log-level 6 iptables -t raw -A PREROUTING -m pkttype --pkt-type multicast -j DROP iptables -t raw -A PREROUTING -s 224.0.0.0/240.0.0.0 -j LOG --log-prefix "IPTables:raw:SMCast: " --log-level 6 iptables -t raw -A PREROUTING -s 224.0.0.0/240.0.0.0 -j DROP

SysV/POSIX iptables-save > /etc/sysconfig/iptables Un Lugar Donde Confiar SysV/POSIX iptables-save > /etc/sysconfig/iptables chkconfig iptables on service iptables stop service iptables start service iptables restart service iptables reload service iptables status service iptables check

Un Lugar Donde Confiar ¿Preguntas?

Un Lugar Donde Confiar ¡JUGAMOS!