简介
本文档介绍如何配置自适应安全设备(ASA),使用设置从VPN连接中排除发往Microsoft Office 365(包括Microsoft Teams)和Cisco Webex的流量。它为支持它的AnyConnect客户端包含网络地址排除和动态(完全限定域名(FQDN))排除。
Split Tunneling
需要将ASA配置为“排除”要从隧道中排除的IPv4和IPv6目标的指定列表。遗憾的是,地址列表是动态的,可能会更改。请参阅Python脚本的配置部分和指向可用于检索列表和生成示例配置的联机python读取 — 评估 — 打印循环(REPL)的链接。
动态分割隧道
除拆分排除网络地址列表外,AnyConnect 4.6中还为Windows和Mac添加了动态拆分隧道。动态拆分隧道使用FQDN来确定连接是否应通过隧道。Python脚本还确定要添加到自定义AnyConnect属性的终端的FQDN。
配置
在Python 3 REPL中运行此脚本,或在公共REPL环境(如https://repl.it/@ministryofjay/AnyConnectO365DynamicExclude)中运行它。
import urllib.request
import uuid
import json
import re
def print_acl_lines(acl_name, ips, section_comment):
slash_to_mask = (
"0.0.0.0",
"128.0.0.0",
"192.0.0.0",
"224.0.0.0",
"240.0.0.0",
"248.0.0.0",
"252.0.0.0",
"254.0.0.0",
"255.0.0.0",
"255.128.0.0",
"255.192.0.0",
"255.224.0.0",
"255.240.0.0",
"255.248.0.0",
"255.252.0.0",
"255.254.0.0",
"255.255.0.0",
"255.255.128.0",
"255.255.192.0",
"255.255.224.0",
"255.255.240.0",
"255.255.248.0",
"255.255.252.0",
"255.255.254.0",
"255.255.255.0",
"255.255.255.128",
"255.255.255.192",
"255.255.255.224",
"255.255.255.240",
"255.255.255.248",
"255.255.255.252",
"255.255.255.254",
"255.255.255.255",
)
print(
"access-list {acl_name} remark {comment}".format(
acl_name=acl_name, comment=section_comment
)
)
for ip in sorted(ips):
if ":" in ip:
# IPv6 address
print(
"access-list {acl_name} extended permit ip {ip} any6".format(
acl_name=acl_name, ip=ip
)
)
else:
# IPv4 address. Convert to a mask
addr, slash = ip.split("/")
slash_mask = slash_to_mask[int(slash)]
print(
"access-list {acl_name} extended permit ip {addr} {mask} any4".format(
acl_name=acl_name, addr=addr, mask=slash_mask
)
)
# Fetch the current endpoints for O365
http_res = urllib.request.urlopen(
url="https://endpoints.office.com/endpoints/worldwide?clientrequestid={}".format(
uuid.uuid4()
)
)
res = json.loads(http_res.read())
o365_ips = set()
o365_fqdns = set()
for service in res:
if service["category"] == "Optimize":
for ip in service.get("ips", []):
o365_ips.add(ip)
for fqdn in service.get("urls", []):
o365_fqdns.add(fqdn)
# Generate an acl for split excluding For instance
print("##### Step 1: Create an access-list to include the split-exclude networks\n")
acl_name = "ExcludeSass"
# O365 networks
print_acl_lines(
acl_name=acl_name,
ips=o365_ips,
section_comment="v4 and v6 networks for Microsoft Office 365",
)
# Microsoft Teams
# https://docs.microsoft.com/en-us/office365/enterprise/office-365-vpn-implement-split-tunnel#configuring-and-securing-teams-media-traffic
print_acl_lines(
acl_name=acl_name,
ips=["13.107.60.1/32"],
section_comment="v4 address for Microsoft Teams"
)
# Cisco Webex - Per https://help.webex.com/en-us/WBX000028782/Network-Requirements-for-Webex-Teams-Services
webex_ips = [
"64.68.96.0/19",
"66.114.160.0/20",
"66.163.32.0/19",
"170.133.128.0/18",
"173.39.224.0/19",
"173.243.0.0/20",
"207.182.160.0/19",
"209.197.192.0/19",
"216.151.128.0/19",
"114.29.192.0/19",
"210.4.192.0/20",
"69.26.176.0/20",
"62.109.192.0/18",
"69.26.160.0/19",
]
print_acl_lines(
acl_name=acl_name,
ips=webex_ips,
section_comment="IPv4 and IPv6 destinations for Cisco Webex",
)
# Edited. April 1st 2020
# Per advice from Microsoft they do NOT advise using dynamic split tunneling for their properties related to Office 365
#
print(
"\n\n##### Step 2: Create an Anyconnect custom attribute for dynamic split excludes\n"
)
print("SKIP. Per Microsoft as of April 2020 they advise not to dynamically split fqdn related to Office365")
#print(
# """
#webvpn
# anyconnect-custom-attr dynamic-split-exclude-domains description dynamic-split-exclude-domains
#
#anyconnect-custom-data dynamic-split-exclude-domains saas {}
#""".format(
# ",".join([re.sub(r"^\*\.", "", f) for f in o365_fqdns])
# )
#)
#
print("\n##### Step 3: Configure the split exclude in the group-policy\n")
print(
"""
group-policy GP1 attributes
split-tunnel-policy excludespecified
ipv6-split-tunnel-policy excludespecified
split-tunnel-network-list value {acl_name}
""".format(
acl_name=acl_name
)
)
注意:Microsoft建议从VPN连接范围中排除发往关键Office 365服务的流量,方法是使用已发布的IPv4和IPv6地址范围配置分割隧道。为了获得最佳性能和最有效的VPN容量使用,应直接在VPN隧道外路由到与Office 365 Exchange Online、SharePoint Online和Microsoft Teams(在Microsoft文档中称为“优化”类别)关联的这些专用IP地址范围的流量。有关此建议的更多详细信息,请参阅使用VPN拆分隧道为远程用户优化Office 365连接。
注意:截至2020年4月初,Microsoft Teams依赖于必须从隧道中排除IP范围13.107.60.1/32。有关详细信息,请参阅配置和保护Teams媒体流量。
验证
连接用户后,他们应看到“非安全路由”(Non-Secured Routes),其中填入了ACL中提供的地址和“动态隧道排除”(Dynamic Tunnel Exclusion)列表。

