NAT網絡地址轉換——動態地址轉換,PAT端口多路複用(實操!!)

動態NAT地址轉換

實驗拓撲圖

NAT網絡地址轉換——動態地址轉換,PAT端口多路複用(實操!!)

1,配置sw二層交換機

sw#conf t 
sw(config)#no ip routing        //關閉路由功能
sw(config)#int f1/0
sw(config-if)#speed 100         //配置速率  
sw(config-if)#dup full          //配置全雙工模式

2,配置R1路由器,並配置NAT

1)配置路由的接口地址網關

R1#conf t   ##全局模式
R1(config)#int f0/0    ##進入接口 
R1(config-if)#ip add 192.168.100.1 255.255.255.0   ##配置接口的地址網關
R1(config-if)#no shut   ##開啓
R1(config-if)#int f0/1 
R1(config-if)#ip add 12.0.0.1 255.255.255.0
R1(config-if)#no shut
R1(config-if)#ex

2)配置NAT地址轉換

R1(config)#access-list 1 permit 192.168.100.0 0.0.0.255         //設定內部地址轉化範圍
R1(config)#ip nat pool test 12.0.0.10 12.0.0.100 netmask 255.255.255.0          ////設定外部地址轉化範圍
R1(config)#ip nat inside source list 1 pool test            //調用ip地址池
R1(config)#int f0/0
R1(config-if)#ip nat inside                 //將NAT應用於內部端口
R1(config-if)#int f0/1
R1(config-if)#ip nat outside                //將NAT應用於外部端口
R1(config-if)#end

3,配置pc機的ip地址

PC1> ip 192.168.100.10 192.168.100.1  ##配置pc1的ip地址
Checking for duplicate address...
PC1 : 192.168.100.10 255.255.255.0 gateway 192.168.100.1

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

PC3> ip 12.0.0.12 12.0.0.1
Checking for duplicate address...
PC1 : 12.0.0.12 255.255.255.0 gateway 12.0.0.1

4,測試全網互通性,並查看debug地址轉換的過程

測試全網互通性網絡

PC1> ping 12.0.0.12
84 bytes from 12.0.0.12 icmp_seq=1 ttl=63 time=31.244 ms
84 bytes from 12.0.0.12 icmp_seq=2 ttl=63 time=31.282 ms
84 bytes from 12.0.0.12 icmp_seq=3 ttl=63 time=46.897 ms
84 bytes from 12.0.0.12 icmp_seq=4 ttl=63 time=46.834 ms
84 bytes from 12.0.0.12 icmp_seq=5 ttl=63 time=31.210 ms

PC2> ping 12.0.0.12
84 bytes from 12.0.0.12 icmp_seq=1 ttl=63 time=46.864 ms
84 bytes from 12.0.0.12 icmp_seq=2 ttl=63 time=46.864 ms
84 bytes from 12.0.0.12 icmp_seq=3 ttl=63 time=31.242 ms
84 bytes from 12.0.0.12 icmp_seq=4 ttl=63 time=31.273 ms
84 bytes from 12.0.0.12 icmp_seq=5 ttl=63 time=31.208 ms

debug功能查看地址轉換的過程ide

R1#debug ip nat
IP NAT debugging is on
R1#
*Mar  1 00:15:21.287: NAT*: s=192.168.100.10->12.0.0.10, d=12.0.0.12 [55463]
*Mar  1 00:15:21.295: NAT*: s=12.0.0.12, d=12.0.0.10->192.168.100.10 [55463]

//PC1 地址轉換成功

R1#
*Mar  1 00:19:12.139: NAT*: s=192.168.100.20->12.0.0.11, d=12.0.0.12 [55693]
*Mar  1 00:19:12.159: NAT*: s=12.0.0.12, d=12.0.0.11->192.168.100.20 [55693]

//PC2 地址轉換成功

PAT端口多路複用

實驗拓撲圖

NAT網絡地址轉換——動態地址轉換,PAT端口多路複用(實操!!)

1,配置sw二層交換機

sw#conf t
    sw(config)#no ip routing            //關閉路由功能
    sw(config)#int f1/0 
    sw(config-if)#speed 100             //配置速率
    sw(config-if)#dup full              //配置全雙工模式
    sw(config-if)#ex

2,配置R1路由器,並配置NAT

R1#conf t
    R1(config)#int f0/0
    R1(config-if)#ip add 192.168.100.1 255.255.255.0
    R1(config-if)#no shut
    R1(config-if)#int f0/1
    R1(config-if)#ip add 12.0.0.1 255.255.255.0
    R1(config-if)#no shut
    R1(config-if)#ex
    R1(config)#access-list 1 permit 192.168.100.0 0.0.0.255
    //定義內部訪問列表
    R1(config)#ip nat inside source list 1 interface fastEthernet 0/1 overload 
    //設置複用動態IP地址轉換於外部接口
    R1(config)#int f0/0
    R1(config-if)#ip nat inside     
    R1(config-if)#int f0/1
    R1(config-if)#ip nat outside
    R1(config-if)#end

3,配置客戶機ip地址

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

    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

    PC3> ip 12.0.0.12 12.0.0.1
    Checking for duplicate address...
    PC1 : 12.0.0.12 255.255.255.0 gateway 12.0.0.1

4,測試全網互通性,並使用debug查看PAT轉換過程

PC1> ping 12.0.0.12
    84 bytes from 12.0.0.12 icmp_seq=1 ttl=63 time=31.242 ms
    84 bytes from 12.0.0.12 icmp_seq=2 ttl=63 time=46.864 ms
    84 bytes from 12.0.0.12 icmp_seq=3 ttl=63 time=31.280 ms
    84 bytes from 12.0.0.12 icmp_seq=4 ttl=63 time=31.241 ms
    84 bytes from 12.0.0.12 icmp_seq=5 ttl=63 time=31.241 ms

    R1#debug ip nat
    IP NAT debugging is on
    R1#
    *Mar  1 00:32:57.215: NAT*: s=192.168.100.10->12.0.0.1, d=12.0.0.12 [59174]
    *Mar  1 00:32:57.219: NAT*: s=12.0.0.12, d=12.0.0.1->192.168.100.10 [59174]
    ...
    //私網地址192.168.100.10已轉換成功公網地址12.0.0.1,並接收到來自公網主機的回覆信息

    PC2> ping 12.0.0.12
    84 bytes from 12.0.0.12 icmp_seq=1 ttl=63 time=31.242 ms
    84 bytes from 12.0.0.12 icmp_seq=2 ttl=63 time=31.245 ms
    84 bytes from 12.0.0.12 icmp_seq=3 ttl=63 time=31.244 ms
    84 bytes from 12.0.0.12 icmp_seq=4 ttl=63 time=31.213 ms
    84 bytes from 12.0.0.12 icmp_seq=5 ttl=63 time=31.246 ms

    R1#
    *Mar  1 00:35:15.595: NAT*: s=192.168.100.20->12.0.0.1, d=12.0.0.12 [59312]
    *Mar  1 00:35:15.607: NAT*: s=12.0.0.12, d=12.0.0.1->192.168.100.20 [59312]
    ...
    ////私網地址192.168.100.20已轉換成功公網地址12.0.0.1,並接收到來自公網主機的回覆信息

謝謝閱讀!!!

相關文章
相關標籤/搜索