> For the complete documentation index, see [llms.txt](https://docs.console.zenlayer.com/welcome/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.console.zenlayer.com/welcome/cn/global-bgp/establish-bgp-session/configure-bgp-on-your-router.md).

# 在您的路由器上配置 BGP

在 zenConsole 上建立 BGP 会话后，为了启用 BGP 互联，您需要在自己的路由器上配置 BGP。

{% hint style="info" %} <mark style="color:blue;">**注意**</mark>

* <mark style="color:blue;">确保您熟悉 BGP 配置，并在必要时咨询专业人士。</mark>
* <mark style="color:blue;">BGP 配置可能因路由器型号和路由器操作系统（IOS）版本的不同而有所差异，如有需要，请参考路由器手册。</mark>
  {% endhint %}

## 操作步骤

1. **进入三层网络配置模式**\
   登录您的路由器并进入配置模式。这通常通过命令行接口（CLI）使用 SSH、Telnet 或控制台连接完成。\\
2. **进入 BGP 配置模式**\
   进入三层网络的配置模式后，通过输入以下命令进入 BGP 配置模式：

   ```typescript
   router bgp <your-as-number>
   ```

   将 `<your-as-number>` 替换为您的自治系统编号（ASN）。\\
3. **配置 BGP 邻居关系**

   配置 BGP 邻居关系以建立与其他路由器的连接。使用以下命令：

   ```typescript
   neighbor <neighbor-ip-address> remote-as <neighbor-as-number>
   ```

   将 `<neighbor-ip-address>` 替换为您的 BGP 邻居的内网 IP 地址，即 BGP 会话详情中的对等 IP；将 `<neighbor-as-number>` 替换为对等 ASN（65534）。\\
4. **配置 BGP 路由策略**
   * 创建路由策略：`route-map <route-map-name> permit 10`
   * 匹配路由：`match ip address 1` \\
5. **激活 BGP 邻居关系**\
   配置完 BGP 邻居关系和路由策略后，使用以下命令激活 BGP 邻居关系：

   ```typescript
   neighbor <neighbor-ip-address> activate
   ```

   将 `<neighbor-ip-address>` 替换为您的 BGP 邻居的内网 IP 地址，即 BGP 会话详情中的对等 IP。

示例

```python
pythonCopy coderouter bgp 65000
neighbor 10.0.0.1 remote-as 65534
route-map to-as65534 permit 10
  match ip address 1
neighbor 10.0.0.1 activate
```

6. **保存配置**\
   配置完 BGP 后，确保将配置更改保存到三层网络的运行配置中。使用以下命令：

   ```arduino
   arduinoCopy codewrite memory
   ```

   或

   ```arduino
   arduinoCopy codecopy running-config startup-config
   ```

   这样可以确保配置更改在重启后仍然保留。\\
7. **验证配置**\
   使用各种 show 命令（例如 `show ip bgp`、`show ip bgp neighbor`）验证 BGP 是否已正确配置并正常运行。
