Jeremy’s IT Lab lecture video:

Day 45 - NAT (2)


Commands


NAT Info

Static NAT Reminder

Static NAT

Static NAT involves statically configuring one-to-one mappings of private IP addresses to public IP addresses.

  • When traffic from the internal host is sent to the outside network, the router will translate the source address.
  • Also, this one-to-one mapping also allows external hosts to access the internal host via the Inside Global address.

Static NAT Configuration

  • show ip nat translations
    • Shows information about IP addresses that have been translated through NAT.
    • Includes the following information:
      • Protocol used in the connection
      • Inside Local address
      • Inside Global address
      • Outside Local address
      • Outside Global address
  • show ip nat statistics
    • Shows statistics about the current NAT process
    • Includes the following information:
      • Total active translations (static, dynamic, extended)
      • Peak translations (highest amount of translations in one time)
      • Outside interfaces
      • Inside interfaces
      • Etc.
  • clear ip nat translation *
    • Clears all dynamic NAT translations in the NAT translation table
    • (One type of dynamic translations is IP address translations with a port included)
  • ip nat inside
    • Defines the ‘inside’ interface(s) connected to the internal network
  • ip nat outside
    • Defines the ‘outside’ interface(s) connected to the external network
  • ip nat inside source static INSIDE-LOCAL-IP INSIDE-GLOBAL-IP
    • Configures a one-to-one (Static NAT) IP address mapping
Link to original


Dynamic NAT

Dynamic NAT involves dynamically mapping Inside Local addresses to Inside Global addresses as needed.

  • Although they are dynamically assigned, the mappings are still one-to-one. (One Inside Local IP address per Inside Global IP address)
  • It uses an ACL to identify which traffic should be translated.
    • If the source IP is permitted by the ACL, the source IP will be translated.
    • If the source IP is denied by the ACL, the source IP will not be translated.
  • A NAT Pool is also used to define the available Inside Global addresses to be used for the translation.

What does it mean if an address is 'not translated'?

  • When an address is not translated (due to NAT Pool Exhaustion or being denied by the ACL), that does NOT mean that the traffic will get dropped.
  • Instead, it simply means that the traffic won’t go through the NAT process and will be sent with its original source IP address.
Dynamic NAT demonstration

NAT Pool Exhaustion

If there aren’t enough Inside Global IP addresses available in the NAT Pool (all the addresses are currently being used), that is called ‘NAT Pool Exhaustion

  • If a packet from another inside host arrives and needs NAT but there are no available addresses, the router will drop the packet.
  • The host will be unable to access outside networks (which requires NAT translations) until one of the Inside Global IP addresses becomes available.
  • Dynamic NAT entries will time out automatically if they’re not used, or they can be cleared manually through clear ip nat translation *

Be careful: 'Not translated' traffic and 'dropped' traffic

  • Watch out for these two similar terms.
    • When traffic is ‘not translated’ it means that it won’t go through the NAT process and will retain its original source IP address, therefore, and it can still be sent to others devices in the LAN for example.
    • When traffic needs a NAT translation (in order to reach outside networks) and the Dynamic NAT Pool is full and completely in use, the traffic will be completely ‘dropped’ and discarded.

Dynamic NAT Configuration

  • show ip nat translations
    • Shows information about IP addresses that have been translated through NAT.
    • Includes the following information:
      • Protocol used in the connection
      • Inside Local address
      • Inside Global address
      • Outside Local address
      • Outside Global address
  • show ip nat statistics
    • Shows statistics about the current NAT process.
    • Includes the following information:
      • Total active translations (static, dynamic, extended)
      • Peak translations (highest amount of translations in one time)
      • Outside interfaces
      • Inside interfaces
      • Etc.
  • clear ip nat translation *
    • Clears all dynamic NAT translations in the NAT translation table.
    • (One type of dynamic translations is IP address translations with a port included)
  • ip nat inside
    • Defines the ‘inside’ interface(s) connected to the internal network.
  • ip nat outside
    • Defines the ‘outside’ interface(s) connected to the external network.
  • access-list ACL-ID permit ARGUMENTS
    • Defines the traffic that should be translated
    • (Permitted traffic by the ACL will be translated)
  • ip nat pool POOL-NAME START-IP END-IP { prefix-length PREFIX-LENGTH | netmask SUBNET-MASK }
    • Defines the NAT Pool of Inside Global IP addresses.
  • ip nat inside source list ACL-ID pool POOL-NAME
    • Configures Dynamic NAT on the router by mapping the ACL to the NAT Pool.

