FRRouting tutorial
本記事について
FRRoutingのインストール完了までの構築メモ、基本的には公式ドキュメントに沿って進める
公式ドキュメント(Ubuntu 18.04 LTS — FRR latest documentation)
通り実施しても意外とすんなりいかなかったので備忘録として残しておく
実際のCLI操作については対象外
構築環境
OS : 18.04.2 LTS (Bionic Beaver)
(http://releases.ubuntu.com/18.04/ : ubuntu-18.04.2-desktop-amd64.iso)
FRR : FRRouting 7.1 (2019/07/05 時点でstable)
事前準備
sudo apt update sudo apt install -y vim curl openssh-server systemctl enable ssh systemctl restart ssh
FRR Installation
libyang Install (FRR 7.0以上で必要)
sudo apt install -y gcc cmake libpcre3 libpcre3-dev git pkg-config doxygen flex bison graphviz devscripts debhelper rpm git clone https://github.com/CESNET/libyang.git cd libyang mkdir build; cd build cmake -DENABLE_LYD_PRIV=ON -DCMAKE_INSTALL_PREFIX:PATH=/usr -D CMAKE_BUILD_TYPE:String="Release" .. make sudo make install
FRR Dependencies
sudo apt-get install \ git autoconf automake libtool make libreadline-dev texinfo \ pkg-config libpam0g-dev libjson-c-dev bison flex python3-pytest \ libc-ares-dev python3-dev libsystemd-dev python-ipaddress python3-sphinx \ install-info build-essential libsystemd-dev libsnmp-dev perl
Protocol Buffer
sudo apt-get install protobuf-c-compiler libprotobuf-c-dev
ZeroMQ
sudo apt-get install libzmq5 libzmq3-dev
ADD FRR user and groups
sudo groupadd -r -g 92 frr sudo groupadd -r -g 85 frrvty sudo adduser --system --ingroup frr --home /var/run/frr/ \ --gecos "FRR suite" --shell /sbin/nologin frr sudo usermod -a -G frrvty frr
Compile
git clone https://github.com/frrouting/frr.git frr cd frr ./bootstrap.sh ./configure \ --prefix=/usr \ --includedir=\${prefix}/include \ --enable-exampledir=\${prefix}/share/doc/frr/examples \ --bindir=\${prefix}/bin \ --sbindir=\${prefix}/lib/frr \ --libdir=\${prefix}/lib/frr \ --libexecdir=\${prefix}/lib/frr \ --localstatedir=/var/run/frr \ --sysconfdir=/etc/frr \ --with-moduledir=\${prefix}/lib/frr/modules \ --with-libyang-pluginsdir=\${prefix}/lib/frr/libyang_plugins \ --enable-configfile-mask=0640 \ --enable-logfile-mask=0640 \ --enable-snmp=agentx \ --enable-multipath=64 \ --enable-user=frr \ --enable-group=frr \ --enable-vty-group=frrvty \ --enable-systemd=yes \ --with-pkg-git-version \ --with-pkg-extra-version=-MyOwnFRRVersion make sudo make install
Install FRR configuration files
sudo install -m 775 -o frr -g frr -d /var/log/frr sudo install -m 775 -o frr -g frrvty -d /etc/frr sudo install -m 640 -o frr -g frrvty tools/etc/frr/vtysh.conf /etc/frr/vtysh.conf sudo install -m 640 -o frr -g frr tools/etc/frr/frr.conf /etc/frr/frr.conf sudo install -m 640 -o frr -g frr tools/etc/frr/daemons.conf /etc/frr/daemons.conf sudo install -m 640 -o frr -g frr tools/etc/frr/daemons /etc/frr/daemons
Tweak sysctls
vim /etc/sysctl.conf --- uncomment # Uncomment the next line to enable packet forwarding for IPv4 net.ipv4.ip_forward=1 # Uncomment the next line to enable packet forwarding for IPv6 # Enabling this option disables Stateless Address Autoconfiguration # based on Router Advertisements for this host net.ipv6.conf.all.forwarding=1 --- reboot
Add MPLS kernel modules
vim /etc/modules-load.d/modules.conf --- 末尾に追加 # Load MPLS Kernel Modules mpls_router mpls_iptunnel sudo modprobe mpls-router mpls-iptunnel ---
Enable MPLS Forwarding
vim /etc/sysctl.conf --- 末尾に追加(interface名は環境に合わせて変更) # Enable MPLS Label processing on all interfaces net.mpls.conf.eth0.input=1 net.mpls.conf.eth1.input=1 net.mpls.conf.eth2.input=1 net.mpls.platform_labels=100000 ---
Install service files
cd frr sudo install -m 644 tools/frr.service /etc/systemd/system/frr.service sudo systemctl enable frr
Enable daemons
vim /etc/frr/daemons --- 必要箇所をyesに変更 bgpd=yes ospfd=yes ospf6d=yes ripd=yes ripngd=yes isisd=yes pimd=yes ldpd=yes nhrpd=yes eigrpd=yes babeld=yes sharpd=yes pbrd=yes bfdd=yes fabricd=yes vrrpd=yes ---
Start FRR
sudo systemctl start frr # vtysh Hello, this is FRRouting (version 7.2-dev-MyOwnFRRVersion-g82502cd). Copyright 1996-2005 Kunihiro Ishiguro, et al. This is a git build of frr-7.1-dev-542-gc682502cd Associated branch(es): local:master github/frrouting/frr.git/master frr#
↑の画面が出てくればFRRoutingの環境構築終わりだけどもう少しだけ続く
hostname変更 (Ubuntu 18.04 LTS — FRR latest documentation)
hostnameの変更はFRRのCLI上からではなくvtysh,confを直接変更する必要がある
vim /etc/frr/vtysh.conf --- hostname frr ---
configの保存先
defaultでは、/etc/frr/frr.conf に全ての設定を書き込むが
We recommend you do not mix the use of the two types of files. Further, it is better not to use the integrated frr.conf file, as any syntax error in it can lead to /all/ of your daemons being unable to start up. Per daemon files are more robust as impact of errors in configuration are limited to the daemon in whose file the error is made.
あまり好ましくないとのことなのでそれぞれのdaemonのconfファイルに書き込む設定にする
vim /etc/frr/vtysh.conf --- no service integrated-vtysh-config --- systemctl restart frr
これで write mem するとそれぞれのconfファイルに書き込まれる 次回は、FRRoutingで何かやる
Unbound on CentOS7でローカルDNSサーバを構築してみる
【目標】
ホストOSからnslookupで名前解決できていることの確認とブラウザからIPアドレスではなくドメインでアクセスできればOK
前回までの記事
Vagrantの使い方
VagrantでWebServerとUnbound用サーバの構築
Unboundの構築
//パッケージの更新 sudo yum -y update //ifconfigでinterfaceにIPアドレスが振られていない場合に振る sudo ifconfig enp0s8 192.168.33.20 netmask 255.255.255.0 //yumでunboundのインストール sudo yum -y install unbound //unboundの設定ファイルを書き換える(基本的にコメントアウトか加筆する) sudo vim /etc/unbound/unbound.conf server: verbosity: 1 interface: 0.0.0.0 //すべての通信に対して名前解決を行う access-control: 0.0.0.0/0 refuse //defaultは遮断 //192.168.33.0/24のネットワークは許可(ホストのvagrant用vboxnetが192.168.33.0/24なので←vagrantを使う場合は基本的に同じはず) access-control: 192.168.33.0/24 allow //test.example.comという存在しないURLを名前解決し、webserverにアクセスできるようにする local-data: "test.example.com. IN A 192.168.33.30" //すべてのドメインに対して名前解決ができない場合は次のDNSサーバー(Googleが提供している)にforwardingする forward-zone: name: "." forward-addr: 8.8.8.8 forward-addr: 8.8.4.4
<補足>
正式なURLでは、末尾に「.」がつく
→ test.example.com.
unboundの起動
$ sudo systemctl start unbound $ sudo systemctl enable unbound
DNSサーバの変更
/etc/resolv.confを編集しないといけないがNetworkManagerの影響でnetworkサービスを再起動すると設定がデフォルトに戻ってしまう
そこでネットワーク起動時のインターフェースの設定を書き換える
sudo vim /etc/sysconfig/network-scripts/ifcfg-enp0s8 … DNS1=127.0.0.1 (DNSサーバを追記、unboundサーバのIPアドレスでも可) //networkサービスの再起動 $ sudo systemctl restart network //DNSサーバのアドレスが書き換わっていることを確認 cat /etc/resolv.conf … nameserver 127.0.0.1 …
検証(名前解決できているか確認)
ホストOSは以下の画面で別途DNSサーバの追加が必要
※追加するDNSは一番上に設定する
【unbound起動状態】
[ホストOS] nslookup test.example.com [ゲストOS] nslookup test.example.com
以下のようになっていれば成功(左:ゲストOS、右:ホストOS)
ホストOSからWebブラウザでも確認(URL:test.example.com)
【unbound停止状態】
[ホストOS] nslookup test.example.com [ゲストOS] nslookup test.example.com
以下のように名前解決できないことが確認できる
最後に
ローカルDNSサーバをたてられたので満足
よくDNSサーバとして利用されるBINDとunboundの違いとしては
BINDは昔からあるもので権威DNSサーバにもキャッシュサーバにも使えるがバグが多い
unboundはキャッシュサーバと部分的な権威DNSサーバの機能しかないがBINDよりも2〜4倍ほど性能がいい
あと動作としてよくわからなかったのが
Zabbix on CentOS7(Vagrant)で構築
環境
ホストOS | ゲストOS(vagrant) |
---|---|
Mac OSX | CentOS7×3 |
ゲストOS | IPアドレス | 用途 |
---|---|---|
zabbix | 192.168.33.10 | zabbixサーバ |
unbound | 192.168.33.20 | ローカルDNSサーバ(今回は使用しない) |
webserver | 192.168.33.30 | Webサーバ |
Vagrantの起動
$ mkdir workspace $ cd workspace $ vim Vagrantfile # -*- mode: ruby -*- # vi: set ft=ruby : VAGRANTFILE_API_VERSION = "2" Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| # All Vagrant configuration is done here. The most common configuration # options are documented and commented below. For a complete reference, # please see the online documentation at vagrantup.com. # Every Vagrant virtual environment requires a box to build off of. config.vm.box = "bento/centos-7.3" config.vm.define :zabbix do | zabbix | zabbix.vm.hostname = "zabbix" zabbix.vm.network :private_network, ip: "192.168.33.10" end config.vm.define :unbound do | unbound | unbound.vm.hostname = "unbound" unbound.vm.network :private_network, ip: "192.168.33.20" end config.vm.define :webserver do | webserver | webserver.vm.hostname = "webserver" webserver.vm.network :private_network, ip: "192.168.33.30" end end $ vagrant up $ vagrant ssh zabbix # ifconfigでinterfaceにipアドレスが振られてない場合は固定で振る vagrant@zabbix~$ sudo ifconfig enp0s8 up 192.168.33.10 netmask 255.255.255.0
パッケージの更新
$ sudo yum -y update $ sudo yum -y upgrade $ sudo yum -y install vim
Apacheのインストール
$ sudo yum -y install httpd $ sudo vim /etc/httpd/conf/httpd.conf #151行目 AllowOverride All #164行目 DirectoryIndex index.html index.php $ sudo systemctl start httpd $ sudo systemctl enable httpd
Apacheが起動できているか以下のURLで確認
sudo vim /var/www/html/index.html <html> <body> Test </div> </body> </html>
http://[自分のサーバのIP address]/index.html
Testが表示されていればOK
Zabbixのインストール
$ sudo wget http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm $ sudo yum -y localinstall zabbix-release-3.0-1.el7.noarch.rpm $ sudo yum -y install zabbix-server-mysql $ sudo yum -y install zabbix-web-mysql $ sudo yum -y install zabbix-web-japanese $ sudo yum -y install zabbix-agent $ sudo yum -y install zabbix-get
MariaDBのインストールとセットアップ
1 MariaDBのインストール
$ sudo yum -y install mariadb-server $ sudo vim /etc/my.cnf [mysqld] #以下の1文を追加 character-set-server=utf8 $ sudo systemctl start mariadb $ sudo systemctl enable mariadb
2 MariaDBのセットアップ
- Zabbixデータベース作成
- zabbixユーザとパスワードの設定
ユーザ名 | パスワード |
---|---|
zabbix | hogehoge |
$ mysql -u root -p > create database zabbix; > create user zabbix@'localhost' identified by 'hogehoge'; > grant all privileges on zabbix.* to zabbix@'localhost'; > exit; $ cd /usr/share/doc/zabbix-server-mysql-3.0.16/ $ sudo gunzip create.sql.gz $ mysql -u root -p zabbix < create.sql
3 Zabbixサーバのセットアップと起動
$ sudo vim /etc/zabbix/zabbix_server.conf # DB名を確認 DBName=zabbix # DBユーザー名を確認 DBUser=zabbix # DBユーザーのパスワードを追記 DBPassword=hogehoge $ sudo vim /etc/httpd/conf.d/zabbix.conf #19行目に追記 php_value date.timezone Asia/Tokyo $ sudo systemctl restart zabbix-server $ sudo systemctl enable zabbix-server
4 Zabbix-agentの起動
$ sudo systemctl restart zabbix-agent $ sudo systemctl enable zabbix-agent
Zabbixの起動確認
http://[自分のサーバのIP address]/zabbix/ にアクセス
以下のような画面が出てきたらOK(バージョンが違うのは気にしないでください)
Nextを選択
Nextを選択
UserとPasswordをそれぞれzabbixとhogehogeに設定
Nextを選択
NameはつけてもつけてなくてもOK
Nextを選択
確認画面が出てくるので良ければNextを選択
Finishを選択
デフォルトではユーザー名:Admin, パスワード:zabbixでログインできる
Zabbixの設定
管理者パスワードの変更と日本語化 右上の人形マークから管理者パスワードの変更と日本語化をする
Change passwordから新しいパスワードを入力し、LanguageからJapaneseを選択し、Updateする監視ホストの設定 管理画面からConfigure → Hostsを選択
Zabbix-agentをインストールしたローカルホストがあるのでチェックを入れ、Enableにする 少し待ってからMoniter → Screenから以下のように見られればOK監視ホストの追加(webserver on CentOS7.3)
Zabbixサーバ以外の監視ホストの追加をする
[ホストOS] $ vagrant ssh webserver $ sudo yum -y update $ sudo yum -y upgrade $ sudo yum -y install httpd $ sudo systemctl start httpd $ sudo systemctl enable httpd $ sudo wget http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm $ sudo yum -y localinstall zabbix-release-3.0-1.el7.noarch.rpm $ sudo yum -y install zabbix-agent $ sudo vim /etc/zabbix/zabbix_agentd.conf # Zabbix サーバーを指定 Server=192.168.33.10 # Zabbix サーバーを指定 ServerActive=192.168.33.10 # 自身のホスト名に変更 Hostname=webserver $ sudo systemctl restart httpd $ sudo systemctl start zabbix-agent $ sudo systemctl enable zabbix-agent
設定 → ホスト → ホストの追加(右上)に進む
ホスト名 | グループ | IPアドレス | テンプレート |
---|---|---|---|
webserver | Linux servers | 192.168.33.30 | Template OS Linux |
ホストの項目でホスト名、グループ、IPアドレスを設定する
ホストの横にあるテンプレートを選択する
選択からTemplate OS Linuxを選び、すぐ下にある追加するを選択
テンプレートとのリンクに追加されたのを確認したら一番下の追加を選択
ホストが追加されましたと表示されたらOK
しばらく待っていると以下のように見られるようになる
zabbixでsnmpを利用したネットワークの監視もできるけど今回はこれで終わり。機会があればやります。