mirror of
https://github.com/LCTT/TranslateProject.git
synced 2024-12-26 21:30:55 +08:00
translated
This commit is contained in:
parent
7174ff7959
commit
be2a651d55
@ -1,198 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (How to configure your router using VTY shell)
|
||||
[#]: via: (https://opensource.com/article/20/5/vty-shell)
|
||||
[#]: author: (M Umer https://opensource.com/users/noisybotnet)
|
||||
|
||||
How to configure your router using VTY shell
|
||||
======
|
||||
Free range routing gives you options for implementing multiple
|
||||
protocols. This guide will get you started.
|
||||
![Multi-colored and directional network computer cables][1]
|
||||
|
||||
Recently, I wrote an article explaining how we can implement Open Shortest Path First (OSPF) using the [Quagga][2] routing suite. There are multiple software suites that can be used instead of Quagga to implement different routing protocols. One such option is free range routing (FRR).
|
||||
|
||||
### FRR
|
||||
|
||||
[FRR][3] is a routing software suite, which has been derived from Quagga and is distributed under GNU GPL2 license. Like Quagga, it provides implementations of all major routing protocols such as OSPF, Routing Information Protocol (RIP), Border Gateway Protocol (BGP), and Intermediate system-to-intermediate system (IS-IS) for Unix-like platforms.
|
||||
|
||||
Several companies, such as Big Switch Networks, Cumulus, Open Source Routing, and 6wind, who were behind the development of Quagga, created FRR to improve on Quagga's well-established foundations.
|
||||
|
||||
#### Architecture
|
||||
|
||||
FRR is a suite of daemons that work together to build the routing table. Each major protocol is implemented in its own daemon, and these daemons talk to the core and protocol-independent daemon Zebra, which provides kernel routing table updates, interface lookups, and redistribution of routes between different routing protocols. Each protocol-specific daemon is responsible for running the relevant protocol and building the routing table based on the information exchanged.
|
||||
|
||||
![FRR architecture][4]
|
||||
|
||||
### VTY shell
|
||||
|
||||
[VTYSH][5] is an integrated shell for the FRR routing engine. It amalgamates all the CLI commands defined in each of the daemons and presents them to the user in a single shell. It provides a Cisco-like modal CLI, and many of the commands are similar to Cisco IOS commands. There are different modes to the CLI, and certain commands are only available within a specific mode.
|
||||
|
||||
### Setup
|
||||
|
||||
In this tutorial, we'll be implementing the routing information protocol (RIP) to configure dynamic routing using FRR. We can do this in two ways—either by editing the protocol daemon configuration file in an editor or by using the VTY shell. We'll be using the VTY shell in this example. Our setup includes two CentOS 7.7 hosts, named Alpha and Beta. Both hosts have two network interfaces and share access to the 192.168.122.0/24 network. We'll be advertising routes for 10.12.11.0/24 and 10.10.10.0/24 networks.
|
||||
|
||||
**For Host Alpha:**
|
||||
|
||||
* eth0 IP: 192.168.122.100/24
|
||||
* Gateway: 192.168.122.1
|
||||
* eth1 IP: 10.10.10.12/24
|
||||
|
||||
|
||||
|
||||
**For Host Beta:**
|
||||
|
||||
* eth0 IP: 192.168.122.50/24
|
||||
* Gateway: 192.168.122.1
|
||||
* eth1 IP: 10.12.11.12/24
|
||||
|
||||
|
||||
|
||||
#### Installation of package
|
||||
|
||||
First, we need to install the FRR package on both hosts; this can be done by following the instructions in the [official FRR documentation][6].
|
||||
|
||||
#### Enable IP forwarding
|
||||
|
||||
For routing, we need to enable IP forwarding on both hosts since that will performed by the Linux kernel.
|
||||
|
||||
|
||||
```
|
||||
sysctl -w net.ipv4.conf.all.forwarding = 1
|
||||
|
||||
sysctl -w net.ipv6.conf.all.forwarding = 1
|
||||
sysctl -p
|
||||
```
|
||||
|
||||
#### Enabling the RIPD daemon
|
||||
|
||||
Once installed, all the configuration files will be stored in the **/etc/frr** directory. The daemons must be explicitly enabled by editing the **/etc/frr/daemons** file. This file determines which daemons are activated when the FRR service is started. To enable a particular daemon, simply change the corresponding "no" to "yes." A subsequent service restart should start the daemon.
|
||||
|
||||
![FRR daemon restart][7]
|
||||
|
||||
#### Firewall configuration
|
||||
|
||||
Since RIP protocol uses UDP as its transport protocol and is assigned port 520, we need to allow this port in `firewalld` configuration.
|
||||
|
||||
|
||||
```
|
||||
firewall-cmd --add-port=520/udp –permanent
|
||||
|
||||
firewalld-cmd -reload
|
||||
```
|
||||
|
||||
We can now start the FRR service using:
|
||||
|
||||
|
||||
```
|
||||
`systemctl start frr`
|
||||
```
|
||||
|
||||
#### Configuration using VTY
|
||||
|
||||
Now, we need to configure RIP using the VTY shell.
|
||||
|
||||
On Host Alpha:
|
||||
|
||||
|
||||
```
|
||||
[root@alpha ~]# vtysh
|
||||
|
||||
Hello, this is FRRouting (version 7.2RPKI).
|
||||
Copyright 1996-2005 Kunihiro Ishiguro, et al.
|
||||
|
||||
alpha# configure terminal
|
||||
alpha(config)# router rip
|
||||
alpha(config-router)# network 192.168.122.0/24
|
||||
alpha(config-router)# network 10.10.10.0/24
|
||||
alpha(config-router)# route 10.10.10.5/24
|
||||
alpha(config-router)# do write
|
||||
Note: this version of vtysh never writes vtysh.conf
|
||||
Building Configuration...
|
||||
Configuration saved to /etc/frr/ripd.conf
|
||||
Configuration saved to /etc/frr/staticd.conf
|
||||
alpha(config-router)# do write memory
|
||||
Note: this version of vtysh never writes vtysh.conf
|
||||
Building Configuration...
|
||||
Configuration saved to /etc/frr/ripd.conf
|
||||
Configuration saved to /etc/frr/staticd.conf
|
||||
alpha(config-router)# exit
|
||||
```
|
||||
|
||||
Similarly, on Host Beta:
|
||||
|
||||
|
||||
```
|
||||
[root@beta ~]# vtysh
|
||||
|
||||
Hello, this is FRRouting (version 7.2RPKI).
|
||||
Copyright 1996-2005 Kunihiro Ishiguro, et al.
|
||||
|
||||
beta# configure terminal
|
||||
beta(config)# router rip
|
||||
beta(config-router)# network 192.168.122.0/24
|
||||
beta(config-router)# network 10.12.11.0/24
|
||||
beta(config-router)# do write
|
||||
Note: this version of vtysh never writes vtysh.conf
|
||||
Building Configuration...
|
||||
Configuration saved to /etc/frr/zebra.conf
|
||||
Configuration saved to /etc/frr/ripd.conf
|
||||
Configuration saved to /etc/frr/staticd.conf
|
||||
beta(config-router)# do write memory
|
||||
Note: this version of vtysh never writes vtysh.conf
|
||||
Building Configuration...
|
||||
Configuration saved to /etc/frr/zebra.conf
|
||||
Configuration saved to /etc/frr/ripd.conf
|
||||
Configuration saved to /etc/frr/staticd.conf
|
||||
beta(config-router)# exit
|
||||
```
|
||||
|
||||
Once done, check the routes on both hosts as follows:
|
||||
|
||||
|
||||
```
|
||||
[root@alpha ~]# ip route show
|
||||
default via 192.168.122.1 dev eth0 proto static metric 100
|
||||
10.10.10.0/24 dev eth1 proto kernel scope link src 10.10.10.12 metric 101
|
||||
10.12.11.0/24 via 192.168.122.50 dev eth0 proto 189 metric 20
|
||||
192.168.122.0/24 dev eth0 proto kernel scope link src 192.168.122.100 metric 100
|
||||
```
|
||||
|
||||
We can see that the routing table on Alpha contains an entry of 10.12.11.0/24 via 192.168.122.50, which was offered through RIP. Similarly, on Beta, the table contains an entry of network 10.10.10.0/24 via 192.168.122.100.
|
||||
|
||||
|
||||
```
|
||||
[root@beta ~]# ip route show
|
||||
default via 192.168.122.1 dev eth0 proto static metric 100
|
||||
10.10.10.0/24 via 192.168.122.100 dev eth0 proto 189 metric 20
|
||||
10.12.11.0/24 dev eth1 proto kernel scope link src 10.12.11.12 metric 101
|
||||
192.168.122.0/24 dev eth0 proto kernel scope link src 192.168.122.50 metric 100
|
||||
```
|
||||
|
||||
### Conclusion
|
||||
|
||||
As you can see, the setup and configuration are relatively simple. To add complexity, we can add more network interfaces to the router to provide routing for more networks. The configurations can be made by editing the configuration files in an editor, but using VTY shell provides us a frontend to all FRR daemons in a single, combined session.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/20/5/vty-shell
|
||||
|
||||
作者:[M Umer][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/noisybotnet
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/connections_wires_sysadmin_cable.png?itok=d5WqHmnJ (Multi-colored and directional network computer cables)
|
||||
[2]: https://opensource.com/article/20/4/quagga-linux
|
||||
[3]: https://en.wikipedia.org/wiki/FRRouting
|
||||
[4]: https://opensource.com/sites/default/files/uploads/frr_architecture.png (FRR architecture)
|
||||
[5]: http://docs.frrouting.org/projects/dev-guide/en/latest/vtysh.html
|
||||
[6]: http://docs.frrouting.org/projects/dev-guide/en/latest/building-frr-for-centos7.html
|
||||
[7]: https://opensource.com/sites/default/files/uploads/frr_daemon_restart.png (FRR daemon restart)
|
@ -0,0 +1,198 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (How to configure your router using VTY shell)
|
||||
[#]: via: (https://opensource.com/article/20/5/vty-shell)
|
||||
[#]: author: (M Umer https://opensource.com/users/noisybotnet)
|
||||
|
||||
如何使用 VTY Shell 配置路由器
|
||||
======
|
||||
FRR(free range routing)给了你实现多种协议的选择。本指南将帮助你入门。
|
||||
![Multi-colored and directional network computer cables][1]
|
||||
|
||||
最近,我写了一篇文章,解释了如何使用 [Quagga][2] 路由套件实现开放式最短路径优先(OSPF)。可以使用多个软件套件代替 Quagga 来实现不同的路由协议。其中一种是 FRR。
|
||||
|
||||
### FRR
|
||||
|
||||
[FRR][3] 是一个路由软件套件,它衍生自 Quagga,并在 GNU GPL2 许可下分发。与 Quagga 一样,它为类 Unix 平台提供了所有主要路由协议的实现,例如 OSPF,路由信息协议 (RIP),边界网关协议 (BGP) 和中间系统到中间系统 (IS-IS)。
|
||||
|
||||
背后开发 Quagga 的一些公司,例如 Big Switch Networks、Cumulus、Open Source Routing 和 6wind,创建了 FRR 以改善 Quagga 的良好基础。
|
||||
|
||||
|
||||
#### 体系结构
|
||||
|
||||
FRR是一组守护程序,它们可以共同构建路由表。每个主协议都在其自己的守护程序中实现,并且这些守护程序与独立于协议的核心守护程序 Zebra 通信,后者提供内核路由表更新、接口查找以及不同路由协议之间路由的重新分配。每个特定协议的守护程序负责运行相关协议并根据交换的信息构建路由表。
|
||||
|
||||
![FRR architecture][4]
|
||||
|
||||
### VTY shell
|
||||
|
||||
[VTYSH][5] 是 FRR 路由引擎的集成 shell。它将每个守护程序中定义的所有 CLI 命令合并,并在单个 shell 中将它们呈现给用户。它提供了类似于 Cisco 的命令行模式,并且许多命令与 Cisco IOS 命令相似。CLI 有不同的模式,某些命令仅在特定模式下可用。
|
||||
|
||||
### 设置
|
||||
|
||||
在本教程中,我们将使用 FRR 配置动态路由来实现路由信息协议(RIP)。我们可以通过两种方式来做到这一点:在编辑器中编辑协议守护程序配置文件或使用 VTY Shell。在此例中,我们将使用 VTY shell。我们的设置包括两个名为 Alpha 和 Beta 的 CentOS 7.7 主机。这两台主机都有两个网络接口,并共享对 192.168.122.0/24 网络的访问。我们将广播 10.12.11.0/24 和 10.10.10.0/24 网络的路由。
|
||||
|
||||
**对于主机 Alpha:**
|
||||
|
||||
* eth0 IP: 192.168.122.100/24
|
||||
* Gateway: 192.168.122.1
|
||||
* eth1 IP: 10.10.10.12/24
|
||||
|
||||
|
||||
|
||||
**对于主机 Beta:**
|
||||
|
||||
* eth0 IP: 192.168.122.50/24
|
||||
* Gateway: 192.168.122.1
|
||||
* eth1 IP: 10.12.11.12/24
|
||||
|
||||
|
||||
|
||||
#### 安装软件包
|
||||
|
||||
首先,我们需要在两台主机上都安装 FRR 软件包。可以按照[官方 FRR 文档][6]中的说明进行操作。
|
||||
|
||||
#### 启用 IP 转发
|
||||
|
||||
对于路由,我们需要在两台主机上都启用 IP 转发,因为这将由 Linux 内核执行。
|
||||
|
||||
|
||||
```
|
||||
sysctl -w net.ipv4.conf.all.forwarding = 1
|
||||
|
||||
sysctl -w net.ipv6.conf.all.forwarding = 1
|
||||
sysctl -p
|
||||
```
|
||||
|
||||
#### 启用 RIPD 守护程序
|
||||
|
||||
安装后,所有配置文件将保存在 **/etc/frr** 目录中。 必须通过编辑 **/etc/frr/daemons** 文件显式启用守护程序。 该文件确定启动 FRR 服务时激活哪些守护程序。 要启用特定的守护程序,只需将相应的 “no” 改为 “yes”。 之后的服务重启将启动守护程序。
|
||||
|
||||
![FRR daemon restart][7]
|
||||
|
||||
#### 防火墙配置
|
||||
|
||||
由于 RIP 协议使用 UDP 作为传输协议,并被分配了 520 端口,因此我们需要在 `firewalld` 配置中允许该端口。
|
||||
|
||||
|
||||
```
|
||||
firewall-cmd --add-port=520/udp –permanent
|
||||
|
||||
firewalld-cmd -reload
|
||||
```
|
||||
|
||||
现在,我们可以使用以下命令启动 FRR 服务:
|
||||
|
||||
|
||||
```
|
||||
`systemctl start frr`
|
||||
```
|
||||
|
||||
#### 使用 VTY 进行配置
|
||||
|
||||
现在,我们需要使用 VTY Shell 配置 RIP。
|
||||
|
||||
在主机 Alpha 上:
|
||||
|
||||
|
||||
```
|
||||
[root@alpha ~]# vtysh
|
||||
|
||||
Hello, this is FRRouting (version 7.2RPKI).
|
||||
Copyright 1996-2005 Kunihiro Ishiguro, et al.
|
||||
|
||||
alpha# configure terminal
|
||||
alpha(config)# router rip
|
||||
alpha(config-router)# network 192.168.122.0/24
|
||||
alpha(config-router)# network 10.10.10.0/24
|
||||
alpha(config-router)# route 10.10.10.5/24
|
||||
alpha(config-router)# do write
|
||||
Note: this version of vtysh never writes vtysh.conf
|
||||
Building Configuration...
|
||||
Configuration saved to /etc/frr/ripd.conf
|
||||
Configuration saved to /etc/frr/staticd.conf
|
||||
alpha(config-router)# do write memory
|
||||
Note: this version of vtysh never writes vtysh.conf
|
||||
Building Configuration...
|
||||
Configuration saved to /etc/frr/ripd.conf
|
||||
Configuration saved to /etc/frr/staticd.conf
|
||||
alpha(config-router)# exit
|
||||
```
|
||||
|
||||
类似地,在主机 Beta 上:
|
||||
|
||||
|
||||
```
|
||||
[root@beta ~]# vtysh
|
||||
|
||||
Hello, this is FRRouting (version 7.2RPKI).
|
||||
Copyright 1996-2005 Kunihiro Ishiguro, et al.
|
||||
|
||||
beta# configure terminal
|
||||
beta(config)# router rip
|
||||
beta(config-router)# network 192.168.122.0/24
|
||||
beta(config-router)# network 10.12.11.0/24
|
||||
beta(config-router)# do write
|
||||
Note: this version of vtysh never writes vtysh.conf
|
||||
Building Configuration...
|
||||
Configuration saved to /etc/frr/zebra.conf
|
||||
Configuration saved to /etc/frr/ripd.conf
|
||||
Configuration saved to /etc/frr/staticd.conf
|
||||
beta(config-router)# do write memory
|
||||
Note: this version of vtysh never writes vtysh.conf
|
||||
Building Configuration...
|
||||
Configuration saved to /etc/frr/zebra.conf
|
||||
Configuration saved to /etc/frr/ripd.conf
|
||||
Configuration saved to /etc/frr/staticd.conf
|
||||
beta(config-router)# exit
|
||||
```
|
||||
|
||||
完成后,像下面这样检查两台主机路由:
|
||||
|
||||
|
||||
```
|
||||
[root@alpha ~]# ip route show
|
||||
default via 192.168.122.1 dev eth0 proto static metric 100
|
||||
10.10.10.0/24 dev eth1 proto kernel scope link src 10.10.10.12 metric 101
|
||||
10.12.11.0/24 via 192.168.122.50 dev eth0 proto 189 metric 20
|
||||
192.168.122.0/24 dev eth0 proto kernel scope link src 192.168.122.100 metric 100
|
||||
```
|
||||
|
||||
我们可以看到 Alpha 上的路由表通过 192.168.122.50 包含了 10.12.11.0/24 的条目,它是通过 RIP 提供的。类似地,在 Beta 上,该表通过 192.168.122.100 包含了 10.10.10.0/24 的条目。
|
||||
|
||||
|
||||
```
|
||||
[root@beta ~]# ip route show
|
||||
default via 192.168.122.1 dev eth0 proto static metric 100
|
||||
10.10.10.0/24 via 192.168.122.100 dev eth0 proto 189 metric 20
|
||||
10.12.11.0/24 dev eth1 proto kernel scope link src 10.12.11.12 metric 101
|
||||
192.168.122.0/24 dev eth0 proto kernel scope link src 192.168.122.50 metric 100
|
||||
```
|
||||
|
||||
### 总结
|
||||
|
||||
如你所见,设置和配置相对简单。 要增加复杂性,我们可以向路由器添加更多的网络接口,以为更多的网络提供路由。可以在编辑器中编辑配置文件来进行配置,但是使用 VTY Shell 在单个组合会话中为我们提供了所有 FRR 守护程序的前端。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/20/5/vty-shell
|
||||
|
||||
作者:[M Umer][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/noisybotnet
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/connections_wires_sysadmin_cable.png?itok=d5WqHmnJ (Multi-colored and directional network computer cables)
|
||||
[2]: https://opensource.com/article/20/4/quagga-linux
|
||||
[3]: https://en.wikipedia.org/wiki/FRRouting
|
||||
[4]: https://opensource.com/sites/default/files/uploads/frr_architecture.png (FRR architecture)
|
||||
[5]: http://docs.frrouting.org/projects/dev-guide/en/latest/vtysh.html
|
||||
[6]: http://docs.frrouting.org/projects/dev-guide/en/latest/building-frr-for-centos7.html
|
||||
[7]: https://opensource.com/sites/default/files/uploads/frr_daemon_restart.png (FRR daemon restart)
|
Loading…
Reference in New Issue
Block a user