CISCO 過載NAT配置(小型網路)
一.實驗涉及技術
vlan(虛擬區域網)、 svi(三層交換) 、nat(網路地址轉換)、static router(靜態路由)
三.實驗目的:
通過配置過載NAT從而實現企業內網正常訪問公網,PC2可以正常ping通server,但是無法訪問server的HTTP伺服器,PC1正常。
二.實驗拓撲圖
三.實驗過程
首先給PC1、PC2 新增ip、子網、閘道器、DNS 給server配置ip、子網、閘道器
配置二層交換機S1:
Switch>enable
Switch#configure terminal
Switch(config)#hostname S1
S1(config)#no ip domain-lookup
S1(config)#vlan 10
S1(config-vlan)#exit
S1(config)#vlan 20
S1(config-vlan)#exit
S1(config)#int f0/1
S1(config-if)#switchport mode access
S1(config-if)#switchport access vlan 10
S1(config-if)#exit
S1(config)#int f0/2
S1(config-if)#switchport mode access
S1(config-if)#switchport access vlan 20
S1(config-if)#exit
S1(config)#int f0/3
S1(config-if)#switchport mode trunk
S1(config-if)#switchport trunk allowed vlan all
S1(config-if)#end
S1#write
配置三層交換機S2:
Switch>enable
Switch#configure terminal
Switch(config)#hostname S2
S2(config)#no ip domain-lookup
S2(config)#vlan 10
S2(config-vlan)#exit
S2(config)#vlan 20
S2(config-vlan)#exit
S2(config)#int f0/1
S2(config-if)#switchport trunk encapsulation dot1q #指明介面的封裝型別為802.1Q協議
S2(config-if)#switchport mode trunk
S2(config-if)#switchport trunk allowed vlan all
S2(config-if)#exit
S2(config)#int vlan 10
S2(config-if)#ip address 192.168.1.254 255.255.255.0
S2(config-if)#exit
S2(config)#int vlan 20
S2(config-if)#ip address 192.168.2.254 255.255.255.0
S2(config-if)#exit
S2(config)#int vlan 1
S2(config-if)#ip address 192.168.3.1 255.255.255.0
S2(config-if)#no shutdown
S2(config-if)#exit
S2(config)#ip routing #開啟路由器功能
S2(config)#ip route 0.0.0.0 0.0.0.0 192.168.3.3
S2(config)#end
S2#write
配置路由器Router0:
Router>enable
Router#configure terminal
Router(config)#no ip domain-lookup
Router0(config)#hostname Router0
Router0(config)#int f0/0
Router0(config-if)#ip address 192.168.3.3 255.255.255.0
Router0(config-if)#no shutdown
Router0(config-if)#exit
Router0(config)#int se0/3/0
Router0(config-if)#ip address 2.2.2.1 255.255.255.0
Router0(config-if)#clock rate 128000
Router0(config-if)#no shutdown
Router0(config-if)#exit
Router0(config)#ip route 192.168.0.0 255.255.0.0 192.168.3.1
Router0(config)#ip route 0.0.0.0 0.0.0.0 2.2.2.2
Router0(config)#int f0/0
Router0(config-if)#ip nat inside
Router0(config-if)#exit
Router0(config)#int se0/3/0
Router0(config-if)#ip nat outside
Router0(config-if)#exit
Router0(config)#ip nat pool lb 2.2.2.1 2.2.2.1 netmask 255.255.255.0 #定義公網地址池
Router0(config)#access-list 1 permit 192.168.0.0 0.0.255.255 #定義感興趣流量
Router0(config)#ip nat inside source list 1 pool lb overload #實現nat,將感興趣流量和公網地址池進行對映Router(config)#access-list 100 deny tcp 192.168.2.1 0.0.0.255 3.3.3.2 0.0.0.255 eq www #禁止源地址訪問目的地址的tcp的www埠
Router(config)#access-list 100 permit ip any any
Router(config)#int f0/0
Router(config-if)#ip access-group 100 in #將ACL應用到埠
Router(config)#end
Router#write注意:overload表示啟用過載nat,不加關鍵詞就是動態nat
配置路由器Router1:
Router>enable
Router#configure terminal
Router(config)#no ip domain-lookup
Router1(config)#hostname Router1
Router1(config)#int se0/3/0
Router1(config-if)#ip address 2.2.2.2 255.255.255.0
Router1(config-if)#no shutdown
Router1(config-if)#exit
Router1(config)#int f0/0
Router1(config-if)#ip address 3.3.3.1 255.255.255.0
Router1(config-if)#no shutdown
Router1(config)#end
Router1#write