LoginSignup
9
10

More than 5 years have passed since last update.

Junos環境構築(Vagrant on Mac)

Last updated at Posted at 2014-12-27

はじめに

最近ネットワーク機器のOSであるjunosをちょっと触っているのだが、調べてみるとVagrantでjunos環境を構築できそうだったので構築してみた。

環境情報

  • OS: OS X 10.9.5
  • Vagrant: 1.7.1
  • VirtualBox: 4.3.20

Step1: Vagrantのインストール

公式サイトであるhttps://www.vagrantup.com/downloads.htmlより最新版のパッケージをダウンロードする。

ダウンロード後はパッケージをダブルクリックしてGUIでポチポチすればインストールできる。

$ vagrant --version
Vagrant 1.7.1
$ 

Step2: VirtualBoxのインストール

Vagrantと同様に公式サイトのダウンロードページhttps://www.virtualbox.org/wiki/Downloadsよりパッケージをダウンロードする。

ダウンロード後はパッケージをダブルクリックしてGUIでポチポチすればインストールできる。

Step3: Junosイメージの取得

VirtualBox上で動作するJunosのイメージをローカル環境に追加する。
以下のコマンドで追加できる。

$ vagrant box add Junos12.1X46-D25.7 https://vagrantcloud.com/juniper/boxes/ffp-12.1X46-D20.5
==> box: Loading metadata for box 'https://vagrantcloud.com/juniper/boxes/ffp-12.1X46-D20.5'
This box can work with multiple providers! The providers that it
can work with are listed below. Please review the list and choose
the provider you will be working with.

1) virtualbox
2) vmware_desktop

Enter your choice: 1
==> box: Adding box 'juniper/ffp-12.1X46-D20.5' (v0.1.6) for provider: virtualbox
    box: Downloading: https://vagrantcloud.com/juniper/boxes/ffp-12.1X46-D20.5/versions/0.1.6/providers/virtualbox.box
==> box: Successfully added box 'juniper/ffp-12.1X46-D20.5' (v0.1.6) for 'virtualbox'!
$ vagrant box list
juniper/ffp-12.1X46-D20.5 (virtualbox, 0.1.6)
$

Juniperの説明によると公式なサポート対象ではなく実験的なものとして利用しろとのこと。
対応しているHyperVisorはVirtualBoxVMWare Desktopに対応しているとのこと。

Step4: Junosの起動

$ mkdir -p ~/vagrant/vms/juniper/ffp-12.1X46-D20.5
$ cd ~/vagrant/vms/juniper/ffp-12.1X46-D20.5
$ vagrant init juniper/ffp-12.1X46-D20.5
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.
$ 
$ vagrant up
$ vagrant ssh
--- JUNOS 12.1X46-D20.5 built 2014-05-14 20:38:10 UTC
root@% 

vagrant sshで上記のように表示されればおk。

このままだとvagrant reload時にPlease disable key insertion by setting config.ssh.insert_key = false in the Vagrantfile.と言われるので、以下を追記。

~/vagrant/vms/juniper/ffp-12.1X46-D20.5/Vagrant
  config.ssh.insert_key = false

Step5: Junos Pluginインストール

イメージファイルが依存しているらしいJunosのPluginをインストールしておく。

$ vagrant halt # Junosの停止
$ vagrant plugin install vagrant-junos # Pluginインストール
$ vagrant up # Junosの起動

Step6: 管理者ユーザー作成

junos上で設定を行う管理者ユーザーjunosを作成する。

$ vagrant ssh # HostOS
root@% # ここからGuestOS
root@% cli
root> 
root> configure
[edit]
root# 
root# set system login user junos class super-user
[edit]
root# set system login user junos authentication plain-text-password    
New password: password
Retype new password: password
[edit]
root# 

Step7: ssh_configの設定変更

さてこれでjunosにsshログインできるようになった。
ただIPアドレスやホスト名でsshログインできるほうがいいので、以下のように設定する。

~/.ssh/config
Host l03-junos-test
  HostName 127.0.0.1
  User root
  Port 2222
  UserKnownHostsFile /dev/null
  StrictHostKeyChecking no
  PasswordAuthentication no
  IdentityFile ${user_home}/.vagrant.d/insecure_private_key
  IdentitiesOnly yes
  LogLevel FATAL

注:本来ならVagrantファイル上でconfig.vm.network "private_network", ip: "192.168.33.10"と指定してやればIPアクセスができるはずなのだが、今回はできなかったので上で対応した。私の知識不足かも。。。

上記のように設定すればHOST句に指定した名前でアクセスすることができる。

$ ssh junos@l03-junos-test
Password:
--- JUNOS 12.1X46-D20.5 built 2014-05-14 20:38:10 UTC
junos> 

おわりに

今までネットワーク機器は箱とOSがセットで自動化などを始めるのに敷居が高かったですが、こういった仮想環境のイメージがあれば手軽に試せるのでネットワーク機器の習熟が加速しそうですね^^

おしまい。

9
10
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
9
10