Tecnologie e Protocolli per Internet 1 Introduzione al NAT Network Address Translation



Similar documents
Network Address Translation (NAT)

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

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

21.4 Network Address Translation (NAT) NAT concept

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

Chapter 7. Firewalls

Netfilter / IPtables

How To Understand A Firewall

Track 2 Workshop PacNOG 7 American Samoa. Firewalling and NAT

Firewalls. Chien-Chung Shen

Internet Protocol: IP packet headers. vendredi 18 octobre 13

netkit lab load balancer web switch 1.1 Giuseppe Di Battista, Massimo Rimondini Version Author(s)

Virtual private network. Network security protocols VPN VPN. Instead of a dedicated data link Packets securely sent over a shared network Internet VPN

Компјутерски Мрежи NAT & ICMP

Intro to Linux Kernel Firewall

Network Security Exercise 10 How to build a wall of fire

THE HONG KONG POLYTECHNIC UNIVERSITY Department of Electronic and Information Engineering

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

What I am going to talk about. NAT IPSec and NAT Proxy, Reverse proxy P2P Firewall

Linux Firewalls (Ubuntu IPTables) II

CS Computer and Network Security: Firewalls

Linux Networking: IP Packet Filter Firewalling

Protecting and controlling Virtual LANs by Linux router-firewall

Lecture Objectives. Lecture 6 Mobile Networks: Nomadic Services, DHCP, NAT, and VPNs. Agenda. Nomadic Services. Agenda. Nomadic Services Functions

Definition of firewall

CS Computer and Network Security: Firewalls

Firewalls P+S Linux Router & Firewall 2013

ICS 351: Today's plan. IP addresses Network Address Translation Dynamic Host Configuration Protocol Small Office / Home Office configuration

Firewall Defaults, Public Server Rule, and Secondary WAN IP Address

Load Balancing Bloxx Web Filter. Deployment Guide

Load Balancing Web Proxies Load Balancing Web Filters Load Balancing Web Gateways. Deployment Guide

CSC574 - Computer and Network Security Module: Firewalls

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

Load Balancing Sophos Web Gateway. Deployment Guide

Load Balancing Clearswift Secure Web Gateway

Proxy Server, Network Address Translator, Firewall. Proxy Server

Peer-to-Peer Systems and Security

TECHNICAL NOTES. Security Firewall IP Tables

ipchains and iptables for Firewalling and Routing

Load Balancing Smoothwall Secure Web Gateway

Load Balancing Trend Micro InterScan Web Gateway

Matthew Rossmiller 11/25/03

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

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

Application Note. Onsight TeamLink And Firewall Detect v6.3

Michal Ludvig, SUSE Labs, 01/30/2004, Secure networking, 1

+ iptables. packet filtering && firewall

Main functions of Linux Netfilter

FIREWALL AND NAT Lecture 7a

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

Firewalls. October 23, 2015

Load Balancing McAfee Web Gateway. Deployment Guide

Smoothwall Web Filter Deployment Guide

Digi Connect WAN Application Helper NAT, GRE, ESP and TCP/UPD Forwarding and IP Filtering

CSE543 - Computer and Network Security Module: Firewalls

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

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

IP Security. Ola Flygt Växjö University, Sweden

Linux Firewall Wizardry. By Nemus

NAT Traversal for VoIP. Ai-Chun Pang Graduate Institute of Networking and Multimedia Dept. of Comp. Sci. and Info. Engr. National Taiwan University

Firewall Defaults and Some Basic Rules

Evaluation guide. Vyatta Quick Evaluation Guide

Security in IPv6. Basic Security Requirements and Techniques. Confidentiality. Integrity

Configuring IPSec VPN Tunnel between NetScreen Remote Client and RN300

VLAN und MPLS, Firewall und NAT,

How To Configure Apple ipad for Cyberoam L2TP

Bridgewalling - Using Netfilter in Bridge Mode

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

NAT and Firewall Traversal with STUN / TURN / ICE

CIS 433/533 - Computer and Network Security Firewalls

Network Address Translation (NAT) Adapted from Tannenbaum s Computer Network Ch.5.6; computer.howstuffworks.com/nat1.htm; Comer s TCP/IP vol.1 Ch.

Packet Filtering using the ADTRAN OS firewall has two fundamental parts:

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

Final exam review, Fall 2005 FSU (CIS-5357) Network Security

Network Security TCP/IP Refresher

Load Balancing Barracuda Web Filter. Deployment Guide

IPv6.marceln.org.

Developing P2P Protocols across NAT

Secure use of iptables and connection tracking helpers

