

# 使用前缀列表优化 AWS 基础设施管理
<a name="managed-prefix-lists-referencing"></a>

您可以在以下AWS资源中引用前缀列表。

**Topics**
+ [VPC 安全组](#prefix-list-vpc-security-group)
+ [子网路由表](#prefix-list-subnet-route-table)
+ [中转网关路由表](#prefix-list-tgw-route-table)
+ [AWS Network Firewall 规则组](#prefix-list-nfw-rule-groups)
+ [Amazon Managed Grafana 网络访问控制](#prefix-list-grafana)
+ [AWS Outposts 机架本地网关](#prefix-list-outpost-racks-lgw)

## VPC 安全组
<a name="prefix-list-vpc-security-group"></a>

您可以将前缀列表指定为入站规则的源或出站规则的目的地。有关更多信息，请参阅 [安全组](vpc-security-groups.md)。

**重要**  
您无法修改现有规则来使用前缀列表。而须创建新规则才能使用前缀列表。

**使用控制台在安全组规则中引用前缀列表**

1. 通过以下网址打开 Amazon VPC 控制台：[https://console.aws.amazon.com/vpc/](https://console.aws.amazon.com/vpc/)。

1. 在导航窗格中，选择 **Security Groups**。

1. 选择需要更新的安全组。

1. 依次选择 **Actions (操作)**、**Edit inbound rules (编辑入站规则)**，或 **Actions (操作)**、**Edit outbound rules (编辑出站规则)**。

1. 选择 **Add rule**。对于**类型**，选择流量类型。对于**源**（入站规则）或**目的地**（出站规则），选择“自定义”****。然后，在“前缀列表”****下的下一个字段中，选择前缀列表的 ID。

1. 选择 **Save rules (保存规则)**。

**使用 AWS CLI 在安全组规则中引用前缀列表**  
使用 [authorize-security-group-ingress](https://docs.aws.amazon.com/cli/latest/reference/ec2/authorize-security-group-ingress.html) 和 [authorize-security-group-egress](https://docs.aws.amazon.com/cli/latest/reference/ec2/authorize-security-group-egress.html) 命令。对于 `--ip-permissions` 参数，请使用 `PrefixListIds` 指定前缀列表的 ID。

## 子网路由表
<a name="prefix-list-subnet-route-table"></a>

您可以将前缀列表指定为路由表条目的目的地。不能在网关路由表中引用前缀列表。有关路由表的更多信息，请参见[配置路由表](VPC_Route_Tables.md)。

**使用控制台在路由表中引用前缀列表**

1. 通过以下网址打开 Amazon VPC 控制台：[https://console.aws.amazon.com/vpc/](https://console.aws.amazon.com/vpc/)。

1. 在导航窗格中，选择**路由表**，然后选择路由表。

1. 依次选择 **Actions (操作)**、**Edit routes (编辑路由)**。

1. 要添加路由，请选择**添加路由**。

1. 对于**目的地**，输入前缀列表的 ID。

1. 对于**目标**，请选择一个目标。

1. 选择**保存更改**。

**使用 AWS CLI 在路由表中引用前缀列表**  
使用 [create-route](https://docs.aws.amazon.com/cli/latest/reference/ec2/create-route.html) (AWS CLI) 命令。使用 `--destination-prefix-list-id` 参数指定前缀列表的 ID。

## 中转网关路由表
<a name="prefix-list-tgw-route-table"></a>

您可以将前缀列表指定为路由目的地。有关更多信息，请参阅 *Amazon VPC 中转网关* 中的[前缀列表参考](https://docs.aws.amazon.com/vpc/latest/tgw/create-prefix-list-reference.html)。

## AWS Network Firewall 规则组
<a name="prefix-list-nfw-rule-groups"></a>

AWS Network Firewall 规则组是检查和处理网络流量的一组可重复使用的标准。如果您在 AWS Network Firewall 中创建与 Suricata 兼容的有状态规则组，则可以引用规则组中的前缀列表。有关更多信息，请参阅 *AWS Network Firewall 开发人员指南*中的[引用 Amazon VPC 前缀列表](https://docs.aws.amazon.com/network-firewall/latest/developerguide/rule-groups-ip-set-references.html#rule-groups-referencing-prefix-lists)和[创建有状态规则组](https://docs.aws.amazon.com/network-firewall/latest/developerguide/rule-group-stateful-creating.html)。

## Amazon Managed Grafana 网络访问控制
<a name="prefix-list-grafana"></a>

对于向 Amazon Managed Grafana 工作区发出的请求，您可以指定一个或多个前缀列表作为入站规则。有关 Grafana 工作区网络访问控制的更多信息（包括如何引用前缀列表），请参阅《Amazon Managed Grafana 用户指南**》中的[管理网络访问](https://docs.aws.amazon.com/grafana/latest/userguide/AMG-configure-nac.html)。

## AWS Outposts 机架本地网关
<a name="prefix-list-outpost-racks-lgw"></a>

每个 AWS Outposts 机架都提供一个本地网关，允许您将 Outpost 资源与本地网络连接起来。您可以将经常使用的 CIDR 分组到前缀列表中，并引用该列表作为本地网关路由表中的路由目标。有关更多信息，请参阅《AWS Outposts 机架用户指南》**中的[管理本地网关路由表路由](https://docs.aws.amazon.com/outposts/latest/userguide/routing.html#manage-lgw-routes)。