NAT實戰——端口多路複用(PAT)

端口多路複用(PAT)

設置方式:ide

方法一:創建地址池(單一地址)做爲對外全局地址3d

方法二:不創建地址池(設置端口做爲對外地址)code

方法一:

拓撲圖以下:blog

NAT實戰——端口多路複用(PAT)

實驗步驟:

一、設定三臺PC機的地址ip

PC1路由

PC1> 
PC1> ip 192.168.100.30 192.168.100.1
Checking for duplicate address...
PC1 : 192.168.100.30 255.255.255.0 gateway 192.168.100.1

PC1>

PC2it

PC2> 
PC2> ip 192.168.100.20 192.168.100.1 
Checking for duplicate address...
PC1 : 192.168.100.20 255.255.255.0 gateway 192.168.100.1

PC2>

PC3io

PC3> 
PC3> ip 10.0.0.10 10.0.0.1
Checking for duplicate address...
PC1 : 10.0.0.10 255.255.255.0 gateway 10.0.0.1

PC3>

二、設定二層交換機swconsole

sw#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
sw(config)#no ip routing                      //關閉路由功能,使三層交換鏡像變爲二層交換機
sw(config)#

三、設定路由R1ast

R1#conf t 
Enter configuration commands, one per line.  End with CNTL/Z.
R1(config)#int f 0/0
R1(config-if)#ip add 192.168.100.1 255.255.255.0        //僅設定IP地址與子網掩碼
R1(config-if)#no shut 
*Mar  1 00:06:33.063: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
*Mar  1 00:06:34.063: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
R1(config-if)#int f 0/1
R1(config-if)#ip add 10.0.0.1 255.0.0.0                //僅設定IP地址與子網掩碼
R1(config-if)#no shut 
R1(config-if)#ex 
*Mar  1 00:06:48.191: %LINK-3-UPDOWN: Interface FastEthernet0/1, changed state to up
*Mar  1 00:06:49.191: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
R1(config)#

注意:此時理論上是已經能夠作到全網互通的,具體見下圖。若是沒法鏈接請自行檢查命令。

NAT實戰——端口多路複用(PAT)

爲知足實驗要求,下面將正式進行PAT(端口多路複用)的設置。

四、在路由R1上進行PAT設置

R1(config)#access-list 1 permit 192.168.100.0 0.0.0.255               //創建標準ACL
R1(config)#ip nat pool kgc 10.0.0.20 10.0.0.20 netmask 255.0.0.0      //創建地址池
*Mar  1 00:08:29.815: %LINEPROTO-5-UPDOWN: Line protocol on Interface NVI0, changed state to up
R1(config)#ip nat inside source list 1 pool kgc                 //創建PAT

R1(config)#int f 0/1
R1(config-if)#ip nat inside                            //在內部啓用PAT
R1(config-if)#int f 0/0
R1(config-if)#ip nat outside                          //在外部啓用PAT
R1(config-if)#end
R1#
*Mar  1 00:10:27.007: %SYS-5-CONFIG_I: Configured from console by console
R1#

驗證結果

NAT實戰——端口多路複用(PAT)

實驗成功,外網能訪問的IP地址以更改成公網IP。

方法二:

拓撲圖以下:

NAT實戰——端口多路複用(PAT)

實驗步驟

前面全部對PC一、PC二、PC三、sw以及R1的設置均與方法一相同,再也不過多贅述。這裏只對PAT的設置與啓用進行說明

設置PAT
R1(config)#access-list 1 permit 192.168.100.0 0.0.0.255           //創建標準ACL
R1(config)#ip nat inside source list 1 interface f0/1 overload      //不進行地址池的設置,將外部端口f0/1的IP做爲對外全局地址

R1(config)#
R1(config)#int f 0/0          
R1(config-if)#ip nat inside                     //啓用內部PAT
R1(config-if)#int f 0/1
R1(config-if)#ip nat outside                    //啓用外部PAT
R1(config-if)#end 
R1#

實驗結果

NAT實戰——端口多路複用(PAT)

相關文章
相關標籤/搜索