LoginSignup
3
1

More than 5 years have passed since last update.

EdgeRouter XでBGP

Last updated at Posted at 2017-10-22

「EdgeRouter Xという1万円のルータでBGPが打てる」とどこかで目にしたので、2台購入しEdgeRouter間でBGPピアを確立してみました。

機器へのログイン方法

初期状態のEdgeRouter Xのeth0には192.168.1.1のアドレスが振られています。パソコンとEdgeRouter Xのeth0をLANケーブルで直結し、パソコン側のIPアドレスを192.168.1.2等に設定したあと、sshかhttpsで 192.168.1.1 (username : ubnt, password : ubnt)に接続します。

詳細は以下に記載されています。
https://dl.ubnt.com/guides/edgemax/EdgeOS_UG.pdf

機器設定

EdgeRouter Xに搭載のOS(EdgeOS)には、GUIを介してコンフィグ設定できる機能が付属しています。ただし、BGPはGUI設定に対応していないようですので、今回はCLIで設定していきます。

EdgeRouter XはVyattaをベースにしており、同じくVyattaからforkされたVyOSのコマンドが(多分)そのまま入ります。今回の設定は以下を参考にしました。
VyOSではじめるBGPルータ

ネットワーク構成

以下の構成とします。

network.png

その他、eth0の192.168.1.1は管理インターフェース(機器へのログイン用)として残しておきます。

1台目の設定

投入コマンド

terminal
configure

set system host-name ubnt1

set interfaces ethernet eth1 address 10.10.1.254/24
set interfaces ethernet eth1 description bgp_peer_segment
set interfaces loopback lo address 10.10.0.1/32

edit protocols bgp 65001
set parameters router-id 10.10.0.1
set neighbor 10.10.1.253 remote-as 65002
set neighbor 10.10.1.253 soft-reconfiguration inbound
set network 10.10.0.1/32
exit

commit
save

全体のコンフィグ

terminal
ubnt@ubnt:~$ show configuration commands
set interfaces ethernet eth0 address 192.168.1.1/24
set interfaces ethernet eth0 duplex auto
set interfaces ethernet eth0 speed auto
set interfaces ethernet eth1 address 10.10.1.254/24
set interfaces ethernet eth1 description bgp_peer_segment
set interfaces ethernet eth1 duplex auto
set interfaces ethernet eth1 speed auto
set interfaces ethernet eth2 duplex auto
set interfaces ethernet eth2 speed auto
set interfaces ethernet eth3 duplex auto
set interfaces ethernet eth3 speed auto
set interfaces ethernet eth4 duplex auto
set interfaces ethernet eth4 speed auto
set interfaces loopback lo address 10.10.0.1/32
set interfaces switch switch0 mtu 1500
set protocols bgp 65001 neighbor 10.10.1.253 remote-as 65002
set protocols bgp 65001 neighbor 10.10.1.253 soft-reconfiguration inbound
set protocols bgp 65001 network 10.10.0.1/32
set protocols bgp 65001 parameters router-id 10.10.0.1
set service gui https-port 443
set service ssh port 22
set service ssh protocol-version v2
set system host-name ubnt1
set system login user ubnt authentication encrypted-password 'XXXX'
set system login user ubnt level admin
set system ntp server 0.ubnt.pool.ntp.org
set system ntp server 1.ubnt.pool.ntp.org
set system ntp server 2.ubnt.pool.ntp.org
set system ntp server 3.ubnt.pool.ntp.org
set system syslog global facility all level notice
set system syslog global facility protocols level debug
set system time-zone UTC

2台目の設定

投入コマンド

terminal
configure

set system host-name ubnt2

set interfaces ethernet eth1 address 10.10.1.253/24
set interfaces ethernet eth1 description bgp_peer_segment
set interfaces loopback lo address 10.10.0.2/32

edit protocols bgp 65002
set parameters  router-id 10.10.0.2
set neighbor 10.10.1.254 remote-as 65001
set neighbor 10.10.1.254 soft-reconfiguration inbound
set network 10.10.0.2/32 
exit