Info: show ip nat translations command with Dynamic NAT

  • When the command is used, the one-to-one dynamic mappings will show, just like Static NAT, as well as any translated addresses and their ports.
  • Using the clear ip nat translation * command will clear all the translations except the one-to-one mappings.

Port Address Translation (PAT) / NAT Overload

Port Address Translation (PAT) or NAT Overload is a protocol that translates both the IP address and port number (if necessary)

  • By using a unique port number for each communication flow, a single public IP address can be used by many different internal hosts.
  • (Port numbers are 16 bits, which is over 65,000 available port numbers)
  • The router will keep track of which Inside Local address is using which Inside Global address and port.
  • PAT is really good for preserving public IP addresses, as many inside hosts can share a single public IP.
PAT Demonstration
(In this case, PAT translated both the IP address and ports, as both of the hosts were using the same port of 54321)

PAT Configuration (Pools)

  • show ip nat translations
    • Shows information about IP addresses that have been translated through NAT.
    • Includes the following information:
      • Protocol used in the connection
      • Inside Local address
      • Inside Global address
      • Outside Local address
      • Outside Global address
  • show ip nat statistics
    • Shows statistics about the current NAT process.
    • Includes the following information:
      • Total active translations (static, dynamic, extended)
      • Peak translations (highest amount of translations in one time)
      • Outside interfaces
      • Inside interfaces
      • Etc.
  • clear ip nat translation *
    • Clears all dynamic NAT translations in the NAT translation table.
    • (One type of dynamic translations is IP address translations with a port included)
  • ip nat inside
    • Defines the ‘inside’ interface(s) connected to the internal network.
  • ip nat outside
    • Defines the ‘outside’ interface(s) connected to the external network.
  • access-list ACL-ID permit ARGUMENTS
    • Defines the traffic that should be translated
    • (Permitted traffic by the ACL will be translated)
  • ip nat pool POOL-NAME START-IP END-IP { prefix-length PREFIX-LENGTH | netmask SUBNET-MASK }
    • Defines the NAT Pool of Inside Global IP addresses.
  • ip nat inside source list ACL-ID pool POOL-NAME overload
    • Configures PAT on the router by mapping the ACL to the NAT Pool with the overload argument at the end.

Info: show ip nat translations command with PAT

  • When the command is used, only translated addresses and their ports will show up.
  • PAT does not have any ‘one-to-one’ mappings like Static and Dynamic NAT.
  • Using the clear ip nat translation * command will clear all the translations.

PAT Configuration (Interface)

  • show ip nat translations
    • Shows information about IP addresses that have been translated through NAT.
    • Includes the following information:
      • Protocol used in the connection
      • Inside Local address
      • Inside Global address
      • Outside Local address
      • Outside Global address
  • show ip nat statistics
    • Shows statistics about the current NAT process.
    • Includes the following information:
      • Total active translations (static, dynamic, extended)
      • Peak translations (highest amount of translations in one time)
      • Outside interfaces
      • Inside interfaces
      • Etc.
  • clear ip nat translation *
    • Clears all dynamic NAT translations in the NAT translation table.
    • (One type of dynamic translations is IP address translations with a port included)
  • ip nat inside
    • Defines the ‘inside’ interface(s) connected to the internal network.
  • ip nat outside
    • Defines the ‘outside’ interface(s) connected to the external network.
  • access-list ACL-ID permit ARGUMENTS
    • Defines the traffic that should be translated
    • (Permitted traffic by the ACL will be translated)
  • ip nat inside source list ACL-ID interface INTERFACE-ID overload
    • Configures PAT on the router by mapping the ACL to an interface on the router with the overload argument at the end.
    • When traffic is translated, it will use the IP address of the specified interface.
PAT via interface Demonstration

Jeremy’s IT Lab előadásvideó:

45. Nap - NAT (2)


Parancsok


NAT Információk

Static NAT Emlékeztető

Static NAT

A Static NAT egy állandó, egy-az-egyhez leképezést hoz létre a privát IP címek és a nyilvános IP címek között.

  • Amikor a belső host forgalmat küld a külső hálózat felé, a router a forrás címet lefordítja a megadott nyilvános címre.
  • Ez az egy-az-egyhez kapcsolat azt is lehetővé teszi, hogy külső hostok közvetlenül elérjék a belső szervert/eszközt az Inside Global címen keresztül.

