Friday, June 07, 2013

Make your FreeBSD Machine an IPv6-only Router

This article provides you necessary step-by-step information to make a computer a Router with the following assumption. A complete unicast and multicast router will have been setup over a machine phase wise in which
1.    The Virtual Machine has at least 128M RAM, two network cards (network interfaces), 10GB HDD and CD/DVD.
2.      Lets create such machine over a VM ware platform in to your existing HOST Operating system (Windows/Linux OS)
3.    Make sure that you have installed VMware Server/VMware Workstation/or Oracle VM virtual box.
4.    I am using Oracle VM virtual box (light weight package than VMware Server/Workstation).
5.    FreeBSD 6.2 ISO images are used for the installation. A latest FreeBSD you can install however my objective is to make you understandable in a CORE level about how routing works in kernel level. Latest OS might have almost concepts already integrated into the system.
6.     The router host name is “BSD-Routerv6”
7.    The router’s UP interface (may be em0) has set the IPv6 address : 2001:d30:101::ROLLNO and down interface (may be em1) has the IPv6 address : 2001:d30:111::ROLLNO. The IPv6 address chosen here is not an authorized IPv6 address. Dont set this IP at your real IPv6 network via your Virtual Machine. It is just for testing and experimental routing purpose.
8.    Almost steps are explained in text to avoid image which consumes more memory.

How to create a Virtual Machine?