LinkProof And VPN Load Balancing

IPv6 Fundamentals: A Straightforward Approach

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

Appendix A: Configuring Firewalls for a VPN Server Running Windows Server 2003

Assignment 3 Firewalls

Appliance Quick Start Guide. v7.6

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

10.4. Multiple Connections to the Internet

Chapter 4: Security of the architecture, and lower layer security (network security) 1

Load Balancing VMware Horizon View. Deployment Guide

GPRS / 3G Services: VPN solutions supported

Network Address Translation Commands

Transcription:

Tecnologie e Protocolli per Internet 1 Introduzione al NAT Network Address Translation Prof. Stefano Salsano e-mail: stefano.salsano@uniroma2.it AA2012/13 Blocco 10 Le slides di questo blocco sono tratte da un seminario dell Ing. Vito Ammirata e da un corso dell Ing. Marco Bonola

O meglio CERCA di non modificare

SIP: Source IP address, DIP: Destination IP, Sport: Source Port

O meglio non dovrebbe risentire

Comunicazioni attraverso i NAT Il tipo di NAT influenza le possibilità di comunicazione degli host che stanno dietro ad un NAT. Nelle comunicazioni client-server, quando il server si trova su IP pubblico e il client dietro un NAT, non ci sono problemi particolari (specialmente con TCP). Il problema riguarda le comunicazioni end-to-end (ad esempio per flussi UDP multimediali) che coinvolgono host dietro ai NAT. Se entrambi gli host sono dietro ai NAT, in certi casi non è possibile stabilire delle comunicazioni dirette.

NETWORK ADDRESS TRANSLATION WITH NETFILTER Network Address Translation NAT is the process of changing the the IP header E.g.: a routed packet is intercepted, the IP source address is changed and the IP and L4 checksum in updated RFC 2663 defines it as basic NAT or one to one NAT Since a static one-to-one NAT can t be exploited by an entire address space (e.g.: a 10.0.0.0/24 LAN behind NAT), the L4 ports can be changed to avoid ambiguity in the response packets RFC 2663 also defines a Network Address and Port Translation (NAPT) It is also referred to as PAT, Masquerading, Many to One NAT etc NAPT technique allows to successfully forward packets addressed to the masqueraded network (e.g.: the LAN behind the NAT) only if related to a flow originated from it For flows originated outside the masqueraded network, a different method is used Static NAT (or Port Forwarding) uses static binding between (addr e :port e ) <-> (addr i :port i ) To much confusion! From now on, we ll use NAT for the general IP/L4 translation

NAT basic mechanism - masquerading ip H : host private IP address ip S : server public IP address ip NAT : NAT public IP address tcp sport : host application source port tcp dport : server listening port tcp NAT : random port picked up by NAT ip hc, tcp cs : protocol checksums LAN host NAT server ip H, ip S, ip hc, tcp sport, tcp dport, tcp cs pick up free tcp NAT and store the binding ip H, tcp sport : ip NAT tcp NAT ip NAT, ip S, ip hc*, tcp NAT, tcp dport, tcp cs* ip S, ip NAT, ip hc, tcp dport, tcp NAT, tcp cs ip H, ip S, ip hc*, tcp sport, tcp dport, tcp cs* retrieve ip H, tcp sport from ip NAT, tcp sportnat : NAT basic mechanism port forwarding ip S : server private IP address ip C : client IP address IP NAT : NAT public IP address tcp sport : client application source port tcp dport : server listening port tcp NAT : port forwarded by NAT ip hc, tcp cs : protocol checksums LAN host NAT client Statically configured with ip H, tcp sport : ip NAT tcp NAT ip C, ip NAT, ip hc, tcp sport, tcp NAT, tcp cs ip C, ip S, ip hc*, tcp sport, tcp dport, tcp cs* retrieve ip S, tcp dport from ip NAT, tcp NAT

More about NAT nomenclature NAT classification is really confusing among vendors: CISCO Static, dynamic IBM Static, dynamic, masquerading LINUX (NETFILTER) DNAT, SNAT, MASQUERADE, REDIRECT JUNIPER Full cone, symmetric BSD No explicitly distinct types From now on we ll use the Linux nomenclature Address:Port binding strategy calssification RFC 3849 (Simple Traversal of UDP over NATs, obsoleted by RFC 5389) defines 4 different strategies for selecting the binding between (addr e :port e ) <-> (addr i :port i ) Full-cone NAT Any external host can send packets to iaddr:iport by sending packets to eaddr:eport Restricted cone NAT An external host (haddr:any) can send packets to iaddr:iport by sending packets to eaddr:eport only if iaddr:iport has previously sent a packet to haddr:any Port-restricted cone NAT An external host (haddr:hport) can send packets to iaddr:iport by sending packets to eaddr:eport only if iaddr:iport has previously sent a packet to haddr:hport Symmetric NAT Only an external host that receives a packet from an internal host can send a packet back As described in RFC 4787, this classification is inadequate to describe real NAT implementation (as they can be a mix of the above techniques. E.g: NETFILTER DNAT is fullcone, MASQUERADE is symmetric) Some NAT traversal protocols simply make the distinction Symmetric/Asymmetric NAT

