欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

思科CCNA認證之 NAT 子網(wǎng)地址轉換原理與配置詳解

  發(fā)布時間:2020-03-16 15:46:13   作者:司家勇   我要評論
這篇文章主要介紹了思科CCNA認證之 NAT 子網(wǎng)地址轉換原理與配置,詳細分析了思科NAT 子網(wǎng)地址轉換相關概念、原理、配置命令與操作注意事項,需要的朋友可以參考下

本文講述了思科CCNA認證之 NAT 子網(wǎng)地址轉換。分享給大家供大家參考,具體如下:

NAT 網(wǎng)絡地址轉換

全稱:Network Address Translation

為什么需要NAT?

因為公網(wǎng)IP(IPv4)地址緊缺,內容地址通過NAT轉換成一個公有地址去訪問公網(wǎng)資源;

如下圖展示:

私有地址列表

  • A類: 10.0.0.0/8
  • B類: 172.16.0.0/16
  • C類: 192.168.1.0/24
名詞 解釋
內部本地 轉換之前內部原地址的名字
外部本地 轉換之前目標主機的名字
內部全局 轉換之后內部主機的名字
外部全局 轉換之后外部目標主機的名字

NAT的三種類型

1、靜態(tài)NAT

內部本地地址與內部全局地址進行一對一的明確轉換。這種方法主要用在內部網(wǎng)絡中有對外提供服務的服務器,如WEBMAIL服務器時。該方法的缺點是需要占獨寶貴的合法IP地址。即如果某個合法IP地址已經(jīng)被NAT靜態(tài)地址轉換定義,即使該地址當前沒有被使用,也不能被用作其他的地址轉換。

配置:

 

Router(config)#ip nat inside source static local-ip globl-ip

  • Establishes static translation between an inside local address and an inside global address

     

Router(config)#ip nat inside

  • Marks the interface as connected to the inside

     

Router(config)#ip nat outside

  • Marks the interface as connected to the outside

     

Router(config)#show ip nat translations

  • Displays active translations

     

案例:
如下圖:

2、動態(tài)NAT

動態(tài)地址轉換也是將內部本地地址與內部全局地址進行一對一的轉換。但是是從內部全局地址池中動態(tài)的選擇一個未使用的地址對內部本地地址進行轉換。該地址是由未被使用的地址組成的地址池中在定義時排在最前面的一個。當數(shù)據(jù)傳輸完畢后,路由器將把使用完的內部全局地址放回到地址池中,以供其他內部本地地址進行轉換。但是在改地址被使用時,不能用改地址再進行一次轉換。

配置:

Router(config)#ip nat poll name start-ip end-ip {netmask netmask | prefix-length prefix-length}

  • Defines a pool of global addresses to be allocated as needed

     

Router(config)#access-list access-list-number permit source [source-wildcard]

  • Defines a standard IP ACL permitting those inside local addresses that are to be translated

     

Router(config)#ip nat inside source list access-list-number pool name

  • Establishes dynameic source translation, specifying the ACL that was defined in the previous step

     

Router(config)#show ip nat translations

  • Displays active translations

案例:

3、端口復用(PAT)

  • 服用地址轉換也稱為端口地址轉換(Port Address Translation, PAT),首先是一種動態(tài)地址轉換,路由器將通過幾率地址、應用程序端口等唯一標示一個轉換。通過這種轉換,可以使多個內部本地地址同時與同一個內部全局地址進行轉換并對外部網(wǎng)絡進行訪問。很多只申請到少量IP地址甚至只有一個合法IP、地址,卻京城有很多用戶同時要求上午的情況,這轉換方式非常有用;
  • 理想狀態(tài)下,一個單一的IP地址可以使用的端口為4000個

配置:

Router(config)#access-list access-list-number permit source source-wildcard

  • Defines a standard IP ACL that will permit the inside local addresses that are to be translated

     

Router(config)#ip nat inside source list access-list-number interface interface overload

  • Establishes dynameic source translation, specifying the ACL that was defined in the previous step

     

Router(config)#show ip nat translations

  • Displays active translations

案例:

NAT試驗

按照下圖中的網(wǎng)絡拓撲進行配置:

