2024年3月29日发(作者:)
ASA配置命令
(config)#hostname asa802 配置主机名
(config)#domain-name 配置域名
(config)#enable password asa802 配置特权密码
(config)#passwd cisco 配置远程登录密码(TELNET,SSH)
(config-if)#nameif inside 配置接口名字
(config-if)#security-level 100 安全级别(0-100)
(config)#route 接口名 目标网段和掩码 下一跳 配置路由
#show route 查看路由表
配置TELNET接入
(config)#telnet (network|ip-address) mask interface-name
例: (config)#telnet 192.168.0.0 255.255.255.0 inside 允许192.168.0.0/24 telnet
(config)#telnet timeout minutes(1~1440分钟默认5分钟) 配置空闲超时时间
配置SSH接入
(1) 为防火墙分配一个主机名和域名,因为生成RSA密匙对需要用到主机名和域名
(2) 生成RSA密匙对(config)#crypto key generate rsa modulus (512 | 768 | 1024 | 2048)
(3) 配置防火墙允许SSH接入 (config)#ssh 192.168.0.0 255.255.255.0 inside
(config)#ssh version (1|2) SSH版本
(config)#ssh timeout 30 配置SSH超时
(config)#show ssh session 查看SSH会话
配置ASDM接入(自适应安全设备管理器)
(1) 启用防火墙HTTPS服务器功能
(config)#http server enable (port) 默认使用443端口
(2) 配置防火墙允许HTTPS接入
(config)#http {network|ip-address} mask interface-name
(3) 指定ASDM映像的位置
(config)#asdm image disk0:/asdmfile
(4) 配置客户端登录使用的用户名和密码
(config)#username user password password privilege 15
客户端使用ASDM步骤
(1)从网站下载安装jiava runtime environment (JRE),这里下载的是
(2) 在主机PC1上启动IE浏览器 ,输入ASA的IP地址
NAT网络地址转换
(config)#nat (interface_name) id local_ip mask
(启用nat-control,可以使用nat0 指定不需要被转换的流量)
如:(config)#nat (inside)1 192.168.0.0 255.255.255.0
GLOBAL命令
(config)#global (interface-name) nat-id (global-ip 【-global-ip】)
如: (config)#global (outside) 1 200.1.1.100-200.1.1.150
(config)#global (outside)1 Internet
查看地址转换条目 show xlate
配置ACL
(config)#access-list in_to_out deny ip 192.168.0.0 255.255.255.0 any
1
应用到接口(config)#access-group in_to_out in interface inside
启用nat-control后从低安全级别访问高安全级别要配置NAT规则
Static NAT (config)#static (dmz,outside) 200.1.1.253 192.168.1.1
如要让外网的主机访问DMZ的WEB站点
(config)#static (dmz,outside) 200.1.1.253 192.168.1.1
(config)#access-list out_to_dmz permit tcp any host 200.1.1.253 eq www
(config)#access-group out_to_dmz in interface outside
ICMP协议
(config)#access-list 100 permit icmp any any echo-reply
(config)#access-list 100 permit icmp any any echo-unreachable
(config)#access-list 100 permit icmp any any time-exceeded
(config)#access-group 100 in interface outside
URL过滤
1) 配置ACL
(config)#access-list tcp_filter permit tcp 192.168.0.0 255.255.255.0 any eq www
2) 定义类关联到ACL
(config)#class-map tcp_filter_class
(config-cmap)#match access-list tcp_filter
(config-cmap)#exit
3) 正则表达式
(config)#regex url1 “.”
定义名为
url1
的正则表达式
URL
后缀是
.
4) 类,关联正则表达式
(config)#class-map type regex match-any url_class
(config-camp)#match regex url1
(config-camp)#exit
5) 类检查
(config)#class-map type inspect http http_url_class
(config-camp)#match not request header host regex class url_class
(config-camp)#exit
6) 创建策略检查项
(config)#policy-map type inspect http http_url_policy
(config-pmap)#class http_url_class
(config-pmap-c)#drop-connection log drop
数据包并关闭连接,并发送系统日志
(config-pmap-c)#exit
(config-pmap)#exit
7) 策略关联类
(config)#policy-map inside_http_url_policy
(config-pmap)#class tcp_filter_class
(config-pmap-c)#inspect http http_url_policy
(config-pmap-c)#exit
(config-pmap)#exit
8) 应用到接口
(config)#service-policy inside_http_url_policy interface inside
2
保存配置
#write memory
#copy running-config startup-config
清除所有配置
(config)#clear configure all
清除access-list
(config)#clear configure access-list
配置日志
Log buffer (config)#logging enable
(config)#logging buffered informational (级别)
清除 (config)#clear logging buffer
ASDM日志 (config)#logging enable
(config)#logging asdm informational
清除 (config)#clear longing asdm
配置日志服务器
(config)#logging enable
(config)#logging trap information
(config)#logging host inside 192.168.1.1
ASA基本威胁检测
(config)#threat-detection basic-threat
禁止IP分片通过
(config)#fragment chain 1
启用IDS功能
(config)#ip audit name name (info|attack) {action [alarm] [drop] [reset] }
Alarm对info和attack消息进行警告,信息会出现在syslog服务器上
Reset 丢弃数据包并关闭连接
Action定义策略采取的动作
如:(config)#ip audit name inside_ids_info info action alarm
(config)#ip audit name inside_ids_attack attack action alarm
(config)#ip audit interface inside inside_ids_info
(config)#ip audit interface inside inside_ids_info
关闭ID为2000的签名
(config)#ip audit signature 2000 disable
启用ID为2000的签名
(config)#no ip audit signature 2000 disable
3
IPSec VPN
ISAKMP/IKE阶段1的配置命令
建立ISAKMP管理连接策略
Router(config))#crypto isakmp policy {1-10000}
指定管理连接建立的最后两个数据报文采用何种加密方式
Router (config-isakmp)#crypto {des | 3des | aea}
HASH命令指定验证过程采用HMAC的功能
Router (config-isakmp)#hash {sha|md5}
指定设备身份验证的方式
Router (config-isakmp)#euthentication {pre-share | rea-encr | rsa-sig}
指定DH密匙组,默认使用DH1
Router (config-isakmp)#group {1 | 2 | 5}
指定管理连接的生存周期,默认为86400s(24小时)
(Router config-isakmp)#lifetime seconds
查看上述配置
#show crypto isakmp policy
配置预共享密钥
Router(config))#crypto isakmp key {0 | 6} keystring address peer-address {subnet_mask}
➢ 0表示密钥为明文,6表示密钥被加密
➢ Keystring表示密钥的具体内容
➢ Peer-address表示对端与之共享密钥的对等体设备地址
➢ Subnet_mask在这里为可选命令,如没有指定,默认使用255.255.255.255作为掩码
显示密钥是明文还是密文
#Show crypto isakmp key
加密预共享密钥
Router(config))#key config-key password-encrypt
New key: (最少为8为字母)
Confirm key:
Router(config))#password encryption aes
使用show run可以看到加密后的效果
ISAKMP/IKE阶段2的配置命令
(1) 配置crypto ACL (通常两端对端设备上的crypto ACL互为镜像)
Router(config))#access-list access-list-number { deny | permit } protocol source source-wildcard
destination destination-wildcard
(2) 配置阶段2的传输集
Router(config))#crypto ipsec transform-set transform_set_name transform1[transform2
[transform3]
Router (cfg-crypto-tran)#mode { tunnel | transport }
➢ Transform_set_name为传输集的名称,该名称具有唯一性,不能与其他任何传输集相同
➢ Transform1 :传输集选项,具体参数如下图所示
传输集类型
传输参数
AH
ah-md5-hmac
ah-sha-hmac
ESP验证
esp-md5-hmac
esp-sha-hmac
ESP加密
esp-null
esp-des
esp-3des
esp-aes 128
esp-aes 192
esp-aes 256
4
查看路由器上的传输集,show crypto ipsec transform-set
清除连接的生存周期
Clear crypto sa 或 clear crypto ipsec sa
(3) 配置crypto map
Router(config))# crypto map map_name seq_num ipsec-isakmp
Map-name:crypto map的名称
Seq_num:crypto map的序列号,其范围是1-65535,数值越小,优先级越高
调用crypto ACL的名字或编号
Router(config)-crypto-m)# match address ACL_name_or_num
指定IPsec的对等体设备,即配置的设备应该与谁建立连接
Router(config)-crypto-m)# set peer { hostname | IP_address }
指定传输集的名称,这里最多可以列出6个传输集的名称
Router(config)-crypto-m)# set transform-set transform_set_name1
PFS(perfect forward secrecy)完美转发保密,保证两个阶段中的密钥只能使用一次
启用PFS并指定使用哪个DH密钥组(可选命令)
Router(config)-crypto-m)# set pfs [ group1 | group2 | group5 ]
指定SA的生存周期,默认数据连接的生存周期为3600s或4608000KB
Router(config)-crypto-m)#set security-association lifetime {seconds seconds | kilobytes kilobytes}
设定空闲超时计时器,范围60~86400s (默认关闭)
Router(config)-crypto-m)# set security-association idle-time seconds
查看管理连接所处的状态
show crypto isakmp policy
show crypto isakmp sa
show crypto ipsec transform-set
show crypto ipsec security-association lifetime
show crypto ipsec sa
show crypto map
5
在ASA上配置实现IPSec VPN
分公司网关ASA1的配置
基本配置
ASA1(config)#route outside 0 0 100.0.0.2
ASA1(config)#nat-control
ASA1(config)#nat (inside) 1 0 0
ASA1(config)#global (outside) 1 int
配置NAT豁免
ASA1(config)#access-list nonat extended permit ip 172.16.10.0 255.255.255.0 10.10.33.0
255.255.255.0
ASA1(config)#nat (inside) 0 access-list nonat
启用ISAKMP
ASA1(config)#crypto isakmp enable outside
配置ISAKMP策略
ASA1(config)#crypto isakmp policy 1
ASA1(config-isakmp-policy)#encryption aes
ASA1(config-isakmp-policy)#hash sha
ASA1(config-isakmp-policy)#authentication pre-share
ASA1(config-isakmp-policy)#group 1
配置预共享密钥
ASA1(config)#isakmp key benet address 200.0.0.1
ASA从7.0版本开始一般使用隧道组来配置
ASA1(config)#tunnel-group 200.0.0.1 type ipsec-l2l
ASA1(config)#tunnel-group 200.0.0.1 ipsec-attributes
ASA1(config-ipsec)#pre-shared-key benet
配置crypto ACL
ASA1(config)#access-list yfvpn extended permit ip 172.16.10.0 255.255.255.0 10.10.33.0
255.255.255.0
配置数据连接的传输集
ASA1(config)#crypto ipsec transform-set benet-set esp-aes esp-sha-hmac
配置crypto map并应用到outside接口上
ASA1(config)#crypto map benet-map 1 match address yfvpn
ASA1(config)#crypto map benet-map 1 set peer 200.0.0.1
6
ASA1(config)#crypto map benet-map 1 set transform-set benet-set
ASA1(config)#crypto map benet-map interface outside
接口安全级别对于IPSec流量的影响
流量无法通过具有相同安全级别的两个不同的接口
流量无法从同一接口进入后再流出
ASA(config)#same-security-traffic permit {intra-interface | inter-interface}
路由器实现NAT-T
Router(config)#ip nat inside source list access-list-number interface f0/1 overload
Router(config)#ip nat inside source static udp local-ip 500 interface f0/1 500
Router(config)#ip nat inside source static udp local-ip 4500 interface f0/1 4500
管理连接的状态
状态
MM_NO_STATE
MM_SA_SETUP
MM_KEY_EXCH
MM_KEY_AUTH
QM_IDLE
debug crypto isakmp
初始状态
阶段1策略协商
生成随机数(用于验证)
身份验证
阶段1连接建立
阶段2参数协商
创建数据连接的SA
debug crypto ipsec
协商阶段2的传输集
匹配crypto ACL
SA建立
协商完成
show crypto isakmp sa
7
说明
ISAKMP SA建立的初始状态;管理连接建立失败也会处于该状态。
对等体之间ISAKMP策略协商成功后处于该状态。
对等体通过DH算法成功建立共享密钥,此时还没有进行设备验证。
对等体成功进行设备验证,之后会过渡到QM_IDLE状态。
管理连接成功建立,即将过渡到阶段2的数据连接建立过程。
路由器搭建Easy VPN服务器
定义AAA
R1(config)#aaa new-model
R1(config)#aaa authentication login vpn_authen local
R1(config)#aaa authorization network vpn_author local
R1(config)#username cisco password cisco
定义阶段1的SA参数
R1(config)#crypto isakmp policy 10
R1(config-isakmp)#encryption aes 128
R1(config-isakmp)#hash sha
R1(config-isakmp)#authentication pre-share
R1(config-isakmp)#group 2
R1(config-isakmp)#exit
定义IP地址池
R1(config)#ip local pool vpn_pool 192.168.1.1 192.168.1.200
定义ACL用于分离隧道
R1(config)#access-list 101 permit ip 10.10.1.0 0.0.0.255 any
定义Easy VPN组及参数
R1(config)#crypto isakmp client configuration group vpn_group
R1(config-isakmp-group)#key groupkey
R1(config-isakmp-group)#pool vpn_pool
R1(config-isakmp-group)#acl 101
R1(config-isakmp-group)#exit
定义传输集
R1(config)#crypto ipsec transform-set vpn_transform esp-aes esp-sha-hmac
8
定义动态的Crypto Map条目
R1(config)#crypto dynamic-map vpn_dymap 10
R1(config-crypto-map)#set transform-set vpn_transform
定义静态的Crypto Map条目和XAUTH
R1(config)#crypto map mymap client authentication list vpn_authen
R1(config)#crypto map mymap isakmp authorization list vpn_author
R1(config)#crypto map mymap client configuration address respond
R1(config)#crypto map mymap 1000 ipsec-isakmp dynamic vpn_dymap
将Crypto Map应用到接口
R1(config)#int S1/0
R1(config-if)#crypto map mymap
路由器与硬件客户端之间的配置
Easy VPN硬件客户端R2的配置
建立Easy VPN远端配置
R2(config)#crypto ipsec client ezvpn myeasyvpn
R2(config-crypto-ezvpn)#connect auto
R2(config-crypto-ezvpn)#group vpn_group key groupkey
R2(config-crypto-ezvpn)#mode network-extension
R2(config-crypto-ezvpn)#peer 200.1.1.1
R2(config-crypto-ezvpn)#username cisco password cisco
R2(config)#int f0/0
R2(config-if)#crypto ipsec client ezvpn myeasyvpn inside
R2(config-if)#int s1/1
R2(config-if)#crypto ipsec client ezvpn myeasyvpn outside
R2(config-if)#End
9
crypto isakmp client ezvpn xauth
配置服务器端允许硬件客户端存储XAUTH认证信息
R1(config)#crypto isakmp client configuration group vpn_group
R1(config-isakmp-group)#save-password
配置路由器R2对VPN流量不做NAT转换
R2(config)#no access-list 1 permit 10.20.1.0 0.0.0.255
R2(config)#no ip nat inside source list 1 interface Serial1/1 overload
R2(config)# access-list 110 deny ip 10.20.1.0 0.0.0.255 10.10.1.0 0.0.0.255
R2(config)# access-list 110 permit ip any any
R2(config)#ip nat inside source list 110 interface Serial1/1 overload
使用命令R2#sh crypto ipsec client ezvpn检验Easy VPN的配置
Easy VPN基于ASA的配置
定义XAUTH(用户)验证
asa802(config)#username cisco password cisco
定义阶段1的SA参数
asa802(config)#crypto isakmp enable outside
asa802(config)#crypto isakmp policy 10
asa802(config-isakmp-policy)#encryption aes
asa802(config-isakmp-policy)#hash sha
asa802(config-isakmp-policy)#authentication pre-share
asa802(config-isakmp-policy)#group 2
asa802(config-isakmp-policy)#exit
定义IP地址池
asa802(config)#ip local pool vpn_pool 192.168.1.1-192.168.1.200
定义ACL用于分离隧道
asa802(config)# access-list split_tunnel permit ip 10.10.1.0 255.255.255.0 any
10
定义组策略
asa802(config)# group-policy vpn_group_policy internal
asa802(config)# group-policy vpn_group_policy attributes
asa802(config-group-policy)# split-tunnel-policy tunnelspecified
asa802(config-group-policy)# split-tunnel-network-list value split_tunnel
asa802(config-group-policy)# exit
建立隧道组
asa802(config)# tunnel-group vpn_group type ipsec-ra
asa802(config)# tunnel-group vpn_group general-attributes
asa802(config-tunnel-general)# address-pool vpn_pool
asa802(config-tunnel-general)# default-group-policy vpn_group_policy
asa802(config-tunnel-general)# exit
asa802(config)# tunnel-group vpn_group ipsec-attributes
asa802(config-tunnel-ipsec)# pre-shared-key groupkey
asa802(config-tunnel-ipsec)# exit
定义传输集
asa802(config)#crypto ipsec transform-set vpn_transform esp-aes esp-sha-hmac
定义动态的Crypto Map条目
asa802(config)#crypto dynamic-map vpn_dymap 10 set transform-set vpn_transform
定义静态的Crypto Map条目
asa802(config)#crypto map mymap 1000 ipsec-isakmp dynamic vpn_dymap
将Crypto Map应用到接口
asa802(config)# crypto map mymap interface outside
SSL VPN基于ASA的配置
11
定义XAUTH(用户)验证
asa802(config)#username cisco password cisco
在outside口启用WebVPN和SSLVPN
asa802(config)#webvpn
asa802(config-webvpn)#enable outside
asa802(config-webvpn)#svc image disk0:/
asa802(config-webvpn)#svc enable
asa802(config-webvpn)#exit
定义IP地址池
asa802(config)#ip local pool vpn_pool 192.168.1.1-192.168.1.200
定义ACL用于分离隧道
asa802(config)# access-list split_tunnel permit ip 10.10.1.0 255.255.255.0 any
定义组策略
asa802(config)# group-policy vpn_group_policy internal
asa802(config)# group-policy vpn_group_policy attributes
asa802(config-group-policy)#vpn-tunnel-protocol webvpn svc
asa802(config-group-policy)# split-tunnel-policy tunnelspecified
asa802(config-group-policy)# split-tunnel-network-list value split_tunnel
asa802(config-group-policy)#webvpn
asa802(config-group-webvpn)#svc ask enable
asa802(config-group-webvpn)#exit
asa802(config-group-policy)# exit
建立隧道组
asa802(config)# tunnel-group vpn_group type webvpn
asa802(config)# tunnel-group vpn_group general-attributes
asa802(config-tunnel-general)# address-pool vpn_pool
asa802(config-tunnel-general)# default-group-policy vpn_group_policy
asa802(config-tunnel-general)# exit
asa802(config)# tunnel-group vpn_group webvpn-attributes
asa802(config-tunnel-webvpn)#group-alias groups enable
asa802(config-tunnel-webvpn)#exit
asa802(config)#webvpn
asa802(config-webvpn)#tunnel-group-list enable
asa802(config-webvpn)#exit
12
SSL VPN基于IOS路由器的配置
安装SVC软件
R1(config)#webvpn install svc flash:/
定义AAA,创建SSL VPN用户
R1(config)#aaa new-model
R1(config)#aaa authentication login vpn_authen local
R1(config)#username cisco password cisco
启用WebVPN,产生自签名证书
R1(config)#webvpn gateway vpn_gateway
R1(config-webvpn-gateway)#ip address 200.1.1.1 port 443
R1(config-webvpn-gateway)#inservice
R1(config-webvpn-gateway)#exit
定义IP地址池
R1(config)#ip local pool vpn_pool 192.168.1.1 192.168.1.200
R1(config)#int lo0
R1(config-if)#ip address 192.168.1.254 255.255.255.0
R1(config-if)#exit
建立WebVPN环境
R1(config)#webvpn context vpn_context
R1(config-webvpn-context)#gateway vpn_gateway domain group1
R1(config-webvpn-context)#aaa authentication list vpn_authen
R1(config-webvpn-context)#inservice
R1(config-webvpn-context)#exit
定义组策略
R1(config)#webvpn context vpn_context
R1(config-webvpn-context)#policy group vpn_group_policy
R1(config-webvpn-group)#functions svc-enabled
R1(config-webvpn-group)#svc address-pool vpn_pool
13
R1(config-webvpn-group)#svc split include 10.10.1.0 255.255.255.0
R1(config-webvpn-group)#exit
R1(config-webvpn-context)#default-group-policy vpn_group_policy
R1(config-webvpn-context)#exit
SSL VPN客户端的配置
输入 200.1.1.1/group1
自动安装客户端软件
安装证书
测试
通过show webvpn session context all查看会话信息
搭建RADIUS服务器
安装Cisco ACS软件
设置ACS管理员账号
配置RADIUS服务器,添加AAA客户端SW2
添加用户
配置用户组RADIUS属性
在交换机上配置802.1x认证
配置AAA
SW2(config)#aaa new-model
SW2(config)#radius-server host 10.0.0.203 auth-port 1812 acct-port 1813 key cisco
认证、统计端口和共享密钥必须与服务器配置相同
配置802.1x认证
SW2(config)#aaa authentication dot1x default group radius
配置802.1x授权
SW2(config)#radius-server vsa send authentication
SW2(config)# aaa authorization network default group radius
14
服务器要动态分配VLAN需要使用VSA属性
启用802.1x
SW2(config)# dot1x system-auth-control
SW2(config)#interface fastethernet 0/2
SW2(config-if)#switchport mode access
SW2(config-if)#dot1x port-control auto
命令dot1x port-control有3个参数
force-authorized:端口始终处于授权状态(端口默认状态)
force-unauthorized:端口始终处于非授权状态
auto:根据认证结果决定端口的授权或非授权状态
查看802.1x的相关配置
SW2#show dot1x all
Sysauthcontrol Enabled
Dot1x Protocol Version 2
Critical Recovery Delay 100
Critical EAPOL Disabled
Dot1x Info for FastEthernet0/2
-----------------------------------
PAE = AUTHENTICATOR
PortControl = AUTO
ControlDirection = Both
HostMode = SINGLE_HOST
ReAuthentication = Disabled
QuietPeriod = 60
ServerTimeout = 30
…省略…
802.1x常见故障排查
一般处理流程
判断是单点故障,还是全局故障
个别故障,一般情况下认证服务器应该工作正常
– 检查用户名和密码
– 检查交换机端口配置等
全局故障,一般情况是认证服务器出现故障
– 检查服务器网络连通是否正常
– 检查服务器是否死机
– 检查服务器配置是否有变动
– 检查DHCP地址池是否用完
– 检查服务器认证端口是否访问正常
根据不同的现象逐步排查
15
ASA穿越代理的配置
定义触发认证的流量
ASA(config)# access-list http extended permit tcp any 192.168.100.0 255.255.255.0 eq 80
配置AAA服务器
ASA(config)# aaa-server server_group protocol { RADIUS | TACACS+ }
配置服务器使用的协议
ASA(config)# aaa-server server_group (interface_name) host server_ipaddress
ASA(config-aaa-server-host)# key keyword
配置服务器地址
ASA(config-aaa-server-host)# authentication-port port
ASA(config-aaa-server-host)# accounting-port port
配置共享密钥、
AAA认证配置
ASA(config)# aaa authentication match acl_name interface_name server_group
AAA认证配置实例
ASA(config)# aaa authentication match http inside acs
AAA授权配置
ASA(config)# aaa authorization match acl_name interface_name server_group
配置AAA认证超时时间
ASA(config)# timeout uauth 0:05:00 absolute
绝对超时时间
ASA(config)# timeout uauth 0:05:00 inactivity
空闲超时时间
本地ACL在端口应用配置
ASA(config)#access-group acl_name in interface inside [per-user-override]
配置per-user-override参数
只有动态下发的ACL有效
不配置per-user-override参数
本地ACL和动态下发的ACL同时有效
16


发布评论