Static NAT Konfiguráció

  • show ip nat translations
    • Megjeleníti a NAT táblázatban jelenleg aktív összes címfordítási bejegyzést.
    • A következő információkat tartalmazza:
      • Kapcsolatban használt Protokoll
      • Inside Local cím
      • Inside Global cím
      • Outside Local cím
      • Outside Global cím
  • show ip nat statistics
    • Részletes statisztikát nyújt a futó NAT folyamatról:
      • Aktív fordítások száma (static, dynamic, extended)
      • Csúcs fordítási szám (peak translations)
      • Outside interfészek listája
      • Inside interfészek listája
      • Stb.
  • clear ip nat translation *
    • Törli az összes dinamikus NAT bejegyzést a táblázatból.
    • (A statikus fordításokat nem törli, csak a dinamikusan létrejötteket).
  • ip nat inside
    • Kijelöli a belső (inside) hálózathoz csatlakozó interfészt.
  • ip nat outside
    • Kijelöli a külső (outside) hálózathoz csatlakozó interfészt.
  • ip nat inside source static INSIDE-LOCAL-IP INSIDE-GLOBAL-IP
    • Létrehozza a fix egy-az-egyhez statikus NAT leképezést.
Eredeti hivatkozása


Dynamic NAT (Dinamikus NAT)

A Dynamic NAT dinamikusan képez le Inside Local privát címeket elérhető Inside Global nyilvános címekre szükség szerint, a forgalom felmerülésekor.

  • Bár a hozzárendelés dinamikus, a leképezés továbbra is egy-az-egyhez (one-to-one) történik (egy Inside Local IP cím pontosan egy Inside Global IP címet foglal el a kapcsolat idejére).
  • Egy ACL-t használ annak meghatározására, hogy mely forgalmat kell lefordítani (translate):
    • Ha a forrás IP-t az ACL engedélyezi (permit), az IP cím lefordításra kerül.
    • Ha a forrás IP-t az ACL elutasítja (deny), az IP cím nem kerül lefordításra.
  • Egy NAT Pool (címtartomány) definiálja az elérhető Inside Global nyilvános IP címeket a fordításhoz.

Mit jelent, ha egy cím 'nincs lefordítva' (not translated)?

  • Ha egy cím nincs lefordítva (akár a NAT Pool kimerülése miatt, akár azért, mert az ACL tiltja), az NEM jelenti automatikusan a forgalom eldobását (drop).
  • Egyszerűen annyit jelent, hogy a csomag nem esik át a NAT folyamaton, és az eredeti forrás IP címével kerül továbbításra (pl. helyi LAN-on belül).
Dynamic NAT működésének bemutatása

NAT Pool Kimerülés (NAT Pool Exhaustion)

Ha nincs elegendő szabad Inside Global IP cím a NAT Pool-ban (az összes nyilvános címet éppen más belső hostok használják), azt NAT Pool Exhaustion-nek (NAT pool kimerülésnek) nevezzük.

  • Ha egy újabb belső hosttól érkezik egy olyan csomag, amelyhez NAT fordításra lenne szükség az internet eléréséhez, de nincs szabad cím a poolban, a router a csomagot eldobja (drop).
  • A host mindaddig nem tudja elérni a külső hálózatot, amíg a Pool valamelyik Inside Global IP címe fel nem szabadul.
  • A Dynamic NAT bejegyzések inaktivitás esetén automatikusan lejárnak (timeout), vagy manuálisan törölhetők a clear ip nat translation * paranccsal.

Fontos különbség: 'Nem fordított' (not translated) és 'eldobott' (dropped) forgalom

  • Ügyeljünk erre a két fogalomra a vizsgán:
    • Amikor a forgalom 'nem lefordított', a router változatlan forrás IP címmel továbbítja a csomagot a routing táblázat alapján (pl. belső hálózati cél felé).
    • Amikor a forgalomnak kötelezően NAT fordításra lenne szüksége a külső hálózat felé, de a Dynamic NAT Pool teljesen megtelt és kimerült, a forgalom eldobásra kerül (dropped).

Dynamic NAT Konfiguráció

  • show ip nat translations
    • Információkat jelenít meg a NAT által lefordított címekről.
    • A következő adatokat listázza:
      • Kapcsolatban használt Protokoll
      • Inside Local cím
      • Inside Global cím
      • Outside Local cím
      • Outside Global cím
  • show ip nat statistics
    • Statisztikát mutat a futó NAT folyamatról:
      • Aktív fordítások száma (static, dynamic, extended)
      • Csúcs fordítási szám (peak translations)
      • Outside és Inside interfészek
      • Pool kihasználtság stb.
  • clear ip nat translation *
    • Törli az összes dinamikus NAT fordítást a táblázatból.
  • ip nat inside
    • Kijelöli a belső hálózathoz csatlakozó interfészt.
  • ip nat outside
    • Kijelöli a külső hálózathoz csatlakozó interfészt.
  • access-list ACL-ID permit ARGUMENTS
    • Meghatározza a lefordítandó forgalmat (az ACL által engedélyezett forrás IP-k fordulnak).
  • ip nat pool POOL-NAME START-IP END-IP { prefix-length PREFIX-LENGTH | netmask SUBNET-MASK }
    • Létrehozza az Inside Global IP címek NAT Pool-ját.
  • ip nat inside source list ACL-ID pool POOL-NAME
    • Konfigurálja a Dynamic NAT-ot a megadott ACL és NAT Pool összerendelésével.

