防火墻基礎實驗?
傳統防火墻配置
實驗拓撲圖
?
PC:
ip 192.168.10.1 255.255.255.0 192.168.10.254
ip dns 114.114.114.114
二層交換機
vl 10
ex
int e0/0
sw mo ac
sw ac vl 10
ex
inr e0/1
sw tr en do
sw mo tr
三層交換機
vl 10
ex
int g0/0
sw tr en do
sw mo tr
ex
ip routing
int vl 10
ip address 192.168.10.254 255.255.255.0
no shutdown
int g0/1
no switchport
no shutdown
ip address 10.1.1.1 255.255.255.252
ex
ip route 0.0.0.0 0.0.0.0 10.1.1.2(下一跳為防火墻g0/2口)
路由器(作為服務器)
int e0/0
ip add 192.168.2.88 255.255.255.0
no shut?? ?
ex
no ip routing(關閉路由功能)
ip default-gateway 192.168.2.1
ip name-server 114.114.114.114
ip http server
line vty 0 4
no login
transport input telnet
exit
防火墻
en
password:(無密碼,回車)
int g0/2
nameif inside
security-level 100(定義安全級別)
ip add 10.1.1.2 255.255.255.252
no shut
exit
int g0/1(公網區域)
nameif outside
security-level 0
ip address dhcp setroute(配置為DHCP客戶端,從net網絡獲取IP,并獲得默認路由)
no shutdown
exit
int g0/0
no shutdown
nameif dmz(服務器區域)
security-level 50
ip add?? ?192.168.2.1 255.255.255.0
ex
防火墻路由配置
方法一:靜態路由
route inside 192.168.10.0 255.255.255.0 10.1.1.1
(默認路由已經由DHCP獲得)
方法二:動態路由,就是防火墻與核心層交換機運行RIP、OSPF
router ospf 1
router-id 1.1.1.1
network 192.168.2.0 255.255.255.0 area 0
network 10.1.1.0 255.255.255.252 area 0
實現內網PC上公網,使用動態NAT及配置:
方法一:用出接口做PAT
object network inside (定義內網需要上網的網段)
subnet 192.168.10.0 255.255.255.0
nat (inside,outside) dynamic interface (這里使用outside區接口做PAT 上網)
方法二:定義地址池轉換
object network inside
subnet 192.168.10.0 255.255.255.0
exit
object network outside-pool
range 192.168.116.138 192.168.116.139(為g0/1獲得的網段)
ex
object network inside
nat (inside,outside) dynamic outside-pool
ASA防火墻默認不對ICMP做狀態檢測,需開啟
policy-map global_policy(指的是在網絡設備(如路由器、交換機等)配置中,定義一個名為 “global_policy” 的策略映射)
class inspection_default
inspect icmp
ex
(show xlate 查看防火墻的nat表)
配置使得服務器可以上公網
object network dmz(定義服務器需要上網的網段)
subnet 192.168.2.0 255.255.255.0
nat (dmz,outside) dynamic interface(用outside接口IP做PAT)
測試:在服務器端ping www.zhynet,net
實現服務器對外提供80端口和 23端口telnet 服務,使用靜態NAT配置
方法一:靜態NAT1對1
object network dmz1
host 192.168.2.88(指定服務器私網IP)
nat (dmz,outside) static 192.168.116.138
方法二:靜態PAT(web和telnet對外提供訪問)
object network dmz2
host 192.168.2.88
nat (dmz,outside) static 192.168.116.138 service tcp 23 23(前23代表內部服務器的開放端口,后23代表對外部用戶訪問的端口,也可以和內部開放的端口不一樣)
object network dmz3(有多個端口需要映射時需要配置多個這樣的配置)
host 192.168.2.88
nat (dmz,outside) static 192.168.116.138 service tcp 80 80
防火墻默認,不允許從低級別區域向高級別區域發起連接,需要手動放通
access-list webtel permit tcp any host 192.168.2.88 eq 80
access-list webtel permit tcp any host 192.168.2.88 eq 23
access-group webtel in interface outside
在公網PC上cmd測試
telnet 192.168.116.138
telnet 192.168.116.138 80
防火墻透明模式
實驗拓撲圖
?
PC:192.168.10.1 255.255.255.0 192.168.10.254 114.114.114.114
二層交換機
vl 10
ex
int e0/0
sw mo ac
sw ac vl 10
ex
int e0/1
sw tr en do
sw mo tr
ex
三層交換機
vl 10
ex
int g0/0
sw tr en do
sw mo tr
ex
ip routing
int vl 10
ip add?? ?192.168.10.254 255.255.255.0
no shutdown
int g0/1
no switchport
no shut
ip add?? ?10.1.1.1 255.255.255.0
ex?
ip route 0.0.0.0 0.0.0.0 10.1.1.2(配置缺省路由,下一跳為邊界路由器e0/1接口)
路由器配置
int e0/1
ip add?? ?10.1.1.2 255.255.255.0
no shut
ex
int e0/0
no shut
ip add?? ?dhcp
ex
ip route 192.168.10.0 255.255.255.0 10.1.1.1
int e0/0
ip nat outside
int e0/1
ip nat inside
ex
access-list 1 permit 192.168.10.0 0.0.0.255
ip nat inside source list 1 int e0/0 overload
防火墻配置
firewall transparent(切換到透明模式)#查看當前工作模式(show firewall);如果要重新返回路由模式(no firewall transparent)
int bvi 1
ip add?? ?10.1.1.3 255.255.255.0
int g0/2
namif inside
security-level 100
no shut
bridge-group 1
exit
int g0/1
nameif outside
security-level 0
no shut
bridge-group 1
ex
policy-map global_policy
class inspection_default
inspect icmp
ex
然后測試內網PC是否可以上網
ping 114.114.114.114
ping www.baidu.com
防火墻應用代理
實驗拓撲圖
?
PC:192.168.10.1 255.255.255.0 192.168.10.254 114.114.114.114
二層交換機
vl 10
ex
int e0/0
sw mo ac
sw ac vl 10
ex
int e0/1
sw tr en do
sw mo tr
三層交換機
vl 10
ex
int g0/0
sw tr en do
sw mo tr
ex
ip routing
int vl 10
ip add?? ?192.168.10.254 255.255.255.0
no shut?? ?
int g0/1
no switchport
no shut
ip add?? ?10.1.1.1 255.255.255.252
ex
ip route 0.0.0.0 0.0.0.0 10.1.1.2
防火墻配置
int g0/2
nameif inside
security-level 100
ip add?? ?10.1.1.2 255.255.255.252
no shut
ex
int g0/1
nameif outside
security-level 0
ip add?? ?dhcp setroute
no shut
ex
show ip int br
route inside 192.168.10.0 255.255.255.0 10.1.1.1
show route
object network inside
subnet 192.168.10.0 255.255.255.0
nat (inside,outside) dynamic interface(使用outside區接口做PAT上網)
policy-map global_policy
class inspection_default
inspect icmp
ex
接下來驗證主機是否可以上網
ping www.baidu.com
配置應用代理防火墻的身份認證功能:
username zhongyuan password zhongyuan (創建用戶名和密碼)
access-list auth deny udp any any eq 53
access-list auth permit ip any any
aaa authentication match auth inside LOCAl(注意大寫,開啟內網認證,aaa是名稱)
show uauth(查看認證通過的用戶列表)
實現應用代理防火墻的URL過濾:
access-list aaa permit tcp any any eq 80
class-map aaa1
match access-list aaa
ex
regex urla"\.baidu\.com"(定義名稱為urla的正則表達式,標識URL的擴展名是“baidu.com”)
class-map type regex math-any urla1
match regex urla
ex
class-map type inspect http urla2(創建class-map檢查http流量)
match request hesder host regex class urls1(調用urla)
創建policy-map(策略映射)關聯class-map
policy-map type inspect http policy1(創建policy-map檢查http流量)
class urla2(調用class-map)
drop-connection log(drop數據包且關閉連接,并發送系統日志)
policy-map policy2(創建policy-map,應用到接口)
class aaa1(調用之前的class-map)
inspect http policy1(檢查http流量)
service-policy policy2 interfce inside(注意一個接口只能應用一個policy-map)