<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>vagrant &#8211; Fredrik Holmberg</title>
	<atom:link href="/tag/vagrant/feed/" rel="self" type="application/rss+xml" />
	<link>/</link>
	<description>Network Consultant</description>
	<lastBuildDate>Thu, 10 Nov 2016 19:39:24 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.7.3</generator>

<image>
	<url>/wp-content/uploads/2016/04/cropped-2601-32x32.png</url>
	<title>vagrant &#8211; Fredrik Holmberg</title>
	<link>/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>On-demand Juniper labs using Vagrant</title>
		<link>/2016/04/on-demand-juniper-labs-using-vagrant/</link>
		<comments>/2016/04/on-demand-juniper-labs-using-vagrant/#comments</comments>
		<pubDate>Mon, 11 Apr 2016 22:58:51 +0000</pubDate>
		<dc:creator><![CDATA[Fredrik Holmberg]]></dc:creator>
				<category><![CDATA[juniper]]></category>
		<category><![CDATA[lab]]></category>
		<category><![CDATA[vagrant]]></category>

		<guid isPermaLink="false">/?p=173</guid>
		<description><![CDATA[If you want user adoption, make your product easily accessible. Allow people to download it and start playing around. Provide study resources and hand out discounts to get people to start taking your certifications. Attract the engineers. Show how you can automate your infrastructure using Ansible. Get them hooked! One of the first steps to start learning any platform is to set up [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>If you want user adoption, make your product easily <a href="http://www.juniper.net/us/en/dm/free-vsrx-trial/">accessible</a>. Allow people to download it and start playing around. Provide <a href="http://www.juniper.net/us/en/training/jnbooks/day-one/">study resources</a> and hand out <a href="http://www.juniper.net/us/en/training/fasttrack/">discounts</a> to get people to start taking your certifications. Attract the engineers. Show how you can <a href="https://github.com/Juniper/ansible-junos-stdlib/">automate</a> your infrastructure using Ansible. Get them hooked!</p>
<p>One of the first steps to start learning any platform is to set up a lab. Engineers want labs and <a href="http://www.juniper.net/">Juniper</a> want you to run as many virtual routers as you possibly can on your laptop. To make this as simple and streamlined as possible they provide you with their own pre-built <a href="https://vagrantcloud.com/juniper">Vagrant boxes</a>. These boxes are tiny virtual machines that can run on top of different hypervisors.</p>
<p>In the following example I will show you how to manage the deployment and configuration of these boxes using Vagrant to set up a small Juniper lab.</p>
<p><span id="more-173"></span></p>
<h2>GO</h2>
<p>Start by downloading <a href="https://www.vagrantup.com/downloads.html">Vagrant</a> and <a href="https://www.virtualbox.org/wiki/Downloads">VirtualBox</a>. You might also need to install <a href="https://git-scm.com/downloads">Git</a>.</p>
<p>Clone Juniper&#8217;s Vagrant Github repository:</p>
<blockquote><p>$ <strong>git clone https://github.com/JNPRAutomate/vagrant-junos.git</strong><br />
Cloning into &#8216;vagrant-junos&#8217;&#8230;<br />
remote: Counting objects: 208, done.<br />
remote: Total 208 (delta 0), reused 0 (delta 0), pack-reused 208<br />
Receiving objects: 100% (208/208), 28.18 KiB | 0 bytes/s, done.<br />
Resolving deltas: 100% (84/84), done.<br />
Checking connectivity&#8230; done.</p></blockquote>
<p>You now have a directory created called &#8220;<strong>vagrant-junos</strong>&#8220;.</p>
<p>Install the Vagrant plugins needed:</p>
<blockquote><p>$ <strong>cd vagrant-junos</strong><br />
$ <strong>vagrant plugin install vagrant-junos</strong><br />
Installing the &#8216;vagrant-junos&#8217; plugin. This can take a few minutes&#8230;<br />
Installed the plugin &#8216;vagrant-junos (0.2.1)&#8217;!<br />
$ <strong>vagrant plugin install vagrant-host-shell</strong><br />
Installing the &#8216;vagrant-host-shell&#8217; plugin. This can take a few minutes&#8230;<br />
Installed the plugin &#8216;vagrant-host-shell (0.0.4)&#8217;!</p></blockquote>
<p>OK, let&#8217;s say we want to build a four node topology similar to this:</p>
<p><img class="size-full wp-image-217 aligncenter" src="/wp-content/uploads/2016/04/juniper_vagrant_topo.png" alt="juniper_vagrant_topo" width="403" height="288" srcset="/wp-content/uploads/2016/04/juniper_vagrant_topo.png 403w, /wp-content/uploads/2016/04/juniper_vagrant_topo-300x214.png 300w" sizes="(max-width: 403px) 100vw, 403px" /></p>
<p>First we need to describe this topology to Vagrant using a <strong>Vagrantfile</strong>. This is the file that Vagrant will use to give instructions to VirtualBox on how to connect interfaces, how much memory to allocate to each node etc.</p>
<p>Our <strong>Vagrantfile</strong> should look like this:</p>
<blockquote>
<pre style="margin: 0; line-height: 125%;">#
# Juniper lab v0.1
#
# ge-0/0/0.0: management interface
# ge-0/0/1.0 - ge-0/0/7.0: user interfaces

Vagrant.configure(2) do |config|
  config.vm.box = "juniper/ffp-12.1X47-D15.4-packetmode"

  config.vm.provider "virtualbox" do |vb|
    vb.memory = 1024
    vb.cpus = 2
    vb.gui = false
  end

  config.vm.define "vsrx1" do |vsrx1|
    vsrx1.vm.host_name = "vsrx1"
    vsrx1.vm.network "private_network",
                     ip: "10.99.12.1",
                     virtualbox__intnet: "1-2"
    vsrx1.vm.network "private_network",
                     ip: "10.99.13.1",
                     virtualbox__intnet: "1-3"
  end

  config.vm.define "vsrx2" do |vsrx2|
    vsrx2.vm.host_name = "vsrx2"
    vsrx2.vm.network "private_network",
                     ip: "10.99.23.2",
                     virtualbox__intnet: "2-3"
    vsrx2.vm.network "private_network",
                     ip: "10.99.12.2",
                     virtualbox__intnet: "1-2"
  end

  config.vm.define "vsrx3" do |vsrx3|
    vsrx3.vm.host_name = "vsrx3"
    vsrx3.vm.network "private_network",
                     ip: "10.99.13.3",
                     virtualbox__intnet: "1-3"
    vsrx3.vm.network "private_network",
                     ip: "10.99.23.3",
                     virtualbox__intnet: "2-3"
    vsrx3.vm.network "private_network",
                     ip: "10.99.34.3",
                     virtualbox__intnet: "3-4"
  end

  config.vm.define "vsrx4" do |vsrx4|
    vsrx4.vm.host_name = "vsrx4"
    vsrx4.vm.network "private_network",
                      ip: "10.99.34.4",
                      virtualbox__intnet: "3-4"
  end
end
</pre>
</blockquote>
<p>We allocate 1GB of memory to each node (512MB also works), two vCPUs and hide the console/GUI (headless). Then we specify all the interfaces and private networks that the nodes will communicate over. Pretty straight forward.</p>
<h2>Will it float?</h2>
<p>Only one way to find out! Start the lab:</p>
<blockquote><p>$ <strong>vagrant up</strong><br />
Bringing machine &#8216;vsrx1&#8217; up with &#8216;virtualbox&#8217; provider&#8230;<br />
Bringing machine &#8216;vsrx2&#8217; up with &#8216;virtualbox&#8217; provider&#8230;<br />
Bringing machine &#8216;vsrx3&#8217; up with &#8216;virtualbox&#8217; provider&#8230;<br />
Bringing machine &#8216;vsrx4&#8217; up with &#8216;virtualbox&#8217; provider&#8230;<br />
&#8230;<br />
==&gt; vsrx1: Importing base box &#8216;juniper/ffp-12.1X47-D15.4-packetmode&#8217;&#8230;<br />
==&gt; vsrx1: Matching MAC address for NAT networking&#8230;<br />
&#8230;<br />
==&gt; vsrx1: Checking if box &#8216;juniper/ffp-12.1X47-D15.4-packetmode&#8217; is up to date&#8230;<br />
==&gt; vsrx1: Setting the name of the VM: vagrant-junos_vsrx1_1460289979254_16001<br />
==&gt; vsrx1: Fixed port collision for 22 =&gt; 2222. Now on port 2203.<br />
==&gt; vsrx1: Clearing any previously set network interfaces&#8230;<br />
==&gt; vsrx1: Preparing network interfaces based on configuration&#8230;<br />
vsrx1: Adapter 1: nat<br />
vsrx1: Adapter 2: intnet<br />
vsrx1: Adapter 3: intnet<br />
==&gt; vsrx1: Forwarding ports&#8230;<br />
vsrx1: 22 (guest) =&gt; 2203 (host) (adapter 1)<br />
==&gt; vsrx1: Running &#8216;pre-boot&#8217; VM customizations&#8230;<br />
==&gt; vsrx1: Booting VM&#8230;<br />
==&gt; vsrx1: Waiting for machine to boot. This may take a few minutes&#8230;<br />
vsrx1: SSH address: 127.0.0.1:2203<br />
vsrx1: SSH username: root<br />
vsrx1: SSH auth method: private key<br />
&#8230;<br />
==&gt; vsrx1: Machine booted and ready!<br />
==&gt; vsrx1: Checking for guest additions in VM&#8230;<br />
&#8230;<br />
==&gt; vsrx1: Setting hostname&#8230;<br />
==&gt; vsrx1: Configuring and enabling network interfaces&#8230;</p></blockquote>
<p>These operations will repeat until all of the nodes are up and running.</p>
<p>When completed you can check the status of the nodes:</p>
<blockquote><p>$ <strong>vagrant status</strong><br />
Current machine states:</p>
<p>vsrx1                                  running (virtualbox)<br />
vsrx2                                  running (virtualbox)<br />
vsrx3                                  running (virtualbox)<br />
vsrx4                                  running (virtualbox)</p></blockquote>
<p>Nice! Now what?</p>
<p>Try accessing one of the nodes:</p>
<blockquote><p>$ <strong>vagrant ssh vsrx4</strong><br />
&#8212; JUNOS 12.1X47-D15.4 built 2014-11-12 02:13:59 UTC<br />
root@vsrx4% <strong>cli</strong><br />
root@vsrx4&gt; <strong>show version</strong><br />
Hostname: vsrx4<br />
Model: firefly-perimeter<br />
JUNOS Software Release [12.1X47-D15.4]<br />
root@vsrx4&gt; <strong>ping 10.99.34.3 count 3</strong><br />
PING 10.99.34.3 (10.99.34.3): 56 data bytes<br />
64 bytes from 10.99.34.3: icmp_seq=0 ttl=64 time=9.094 ms<br />
64 bytes from 10.99.34.3: icmp_seq=1 ttl=64 time=0.992 ms<br />
64 bytes from 10.99.34.3: icmp_seq=2 ttl=64 time=1.185 ms</p>
<p>&#8212; 10.99.34.3 ping statistics &#8212;<br />
3 packets transmitted, 3 packets received, 0% packet loss<br />
round-trip min/avg/max/stddev = 0.992/3.757/9.094/3.775 ms</p></blockquote>
<p>It works! We have reachability between <strong>vsrx3</strong> and<strong> vsrx4</strong>!</p>
<h2>Final notes</h2>
<p>So you play around for a while, commit your configs and consider yourself done for the day. Then I&#8217;d recommend that you suspend the whole topology instead of shutting it down:</p>
<blockquote>
<pre>$ <strong>vagrant suspend</strong>
==&gt; vsrx1: Saving VM state and suspending execution...
==&gt; vsrx2: Saving VM state and suspending execution...
==&gt; vsrx3: Saving VM state and suspending execution...
==&gt; vsrx4: Saving VM state and suspending execution...
$ <strong>vagrant status</strong>
Current machine states:

vsrx1                     saved (virtualbox)
vsrx2                     saved (virtualbox)
vsrx3                     saved (virtualbox)
vsrx4                     saved (virtualbox)
</pre>
</blockquote>
<p>This way you save the running state of the whole lab topology. The benefit of doing this is that you can continue where you left off without having to wait for the boot sequence x $node.</p>
<p>Cool! What to do from here is all up to you. Have fun <img src="https://s.w.org/images/core/emoji/2.2.1/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<p>Professional Juniper consulting is available through my <a href="/consulting/">Consulting Services</a>.</p>
]]></content:encoded>
			<wfw:commentRss>/2016/04/on-demand-juniper-labs-using-vagrant/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
