网安学习NO.14

防火墙基础实验 

传统防火墙配置

实验拓扑图

 网安学习NO.14_第1张图片

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

防火墙透明模式

实验拓扑图

网安学习NO.14_第2张图片 

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


防火墙应用代理

实验拓扑图

网安学习NO.14_第3张图片 

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)

你可能感兴趣的:(网安学习NO.14)