

# 使用网关路由表控制进入 VPC 的流量
<a name="associate-route-table-gateway"></a>

要使用网关路由表控制进入 VPC 的流量，您可以将互联网网关或虚拟私有网关与路由表关联或取消关联。有关更多信息，请参阅 [网关路由表](gateway-route-tables.md)。

**使用控制台将网关与路由表关联或取消关联**

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

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

1. 从 **Edge associations**（边缘关联）选项卡，选择 **Edit edge associations**（编辑边缘关联）。

1. 选中或取消选中网关的复选框。

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

**使用 AWS CLI 将网关与路由表关联**  
使用 [associate-route-table](https://docs.aws.amazon.com/cli/latest/reference/ec2/associate-route-table.html) 命令。以下示例将指定的路由表与指定的互联网网关关联。

```
aws ec2 associate-route-table
    --route-table-id rtb-01234567890123456 \
    --gateway-id igw-11aa22bb33cc44dd1
```

**使用 AWS CLI 取消网关与路由表的关联**  
使用 [disassociate-route-table](https://docs.aws.amazon.com/cli/latest/reference/ec2/disassociate-route-table.html) 命令。指定路由表与网关的关联的 ID。

```
aws ec2 disassociate-route-table \
    --association-id rtbassoc-0abcdef1234567890
```