同樣server和PC均使用路由來代替,需要一下配置:

no ip routing
ip default-gateway xxx.xxx.xxx.xxx

注:如果沒有配置no ip routing,則默認網(wǎng)關的配置不生效;

下面進行配置:

Server配置:

R2>en
R2#conf t
R2(config)#hostname Server
Server(config)#int f 0/0
Server(config-if)#ip add 192.168.1.100 255.255.255.0
Server(config-if)#no sh
Server(config-if)#exit
Server(config)#no ip routing
Server(config)#ip default-gateway 192.168.1.254
Server(config)#line vty 0 4
Server(config-line)#pass
Server(config-line)#password sijiayong

服務器配置了vty,等下需要測試telnet連接;

PC配置:

R1>en
R1#conf t
R1(config)#hostname PC
PC(config)#int f 0/0
PC(config-if)#ip add 192.168.1.1 255.255.255.0
PC(config-if)#no sh
PC(config-if)#exit
PC(config)#no ip routing
PC(config)#ip default-gateway 192.168.1.254

路由配置:

R3>en
R3#conf t
Router(config)#hostname Gateway
Gateway(config)#int f 0/0
Gateway(config-if)#ip add 192.168.1.254 255.255.255.0
Gateway(config-if)#no sh
Gateway(config-if)#exit
Gateway(config)#int s 1/0
Gateway(config-if)#ip add 10.0.0.1 255.255.255.0
Gateway(config-if)#no sh
Gateway(config-if)#exit
Gateway(config)#ip route 0.0.0.0 0.0.0.0 10.0.0.2
Gateway(config)#access-list 1 permit 192.168.1.0 0.0.0.255
Gateway(config)#ip nat inside source list 1 interface s1/0 overload
Gateway(config)#int f 0/0
Gateway(config-if)#ip nat inside
Gateway(config-if)#int s 1/0
Gateway(config-if)#ip nat outside
Gateway(config-if)#end

模擬外網(wǎng)配置:

R4>en
R4#conf t
R4(config)#hostname Internet
Internet(config)#int s 0/0
Internet(config-if)#ip add 10.0.0.2 255.255.255.0
Internet(config-if)#no sh

這樣配置,服務器和PC就都可以訪問外網(wǎng)地址10.0.0.2

測試:

PC#ping 10.0.0.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.0.0.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 4/25/76 ms


Server#ping 10.0.0.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.0.0.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 8/15/40 ms

驗證通過;

實驗要求2:

要求公網(wǎng)能夠通過10.0.0.3的公網(wǎng)地址,連接到服務器Server,也就是能夠telnet連接到服務器;

這樣只需要配置路由器,吧10.0.0.3映射到192.168.1.100地址上即可;
配置如下:

Gateway(config)#ip nat inside source static 192.168.1.100 10.0.0.3

這個映射的配置,就可以了,通過10.0.0.1的公網(wǎng)進行測試pingtelnet

Internet#ping 10.0.0.3
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.0.0.3, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 8/27/80 ms
Internet#telnet 10.0.0.3
Trying 10.0.0.3 ... Open
User Access Verification
Password:
Server>exit
[Connection to 10.0.0.3 closed by foreign host]

測試通過;

但同時發(fā)現(xiàn)有個危險,這種配置,是把Server服務器整個暴露在公網(wǎng)上,存在安全隱患;

常規(guī)工作中,一般只需要對公網(wǎng)暴露一個或者兩個端口,一般都是Http80端口和SSH22端口,這樣更能夠保障服務器的安全;

本次以開放telnet23端口進行測試;
首先要刪除掉當前的nat配置,然后在進行端口映射;
配置如下:

Gateway(config)#no ip nat inside source static 192.168.1.100 10.0.0.3
Gateway(config)#ip nat inside source static tcp 192.168.1.100 23 10.0.0.3 8080

這里對外暴露的是8080端口,映射到內網(wǎng)地址的192.168.1.10023端口上,下面進行telnet測試。

Internet#telnet 10.0.0.3 8080
Trying 10.0.0.3, 8080 ... Open
User Access Verification
Password:
Server>exit
[Connection to 10.0.0.3 closed by foreign host]

測試通過,至此,配置完成;

相關文章

最新評論