Thursday, May 21, 2009

[Juniper] How to simulate JUNOS w/ FreeBSD & VirtualBox on MacBook or Linux

How to simulate JUNOS w/ FreeBSD & VirtualBox on MacBook or Linux
Requiements:
JUNOS: jinstall-8.5R1.4-domestic-signed.tgz
FreeBSD: 4.10-RELEASE-i386-miniinst.iso
VirtualBox
Socat (install via macports, apt-get) <-- By default olive disable standard output, only management with serial port console

Credit:
h**p://brokenpipes.blogspot.com
h**p://www.packetmischief.ca/juniper/olive/
h**p://spirit.sheridanc.on.ca/help/virtualbox/Network_Between_VirtualBox_Machines.html

1. VirtualBox
1.1 Create VM
Name JuniperOlive
Operating system: BSD
Version: FreeBSD
1.2 Memory size 256M
1.3 Create new harddisk
- Dynamic expanding storage
- Location
- Size 3G
1.4 Config detail
1.4.1 Audio disabled
1.4.2 Network
- Adapter 1
-Adapter type: Intel PRO/1000MT Desktop
-Attached to: NAT
- Adapter 2
-Adapter type: Intel PRO/1000MT Desktop
-Attached to: Internal Network
-Name: intf_R1_R2
- Adpater 3
-Adapter type: Intel PRO/1000MT Desktop
-Attached to: Internal Network
-Name: intf_R1_R3
1.5 Serial Ports
Enable ports 1
Port number: COM1
Port mode: Host Pipe
Check Create Pipe
Path: /tmp/olive1
2. Install FreeBSD
2.1 Boot freebsd cd
2.2 Skip kernel configuration
2.3 Choose standard install
2.4 Fdisk, Press A, then Q
2.5 select: install a standard MBR
2.6 Create partitions, Press C

/ FS 500M
SWAP 500M
/config FS 100M
/var FS
Finish press Q.
2.7 Choose Distributions = Exit
2.8 Install media CD/DVD
2.9 Config Ethernet: Yes
2.10 Network Interface
2.8.1 select em0 for DHCP, no ipv6
2.8.2 enter hostname: olive, then OK
2.8.3 select NO any requested
2.8.4 Set root password YES, Add user & group= Exit
2.11 Exit from install

2. Install JUNOS software
2.1 Boot freebsd and login with root
#cd /var/tmp
#ftp x.x.x.x <-- get junos software
get jinstall-8.5R1.4-domestic-signed.tgz
#mkdir jinst-signed
#cd jinst-signed
#tar xvfz ../jinstall-8.5R1.4-domestic-signed.tgz
#mkdir jinst
#cd jinst
#tar xvfz ../jinstall-8.3R1.4-domestic.tgz
#mkdir pkgtools
#cd pkgtools
#tar xvfz ../pkgtools.tgz
#cd bin
#cp /usr/bin/true checkpic
#cd ..
#tar zcvf ../pkgtools.tgz *
#cd ..
#rm -rf pkgtools
#tar zcvf /var/tmp/jinstall-8.3R1.4-domestic-signed-olive.tgz *
#rm /dev/wd0c && ln -s /dev/ad0c /dev/wd0c
#mkdir /var/etc
#touch /var/etc/master.passwd
#touch /var/etc/group
#touch /var/etc/inetd.conf
! install JUNOS
#pkg_add /var/tmp/jinstall-8.3R1.4-domestic-signed-olive.tgz
! reboot to continue



3. VirtualBox clone VDI for Backup & for R2 R3 ..
On MacBook

$ cd Library/VirtualBox/VDI/
$ VBoxManage clonehd JuniperOlive.vdi JuniperOlive_R1.vdi
VirtualBox Command Line Management Interface Version 2.2.2
(C) 2005-2009 Sun Microsystems, Inc.
All rights reserved.

0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Clone hard disk created in format 'VDI'. UUID: 564eefe7-350f-42a3-bfd2-bb967d2f998e
3.1 New VM name JuniperOlive_R2, JuniperOlive_R3 and select harddisk from clone
3.2 Config VirtualBox JuniperOlive_R2, JuniperOlive_R3 details same JuniperOlive_R1
- Set Serial ports path different from R1, such as path: /tmp/olive2, /tmp/olive3

4. Start Olive
on macbook open new terminal
$socat -d -d /tmp/olive1 pty <-- Create new PTY. Example /dev/ttys001
$minicom -o -s <-- console and setup select port /dev/ttys001
5. Finish