commit
save

全体のコンフィグ

terminal
ubnt@ubnt:~$ show configuration commands
set interfaces ethernet eth0 address 192.168.1.1/24
set interfaces ethernet eth0 duplex auto
set interfaces ethernet eth0 speed auto
set interfaces ethernet eth1 address 10.10.1.253/24
set interfaces ethernet eth1 description bgp_peer_segment
set interfaces ethernet eth1 duplex auto
set interfaces ethernet eth1 speed auto
set interfaces ethernet eth2 duplex auto
set interfaces ethernet eth2 speed auto
set interfaces ethernet eth3 duplex auto
set interfaces ethernet eth3 speed auto
set interfaces ethernet eth4 duplex auto
set interfaces ethernet eth4 speed auto
set interfaces loopback lo address 10.10.0.2/32
set interfaces switch switch0 mtu 1500
set protocols bgp 65002 neighbor 10.10.1.254 remote-as 65001
set protocols bgp 65002 neighbor 10.10.1.254 soft-reconfiguration inbound
set protocols bgp 65002 network 10.10.0.2/32
set protocols bgp 65002 parameters router-id 10.10.0.2
set service gui https-port 443
set service ssh port 22
set service ssh protocol-version v2
set system host-name ubnt2
set system login user ubnt authentication encrypted-password 'xxxx'
set system login user ubnt level admin
set system ntp server 0.ubnt.pool.ntp.org
set system ntp server 1.ubnt.pool.ntp.org
set system ntp server 2.ubnt.pool.ntp.org
set system ntp server 3.ubnt.pool.ntp.org
set system syslog global facility all level notice
set system syslog global facility protocols level debug
set system time-zone UTC

ほぼJunosと同じ操作方法です。EdgeOSもVyOSも一度も操作したことがありませんでしたが、違和感なくコンフィグ投入できました。

ルーティング確認

1台目の機器から、以下のコマンドを実施してみます。

  • show ip bgp summary
  • show ip route
  • ping 10.10.0.2
terminal
ubnt@ubnt:~$ show ip bgp summary
BGP router identifier 10.10.0.1, local AS number 65001
IPv4 Unicast - max multipaths: ebgp 1 ibgp 1
RIB entries 3, using 192 bytes of memory
Peers 1, using 2524 bytes of memory

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
10.10.1.253     4 65002      15      16        0    0    0 00:12:53        1

Total number of neighbors 1


ubnt@ubnt:~$ show ip route
Codes: K - kernel route, C - connected, S - static, R - RIP, O - OSPF,
       I - ISIS, B - BGP, > - selected route, * - FIB route

C>* 10.10.0.1/32 is directly connected, lo
B>* 10.10.0.2/32 [20/1] via 10.10.1.253, eth1, 00:12:58
C>* 10.10.1.0/24 is directly connected, eth1
C>* 127.0.0.0/8 is directly connected, lo
C>* 192.168.1.0/24 is directly connected, eth0


ubnt@ubnt:~$ ping 10.10.0.2
PING 10.10.0.2 (10.10.0.2) 56(84) bytes of data.
64 bytes from 10.10.0.2: icmp_req=1 ttl=64 time=0.515 ms
64 bytes from 10.10.0.2: icmp_req=2 ttl=64 time=0.432 ms
64 bytes from 10.10.0.2: icmp_req=3 ttl=64 time=0.409 ms
64 bytes from 10.10.0.2: icmp_req=4 ttl=64 time=0.396 ms
^C
--- 10.10.0.2 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 2998ms
rtt min/avg/max/mdev = 0.396/0.438/0.515/0.046 ms

BGPのネイバー確立し、ルーティングテーブルにBGPルートが記載され、Pingも通っていることがわかります。

さいごに

EdgeRouter XではBGPの他にもOSPFやRIP、VPNなども動作させることができます。機会があればこの辺も試してみます。

3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1