Infó: show ip nat translations parancs Dynamic NAT esetén

  • A parancs kimenetében a dinamikusan lefoglalt egy-az-egyhez leképezések jelennek meg (hasonlóan a statikus NAT-hoz), valamint az éppen futó fordítások a portszámokkal.
  • A clear ip nat translation * parancs kiadása törli az aktív fordításokat, kivéve a dinamikusan lefoglalt egy-az-egyhez kötéseket.

Port Address Translation (PAT) / NAT Overload

A Port Address Translation (PAT) – más néven NAT Overload – egy olyan eljárás, amely nemcsak az IP címet, hanem szükség esetén a forrás portszámot is lefordítja (módosítja).

  • Minden egyes kommunikációs folyamathoz (flow) egyedi portszámot rendel, így egyetlen nyilvános IP címen rengeteg különböző belső host osztozhat egyszerre.
  • (A portszámok 16 bitesek, ami több mint 65 000 lehetséges portot jelent címenként).
  • A router egy állapot-táblázatban (NAT translation table) nyilvántartja, melyik Inside Local privát cím és forrásport melyik Inside Global nyilvános címhez és lefordított porthoz tartozik.
  • A PAT a leghatékonyabb technológia a nyilvános IPv4 címek megőrzésére, hiszen több száz vagy ezer belső eszköz használhat egyetlen közös publikus IP címet.
PAT működésének bemutatása
(Ebben a példában a PAT az IP címet és a forrásportot is módosította, mivel mindkét belső host ugyanazt a 54321-es forrásportot használta)

PAT Konfiguráció (NAT Pool használatával)

  • show ip nat translations
    • Megmutatja a lefordított IP címeket és a hozzájuk rendelt portokat.
  • show ip nat statistics
    • Statisztikát mutat a NAT / PAT működéséről.
  • clear ip nat translation *
    • Törli az összes dinamikus PAT fordítási bejegyzést.
  • ip nat inside
    • Kijelöli a belső interfészt.
  • ip nat outside
    • Kijelöli a külső interfészt.
  • access-list ACL-ID permit ARGUMENTS
    • Megadja az ACL-ben, hogy mely belső IP-ket kell lefordítani.
  • ip nat pool POOL-NAME START-IP END-IP { prefix-length PREFIX-LENGTH | netmask SUBNET-MASK }
    • Definiálja a publikus IP címekből álló NAT Pool-t.
  • ip nat inside source list ACL-ID pool POOL-NAME overload
    • Beállítja a PAT-ot a megadott ACL és NAT Pool alapján, a parancs végén szereplő overload kulcsszóval.

Infó: show ip nat translations parancs PAT esetén

  • A parancs kiadásakor csak a ténylegesen lefordított címek és a hozzájuk tartozó portok jelennek meg.
  • A PAT nem hoz létre fix 'egy-az-egyhez' címkötéseket, mint a Static vagy Dynamic NAT.
  • A clear ip nat translation * parancs az összes aktív fordítást azonnal törli.

PAT Konfiguráció (Közvetlen Interfész IP használatával)

  • show ip nat translations
    • Megjeleníti a NAT/PAT fordítási bejegyzéseket.
  • show ip nat statistics
    • Megjeleníti a NAT statisztikákat.
  • clear ip nat translation *
    • Törli a dinamikus NAT fordításokat.
  • ip nat inside
    • Belső interfész meghatározása.
  • ip nat outside
    • Külső interfész meghatározása.
  • access-list ACL-ID permit ARGUMENTS
    • Meghatározza a lefordítandó forgalmat.
  • ip nat inside source list ACL-ID interface INTERFACE-ID overload
    • Konfigurálja a PAT-ot a routeren oly módon, hogy az ACL által engedélyezett forgalmat közvetlenül a megadott külső interfész IP címére fordítja le, a parancs végén megadott overload kapcsolóval.
    • A forgalom fordítása során az adott interfészre konfigurált (vagy DHCP-vel kapott) IP címet fogja használni.
PAT interfész IP használatával