Why NATs are bad (1) NATs are bad for servers in masqueraded LAN OBVIOUS! Without the NAT enabled router taking ad-hoc static port forwarding, how can a client reach such servers? Sometimes we can t control the NAT enables router E.g: FASTWEB home customers Even with total control over the NAT and static port forwarding, what if I have multiple (e.g. HTTP) severs? Use different ports How do I advert this? Why NATs are bad (2) NATs are bad for clients too Example: FTP (textual protocol over TCP) ACTIVE MODE Other examples: RTP/RTCP, SIP, p2p protocols 0. Connection from rand port and authentication 1. Client selects a port (rand+1) for receiving data traffic (PORT command) 2. Server acknowledges it 3. Server starts the connection to client:1027 4. Client acknowledges the SYN FTP active Problems with a NAT in the middle: The server contacts the client at the address it sees in the CMD connection (i.e: the public address of the NAT) and PORT in the FTP msg CMD and DATA ports are random How can the NAT correctly forward the DATA connection to the Client? Even if the client port were fixed, what would happens with multiple client behind the NAT?

Why NATs are bad (3) NATs are bad for secure end to end encapsulation with IPSEC If AH (Authentication Header) is used, the NAT destroys the end to end cryptographic integrity computed over the whole IP packet The NAT would change the source IP address The NAT couldn t re-compute the message authentication code because he doesn t know the secret (as it should be ) Even with ESP only, what if multiple hosts selects the same SPIs? To revert the binding, the NAT can use the couple (IP, SPI) SPIs are picked up independently by the two parties NAT implementations are (not rarely) able to work only with IP+{TCP UDP} NAT binding timeout Other motivations (described in RFC 3715) Why NATs are bad (3)

Why NATs are bad (3) What is NAT traversal? NAT traversal is a mechanisms to solve the problems introduced by NATs It can be implemented as: A protocol patch e.g: FTP passive In FTP passive the client sends the first packet to allow the server to find out the DATA port An ALG (application layer gateway) that inspects and changes the application protocols message An integrated helper protocol used at set up time (Internet Connectivity Establishment (ICE), TURN, STUN) Tunneling mechanism (e.g.: UDP encapsulation)

What are NATs good for? 1. IPv4 address exhaustion NAT allows several hosts in a LAN to share the Internet connection through the same public IP 2. Implicit security A host in a LAN behind NAT can t be reach from outside unless explicit port forwarding is configured Laboratorio pc router server Collision domain A 10.0.0.0/24 Collision domain B 1.2.3.0/24 eth0=10.0.0.100 eth0=10.0.0.1 eth1=1.2.3.4 eth0=1.2.3.5 Semplice emulazione di uno scenario con client in LAN privata e server sulla public Internet pc.startup: ip link set eth0 up ip addr add 10.0.0.100/24 dev eth0 ip route add default via 10.0.0.1 router.startup: ip link set eth0 up ip link set eth1 up ip addr add 10.0.0.1/24 dev eth0 ip addr add 1.2.3.4/24 dev eth1 server.startup: ip link set eth0 up ip addr add 1.2.3.5/24 dev eth0 #non mettere la default!! Altrimenti server #conoscerebbe la strada per la LAN #privata 10.0.0.0/24

Esercizio 1. Verificare che pc non riesce a instaurare una connessione TCP porta 80 verso server 2. Configurare il masquerade su router per il traffico generato dalla LAN 1. Verificare che pc si connette al server sulla porta 80 2. Verificare che server non può fare altrettanto 3. Configurare il destination NAT su router in modo che server può instaurare una connessione TCP porta 80 verso pc HINTS: 1) nc in listening: nc -l -p [numero-porta] 2) connettere nc: nc [indirizzo destinazione] [porta destinazione] 3) Configurare MASQUERADE iptables -A POSTROUTING -t nat [specificare match] -j MASQUERADE 4) Configurare DNAT iptables -A PREROUTING -t nat [specificare match] -j DNAT --to-destination [indirizzo:porta]