VIRL で server(Ubuntu)を使う際の設定
Cisco VIRL 上で server(Ubuntu)を利用する際の設定をメモしておきます。VIRL のバージョンは 1.3.156 を使いました。
Build Initial Configuration を実行する¶
デザイナー上で server を配置し、そのまま実行してもサーバにはログイン出来ません。「Configuration → Build Initial Configurations」を実行することで cloud-init による初期設定が実行され、以下のユーザでログイン出来るようになります。
| ユーザ名 | パスワード |
|---|---|
| cisco | cisco |
root に昇格する¶
以降の手順では root 権限が必要になりますので、sudo su - で root 権限へ昇格しておきます。パスワードは「cisco」です。
NIC を固定する¶
必ずしも NIC を固定する必要は無いのですが、パッケージ全体をアップグレード(apt-get -y upgrade)すると NIC 名が「eth0 → enp3」のように変化してしまった為、予め udev にルールを記載し、NIC 名が変更されないようにしておきます。
echo "SUBSYSTEM==\"net\", ACTION==\"add\", ATTR{address}==\"`cat /sys/class/net/eth0/address`\", NAME=\"eth0\"" > /etc/udev/rules.d/99-nic-name.rules
アドレスを固定化する¶
「Build Initial Configurations」を実行した影響で、アドレスの設定は cat /etc/network/interfaces.d/50-cloud-init.cfg に記載されています。初期状態では以下のようになっていました。
# This file is generated from information provided by
# the datasource. Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
auto lo
iface lo inet loopback
dns-nameservers 8.8.8.8 8.8.4.4
auto eth0
iface eth0 inet static
address 172.16.1.70
netmask 255.255.255.0
mtu 1500
post-up route add default gw 172.16.1.2 || true
pre-down route del default gw 172.16.1.2 || true
auto eth1
iface eth1 inet static
address 10.255.255.2
netmask 255.255.255.0
mtu 1450
今回は以下のパラメータを指定します。
| 項目 | 値 |
|---|---|
| 管理ネットワーク用に NIC | eth0 |
| アドレス | 172.20.1.1 |
| ネットマスク | 255.255.255.0 |
| ゲートウェイ | 172.20.1.254 |
上記パラメータに設定すべく、cat /etc/network/interfaces.d/50-cloud-init.cfg を以下のように修正しました。
# This file is generated from information provided by
# the datasource. Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
auto lo
iface lo inet loopback
dns-nameservers 8.8.8.8 8.8.4.4
auto eth0
iface eth0 inet static
address 172.20.1.1
netmask 255.255.255.0
mtu 1500
post-up route add default gw 172.20.1.254 || true
pre-down route del default gw 172.20.1.254 || true
auto eth1
iface eth1 inet static
address 10.255.255.2
netmask 255.255.255.0
mtu 1450
修正が完了したら再起動し、意図したアドレス設定で起動してくることを確認します。
sudoers に NOPASSWD 設定を追加する¶
必要に応じて cisco ユーザが sudo する際にパスワードが必要無いように設定しておきます。
パッケージのアップグレード¶
以降は通常通り、パッケージを追加するなり、アップグレードするなりして server(Ubuntu)を利用します。