Please follow the following steps:
1.    Install Oracle VM VirtualBox (version 4.1 or higher)  into your Host Computer (you can download freely the package from download section from for Linux and windows Hosts Both)
2.    Run the program. The program interface has three menus (file, machine and help) and four tool buttons (New => to create new VM, Setting=> for necessary settings of resources like storage, network interfaces, USB setting etc.. , Start=> run the Virtual OS, Discard=> to discard the saved state)
3.    Press the New Button and click next.
4.    Now you are asked for VM type and OS type. Write “BSD-Routerv6” at Name section. Choose the Operating System: BSD and Version FreeBSD. Then click next.
5.    Now you are asked for memory size. Set the memory size 256 MB and click next. (For FreeBSD, for our purpose, memory size of 128 MB is sufficient however if your computer has 2GB or high memory you can increase the VM memory as per your requirement.
6.    The next window, you will be asked for virtual hard disk. We are creating the new disk. So left the default which has ticked mark the start-up disk and create new hard disk button selected. (you can use existing disk if you already have a FreeBSD installed virtual disk at your computer. For this, only import of virtual disk is sufficient and run the OS without installing the new one)
7.    After pressing the next button, the wizard for virtual disk creation will open. Left it default (VDI selected) and click next.
8.    On the virtual disk storage details wizard, left it default (dynamically allocated selected). (if you select fix size, your virtual disk  allocated space will be all reserved for the disk where there might not be that size at your drives and also there might be the wastage of disk space remained free after OS installation. Setting it dynamically will create the 2GB chunk disk expandable up to maximum allocated size. Only the required space with 2GB chunk will be reserved for Virtual OS. Remaining disk space can be used by Host OS also.)
9.    Now you have to select the virtual disk file location and size of the disk. You can save your virtual disk at the drive which has more free space like in my case; my D-Drive has more than 100GB free space. So create a folder “Virtual Machines” and sub-folder “BSD-Routerv6” at your D-drive and save your disk at that location. Provide the disk size 20GB, which is more than sufficient for our objective. And Click Next.
10.    See the summary of VM and click “Create” button. Again click the “Create” button. Your VM is successfully created. Now you have to go to “settings” tools and manage other necessary resources
11.    Go the “setting” tool and choose “System” in which make the boot order like in the figure below (first book Hard Disk and 2nd Boot CDROM).
12.    Now select the “Storage” menu and on your “empty” IDE controller, Set the CD/DVD drive to 6.2-RELEASE-i386-disc1 by locating the location of FreeBSD 6.2 ISO CD 1. ( you can download the ISO CDs from
13.    Then go to “Network” menu and enable two network adapters (adapter -1 bridge adapter with your wireless network and adapter-2 bridge with your wired network card). You can set the network card connection more to NAT or HOST only or internal network as per your requirements. Bridge setting will directly use your real network card by the virtual card and may require global/public IP to be accessed from anywhere.
14.    By setting the system, storage and network menu. Our minimum setting requirements has been completed. Press “OK” and start the machine by pressing “Start” button at the tool bar. Now your OS installation steps starts.

Follow the instructions below for default FreeBSD 6.2 installation. Users who has experienced with FreeBSD may customize to suit your site but one must make sure the kernel developer distribution is installed
a.    Left the country selection as it is and click OK.
b.    At the Main Menu, select “standard” installation
c.    At FDISK Partition Editor, input “a” to use entire disk for FreeBSD and then input “q” to finish partitioning disk.
d.    At Boot Manager Installation, select “Standard”(MBR)
e.    At FreeBSD Disklabel Editor, input “a” and then “q” to use default FreeBSD partitioning.
f.    At Choose Distributions menu, select “Kern Developer” (full Binaries and Doc), press space-bar to select it.
g.    At FreeBSD Port Installation question, select “Yes” .
h.    At Choose Installation Media, select “CDROM” and then “Yes”, system will start copying files to your harddisk.
i.    At Ethernet device installation question, select “No”
j.    At Network gateway enable question, select “Yes”
k.    At anonymous FTP access question, select “No”
l.    At NFS server and client questions, select “No”
m.    At default security profile, select “No”
n.    At system console setting, select “No”
o.    At time zone setting, select “No”.
p.    At Linux binary compatibility, select “No”
q.    At USB mouse, select “No”
r.    At Browsing package collection, select “No”
s.    At User Account setup, select “No”. you can add the user account Later.
t.    At Set root password, enter root password for you machine. (never forgot the root password)
u.    At Visit general config menu, select “No”
v.    Exit Install and remove CDROM from the drive.
w.    Finish FreeBSD installation and reboot the machine.

15.    After machine restarts, login to the system using root account. Username: root and its password.

(NEXT STEP) Network configuration
16.    Edit  /etc/rc.conf  to contain following entries. In example below, em0 connects to WAN and em1 connects to LAN. Please replace hostname, IP addresses and netmask according to your site setting. The default router should be kept unchanged. Add/edit the BOLD line Only and other left as it is.
#vi /etc/rc.conf
# -- sysinstall generated deltas -- # Fri Jun  7 08:34:17 2013
# Created: Fri Jun  7 08:34:17 2013
# Enable network daemons for user convenience.
# Please make all changes to this file, not to /etc/defaults/rc.conf.
# This file now contains just the overrides from /etc/defaults/rc.conf.
#ifconfig_em0="inet  netmask"
ipv6_ifconfig_em0="2001:d30:101::1 prefixlen 64"
ipv6_ifconfig_em1="2001:d30:111::1 prefixlen 64"




17.    Now Reboot the Machine.
18.    Login into the system with root account and add new user into the system.
BSD-Routerv6# adduser
Username: babu
Full name: Babu Ram Dawadi
Uid (Leave empty for default):
Login group [babu]: wheel
Login group is wheel. Invite babu into other groups? []:
Login class [default]:
Shell (sh csh tcsh nologin) [sh]:
Home directory [/home/babu]:
Use password-based authentication? [yes]:
Use an empty password? (yes/no) [no]:
Use a random password? (yes/no) [no]:
Enter password:
Enter password again:
Lock out the account after creation? [no]:
Username   : babu
Password   : *****
Full Name  : Babu Ram Dawadi
Uid        : 1003
Class      :
Groups     : wheel
Home       : /home/babu
Shell      : /bin/sh
Locked     : no
OK? (yes/no): y
Add another user? (yes/no): n

19.    Check the name of both Ethernet interfaces to be used in configuration by using the command below. In the example below, it lists the names of interfaces are em0 and em1.
         #ifconfig  –l  ether
         em0 em1

20.    Check the Network Configuration and IPv6 address setting is correct or not with ifconfig command.
BSD-Routerv6# ifconfig
em0: flags=8843 mtu 1500
        inet6 fe80::a00:27ff:fe38:b06f%em0 prefixlen 64 scopeid 0x1
        inet6 2001:d30:101::1 prefixlen 64
        inet netmask 0xffffff00 broadcast
        ether 08:00:27:38:b0:6f
        media: Ethernet autoselect (1000baseTX )
        status: active
em1: flags=8843 mtu 1500
        inet6 fe80::a00:27ff:fe4b:4161%em1 prefixlen 64 scopeid 0x2
        inet6 2001:d30:111::1 prefixlen 64
        ether 08:00:27:4b:41:61
        media: Ethernet autoselect (1000baseTX )
        status: active
lo0: flags=8049 mtu 16384
        inet6 ::1 prefixlen 128
        inet6 fe80::1%lo0 prefixlen 64 scopeid 0x3
        inet netmask 0xff000000

21.    Try the following commands and watch the output
a.    Ping6 ff02::2%em1
b.    Ping6 ff02::1%em0
c.    Ping6 ff02::1%em1
d.    tcpdump –npi em1
(wait for long period and see the router advertisement packet)
e.    ping6 2001:d30:101::1
f.    ping6 2001:d30:111::1
g.   Ping6 (check the connectivity and output)
h.   netstat -ant

22.    If you want to connect from you VM with ipv4 network. It is required to set the ipv4 address for temporary period in your machine. If your network has DHCP server type the following command.
a.    dhclient em0 (if not bound to IPv4 address from DHCP, then go for manual configuration of IPv4 setting), verify it using ifconfig command. #ifconfig em0.
b.    Ping (if you get the reply, your machine can access the internet)
c.   you can also connect to this machine remotely from your windows OS using SSH via IPv4 or IPv6 address. Download PUTTY (SSH) ( and login remotely via SSH by providing username and password. (you have to login form normal user where root user login remotely is not allowed in ssh setting.)
23.    Capture the different IPv6 traffic on the interfaces using TCPDUMP and analyze the traffic and ICMPv6 packets learned in theory.
24.    Take online HELP and SOLUTION to troubleshoot any problems.
>> NEXT STEP on your routing machine is to enable OSPF Unicast routing<<

No comments:

Post a Comment