日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

谷德威天津思科CCNA培训之访问控制列表和NAT设置

發布時間:2023/12/29 编程问答 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 谷德威天津思科CCNA培训之访问控制列表和NAT设置 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
谷德威天津思科CCNA培訓之訪問控制列表和NAT設置 實驗五 訪問控制列表及地址轉換
5.1 實驗目的:
1. 熟悉路由器的包過濾的核心技術:訪問控制列表;
2. 掌握訪問控制列表的相關知識;
3. 掌握訪問控制列表的應用,靈活設計防火墻;
4. 熟悉地址轉換特性。
5.2 實驗環境:
在實際的企業網或者校園網絡中為了保證信息安全以及權限控制,都需要分別對待網內的用戶群。有的能夠訪問外部,有的則不能。這些設置往往都是在整個網絡的出口或是入口(一臺路由器上)進行的。所以在實驗室我們用一臺路由器(RTA)模擬整個企業網,用另一臺路由器(RTB)模擬外部網。具體實驗環境如下: 在實際完成實驗時不一定需要兩臺交換機和多臺主機,交換機可以共用一臺,但最好劃分在不同的VLAN下,主機至少兩臺,可以靈活改變IP地址來滿足實驗需求。
5.3 實驗步驟:
5.3.1 實驗準備
按照上面的組網圖建立實驗環境,然后按照如下規則分配IP地址。
路由器接口IP地址:
RTA RTB
S0 192.0.0.1/24 192.0.0.2/24
E0 202.0.0.1/24 202.0.1.1/24
主機的地址和缺省網關:
PCA PCB PCC PCD PCE
IP/MASK 202.0.0.2/24 202.0.0.3/24 202.0.0.4/24 202.0.1.2/24 202.0.1.3/24
GATEWAY 202.0.0.1 202.0.0.1 202.0.0.1 202.0.1.1 202.0.1.1
5.3.2 標準訪問控制列表
標準訪問控制列表只使用數據包的源地址來判斷數據包,所以它只能以源地址來區分數據包,源相同而目的不同的數據包也只能采取同一種策略。所以利用標準訪問控制列表,我們只能粗略的區別對待網內的用戶群,那些主機能訪問外部網,那些不能。我們來完成如下實驗,看看標準訪問控制列表是如何完成該功能的。在實驗環境中,我們如果只允許IP地址為202.0.0.2的主機訪問外部網絡,則只需在路由器上進行如下配置即可:
RTA#show running-config
Now create configuration...
Current configuration
!
??? version 1.5.6
??? firewall enable????????????????????????????????? //啟動防火墻功能
??? access-list normal 1 permit 202.0.0.2 0.0.0.0???????? //允許特定主機訪問外部網絡
??? access-list normal 1 deny 202.0.0.0 0.0.0.255??????? //禁止其他主機訪問外部網絡
??? hostname RTA
!
interface Aux0
??? async mode interactive
??? encapsulation ppp
!
interface Ethernet0
??? speed auto
??? duplex auto
??? no loopback
??? ip address 202.0.0.1 255.255.255.0
!
interface Serial0
??? clock-select DTECLK1
??? encapsulation ppp
??? ip address 192.0.0.1 255.255.255.0
??? ip access-group 1 out??????????????????????????? //使訪問列表生效
!
interface Serial1
??? encapsulation ppp
!
exit
router rip?????????????????????????????????????? //啟動路由協議
??? network all
! end RTB#show running-config
Now create configuration...
Current configuration
!
??? version 1.5.6
??? hostname RTB
!
interface Aux0
??? async mode interactive
??? encapsulation ppp
!
interface Ethernet0
??? speed auto
??? duplex auto
??? no loopback
??? ip address 202.0.1.1 255.255.255.0
!
interface Serial0
??? encapsulation ppp
??? ip address 192.0.0.2 255.255.255.0
!
interface Serial1
??? clock-select DTECLK1
??? encapsulation ppp
!
exit
router rip
??? network all
! end
注意:在配置路由器時還需要配置防火墻的缺省工作過濾模式(firewall default {permit|deny}),因該命令配置與否在配置信息中沒有顯示,所以要特別注意。Quidway系列路由器防火墻默認過濾模式是允許。在此我們也設為允許。(您可以設為禁止,看看實驗現象。此時有可能路由器不能發現動態路由,因為路由協議也是用IP包去發現路由的,禁止了所有IP包的傳送當然不可能生成動態路由。)完成上述配置之后,用網絡測試命令測試PCA是不是真的能夠訪問外部網絡,PCB等主機是不是不能訪問外部網絡呢?
在設置防火墻時,一般選擇在路由器的出口,可以使用ip access-group 101 out來使防火墻生效,但是如果改為ip access-group 101 in呢?試試會是什么現象,是不是任何主機都可以訪問外部網絡呢?答案是肯定的。那么我們如果是在E0口使用ip access-group 101 in命令呢?現象就如同開始一樣了。現在明白in和out的意義了嗎?我們甚至可以在RTB上來完成該項功能,完成如下配置即可達到同樣的效果:
RTA#show running-config
Now create configuration...
Current configuration
!
??? version 1.5.6
??? hostname RTA
!
interface Aux0
??? async mode interactive
??? encapsulation ppp
!
interface Ethernet0
??? speed auto
??? duplex auto
??? no loopback
??? ip address 202.0.0.1 255.255.255.0
!
interface Serial0
??? clock-select DTECLK1
??? encapsulation ppp
??? ip address 192.0.0.1 255.255.255.0
!
interface Serial1
??? encapsulation ppp
!
exit
router rip
??? network all
! end RTB#show running-config
Now create configuration...
Current configuration
!
??? version 1.5.6
??? firewall enable
??? access-list normal 1 permit 202.0.0.2 0.0.0.0
??? access-list normal 1 deny 202.0.0.0 0.0.0.255
??? hostname RTB
!
interface Aux0
??? async mode interactive
??? encapsulation ppp
!
interface Ethernet0
??? speed auto
??? duplex auto
??? no loopback
??? ip address 202.0.1.1 255.255.255.0
!
interface Serial0
??? encapsulation ppp
??? ip address 192.0.0.2 255.255.255.0
??? ip access-group 1 in
!
interface Serial1
??? clock-select DTECLK1
??? encapsulation ppp
!
exit
router rip
??? network all
! end
從上面的實驗可以看出in和out兩個方向不同作用以及使用不同接口的配置差異了,所以在設置防火墻時,我們需要仔細分析,靈活運用,選擇最佳接口,最簡單的配置完成最完善的功能。
5.3.3 擴展訪問控制列表
擴展訪問控制列表不僅使用數據包的源地址作為判斷條件,還使用目的地址、協議號為判斷條件。所以它可以更加詳細的區分數據包,更好的控制用戶訪問。下面我們先應用擴張訪問控制列表來完成前面標準訪問控制列表完成的功能,以便比較。在路由器上的具體配置如下:
RTA(config)#show running-config
Now create configuration...
Current configuration
!
??? version 1.5.6
??? firewall enable
??? access-list normal 101 permit ip 202.0.0.2 0.0.0.0 202.0.1.0 0.0.0.255
??? access-list normal 101 deny ip 202.0.0.0 0.0.0.255 202.0.1.0 0.0.0.255
??? hostname RTA
!
interface Aux0
??? async mode interactive
??? encapsulation ppp
!
interface Ethernet0
??? speed auto
??? duplex auto
??? no loopback
??? ip address 202.0.0.1 255.255.255.0
!
interface Serial0
??? clock-select DTECLK1
??? encapsulation ppp
??? ip address 192.0.0.1 255.255.255.0
??? ip access-group 101 out
!
interface Serial1
??? encapsulation ppp
!
exit
router rip
??? network all
! end RTB#show running-config
Now create configuration...
Current configuration
!
??? version 1.5.6
??? hostname RTB
!
interface Aux0
??? async mode interactive
??? encapsulation ppp
!
interface Ethernet0
??? speed auto
??? duplex auto
??? no loopback
??? ip address 202.0.1.1 255.255.255.0
!
interface Serial0
??? encapsulation ppp
??? ip address 192.0.0.2 255.255.255.0
!
interface Serial1
??? clock-select DTECLK1
??? encapsulation ppp
!
exit
router rip
??? network all
! end
此時用網絡測試命令ping測試主機的通信狀況,應該和前面一樣。剛才提到的擴展訪問控制列表可以更加詳細的控制訪問,那么究竟怎樣才能實現這項要求呢?在此我們只需要把access-list normal 101 permit ip 202.0.0.2 0.0.0.0 202.0.1.0 0.0.0.255換成access-list normal permit ip 202.0.0.2 0.0.0.0 202.0.1.2 0.0.0.0既可以控制主機PCA只能訪問主機PCD,而使用標準訪問控制列表是不能實現的。在訪問控制列表命令中還有normal字段,這是區別于special的,即我們可以分時間段進行不同的訪問控制策略。此時需要允許時間段控制(timerange enable)和設定特定時間段(settr begin-time end-time)。在此不再詳細闡述,學員可以自行完成。
上面的實驗都是只有一條列表,在同一列表中有多條規則,多條規則之間采用深度優先的原則,即描述的地址范圍越小,優先級越高,越先考慮。但是有時候需要在一個接口上使用多條列表,以完成更豐富的功能。但是列表之間有時什么樣的規則呢?還是深度優先嗎?
讓我們看看下面的實驗,RTB不作任何改動,RTA配置如下:
RTA(config-if-Serial0)#show running-config
Now create configuration...
Current configuration
!
??? version 1.5.6
??? firewall enable
??? access-list normal 101 permit ip 202.0.0.2 0.0.0.0 202.0.1.0 0.0.0.255
??? access-list normal 101 deny ip 202.0.0.0 0.0.0.255 202.0.1.0 0.0.0.255
??? access-list normal 102 permit ip 202.0.0.3 0.0.0.0 202.0.1.0 0.0.0.255
??? access-list normal 102 deny ip 202.0.0.0 0.0.0.255 202.0.1.0 0.0.0.255
??? access-list normal 103 deny ip 202.0.0.2 0.0.0.0 202.0.1.0 0.0.0.255
??? hostname RTA
!
interface Aux0
??? async mode interactive
??? encapsulation ppp
!
interface Ethernet0
??? speed auto
??? duplex auto
??? no loopback
??? ip address 202.0.0.1 255.255.255.0
!
interface Serial0
??? clock-select DTECLK1
??? encapsulation ppp
??? ip address 192.0.0.1 255.255.255.0
ip access-group 103 out
ip access-group 102 out
??? ip access-group 101 out
!
interface Serial1
??? encapsulation ppp
!
exit
router rip
??? network all
! end
此時主機PCA也不能與外部網絡通信了,因為首先匹配列表103,發現不允許通過,則拒絕通過。此時列表102、101不啟作用。但是主機PCB可以與外部網通信。列表101不啟作用。如果取消列表102的作用(no ip access-group 102 out),則PCB又不能與外部網絡通信了。所以我們可以得出如下結論:多條列表時,先匹配列表序號大的規則,如果匹配則按該規則處理數據包,如果不匹配則匹配較小序號的列表,直至最后。所以在編寫列表時要多加注意它們之間的先后順序。
5.3.4 地址轉換(NAT)
由于IP地址緊缺,企業網常常使用的都是私有地址,這給訪問外部網絡帶來了麻煩。因為很可能存在兩個IP地址一樣的主機訪問同一個網絡而產生沖突,無法正常完成數據傳輸。所以我們企業網內部主機訪問外部網絡時,需要進行地址轉換,在公網上使用公有地址進行數據傳輸。
地址轉換有兩種方式,一種是通過與接口關聯,使用物理接口的IP地址作為轉換后的公有地址。另一種是通過地址池來完成地址轉換,轉換時可以任意從地址池中選取一個地址進行轉換。讓我們先來看看第一種方式。使用RTA的S0口的IP地址作為公有地址,路由器的具體配置如下:
RTA(config-if-Serial0)#show running-config
Now create configuration...
Current configuration
!
??? version 1.5.6
??? logging console
??? firewall enable
access-list normal 101 permit ip 202.0.0.2 0.0.0.0 any
//允許特定主機訪問外部網絡
access-list normal 101 permit ip 202.0.0.3 0.0.0.0 any
//允許內部服務器訪問外部網絡
access-list normal 101 deny ip any any
//禁止所有包通過
access-list normal 102 permit tcp 202.0.1.2 0.0.0.0 192.0.0.1 0.0.0.0
//允許特定外部主機訪問內部服務器
access-list normal 102 deny tcp any 192.0.0.1 0.0.0.0
//禁止其他外部用戶訪問內部服務器
??? hostname RTA
!
interface Aux0
??? async mode interactive
??? encapsulation ppp
!
interface Ethernet0
??? speed auto
??? duplex auto
??? no loopback
??? ip address 202.0.0.1 255.255.255.0
??? ip access-group 101 in
!
interface Serial0
??? clock-select DTECLK1
??? encapsulation ppp
??? ip address 192.0.0.1 255.255.255.0
??? nat inside 102 interface?????????????????????????????????? //使列表與接口關聯
??? nat server global 192.0.0.1 ftp inside 202.0.0.3 ftp tcp???????? //內部ftp服務器
??? ip access-group 102 in
!
interface Serial1
??? encapsulation ppp
!
exit
router rip
??? network all
! end RTB#show running-config
Now create configuration...
Current configuration
!
??? version 1.5.6
??? hostname RTB
!
interface Aux0
??? async mode interactive
??? encapsulation ppp
!
interface Ethernet0
??? speed auto
??? duplex auto
??? no loopback
??? ip address 202.0.1.1 255.255.255.0
!
interface Serial0
??? encapsulation ppp
??? ip address 192.0.0.2 255.255.255.0
!
interface Serial1
??? clock-select DTECLK1
??? encapsulation ppp
!
exit
router rip
??? network all
! end
在上面的配置中完成了內部向外部網絡提供ftp服務器,允許內部特定主機PCA能夠訪問外部網絡,允許外部特定用戶PCD可以訪問ftp服務器。在PCB上提供ftp服務,然后測試是否滿足設計需求。我們還可以使用監控與維護命令顯示地址轉換狀態,如:
RTA#show nat
Nat Pool Information:
???????? ddd : from?????? 192.0.0.3?? to?????? 192.0.0.4 Server in Private network Information:
??????? Interface????? GlobalAddr?? GlobalPort InsideAddr??? InsidePort?? Pro
?????????? Serial0??????? 192.0.0.1?? 21(ftp)??????? 202.0.0.3?? 21(ftp) 6(tcp) Nat Access table Information:
????????? Serial0: Access-list(102) --- Interface Nat timeout value Information:
???? tcp ---- timeout value is???? 240 (seconds)
???? udp ---- timeout value is???? 40 (seconds)
icmp ---- timeout value is???? 20 (seconds)
從顯示信息可以看到地址轉換對應表,地址池信息以及地址轉換有效時間。我們還可以根據需要更改地址轉換有效時間(nat timeout)。還可以查看nat的調試信息如:
RTA#debug nat packet
Debugging NAT packet is on
RTA#
NAT In:find a TCP packet to server(192.0.0.1:21---->202.0.0.3:21)
NAT_Forward:TCP packet to inside server(202.0.0.3:21----->192.0.0.1:21)
NAT In:find a TCP packet to server(192.0.0.1:21---->202.0.0.3:21)
NAT_Forward:TCP packet to inside server(202.0.0.3:20----->192.0.0.1:20)
NAT_Forward:TCP packet to inside server(202.0.0.3:21----->192.0.0.1:21)
NAT In:find a TCP packet to server(192.0.0.1:20---->202.0.0.3:20)
可以通過此命令檢查是否有數據包被轉換,地址是如何轉換的。這對我們的調試有很大幫助。
第二種方式是地址池關聯。該方式可以應用多個公有地址來完成地址轉換,增大數據轉換量。該方式的配置如下:(RTB不作改變)
RTA#show running-config
Now create configuration...
Current configuration
!
??? version 1.5.6
??? nat timeout tcp 300???????????????????????????????? //設定地址轉換有效時間
??? nat pool 192.0.0.3 192.0.0.4 ddd?????????????????????? //配置地址池
??? logging console
??? firewall enable
??? access-list normal 101 permit ip 202.0.0.2 0.0.0.0 any
??? access-list normal 101 permit ip 202.0.0.3 0.0.0.0 any
??? access-list normal 101 deny ip any any
??? access-list normal 102 permit tcp 202.0.1.2 0.0.0.0 192.0.0.3 0.0.0.0
??? access-list normal 102 deny tcp any 192.0.0.3 0.0.0.0
??? hostname RTA
!
interface Aux0
??? async mode interactive
??? encapsulation ppp
!
interface Ethernet0
??? speed auto
??? duplex auto
??? no loopback
??? ip address 202.0.0.1 255.255.255.0
??? ip access-group 101 in
!
interface Serial0
??? clock-select DTECLK1
??? encapsulation ppp
??? ip address 192.0.0.1 255.255.255.0
??? nat inside 102 pool ddd?????????????????????????? //將列表與地址池關聯
??? nat server global 192.0.0.3 ftp inside 202.0.0.3 ftp tcp
??? ip access-group 102 in
!
interface Serial1
??? encapsulation ppp
!
exit
router rip
??? network all
! end
完成上述配置后,測試功能需求,應該滿足需要。注意在本實驗中配置地址池時是使用的開始地址和結束地址,所以地址池中的地址需要且必須連續,且最多只能定義64個地址。
小結
關于防火墻我們主要講述了標準訪問控制列表、擴展訪問控制列表以及地址轉換。我們在完成實驗時要多注意其中的區別與聯系,特別是不同的使用場合。還有多條規則,多條列表的作用原則的掌握。 更多技術資料訪問 谷德威(天津)www.gdinformation.com www.ciscotj.com

轉載于:https://blog.51cto.com/alismen/397808

總結

以上是生活随笔為你收集整理的谷德威天津思科CCNA培训之访问控制列表和NAT设置的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。