Perl Catalyst - VBox Network Configuration on Ubuntu

In my previous post regarding PerlCatalyst tutorial setup I mentioned about setting up a virtual machine inside a virtual machine. I didn't provide you with much information regarding how I did it because all the tutorials related to that is already available online. Pasting the links below:

But I had a serious problem with my virtual box inside a virtual box. Not so serious actually, just that it stopped me from proceeding ahead because of my ignorance of network configuration. The tutorial says that after downloading the virtual machine for the tutorial and setting it up as mentioned in the website, I could start using it as a server and log into it using ssh from my host computer. But for some reason the VM (virtual machine) provided by Catalyst just had a loopback network configuration. It wouldn't show me a proper ip address to which I could connect to. And hence I had no way of connecting to this new tutorial virtual machine that I started from within an Ubuntu Virtual machine. I played around with the network configuration of VBox for a couple of hours trying out the different settings provided:

  • NAT
  • Bridge Connection

In case you didn't understand what those things mentioned above were, you can read more about it in detail at the VirtualBox Networking Documentation. I don't want to write about things that I am not really an expert. I just learned about them today. It is pretty crazy to know that there is so much out there that I don't know. So yea, there is more to learn, more to conquer. Help yourself from the link.

So playing with virtual box settings wasn't helping me as the problem really was that the network adapter of the Catalyst VirtualBox wasn't configured correctly. So how do you manually set it up? This is not something software engineers normally do unless they were coding a network program. Mostly Systems Engineers are the ones who deal with such things. But now that I'm just doing it on my machine I can't hire a systems engineer. So sometimes software engineers have to learn a bit or two about network configuration. It comes in handy in situations like this. Not learning new things just makes you a bad engineer.

So I decided to explore, I started reading a post by some geek named EdSteven. I wasn't really into reading everything and so I was obviously getting frustrated but my best friend figured out my frustration and jumped in to help. She had recently configured her virtual machine at work. She had a vague memory of what she had done some 6 months ago. She asked me if she could try to help. I was relieved. I just wanted some help. She told me that there is a file that contains network configuration in Linux which you have to edit. That seemed like a good thing to look for. So she went ahead to /etc directory. She grepped some pattern. But unfortunately that returned too many results. She ran the following on the command line to find out the ethernet adapters and network configuration of the system:

1yourname@yourprompt> ifconfig -a  

This gave us information regarding all available ethernet adapters including the default loopback ip. It would look something like this:

1lo        Link encap:Local Loopback    
2          inet addr:127.0.0.1  Mask:255.0.0.0  
3          inet6 addr: ::1/128 Scope:Host  
4          UP LOOPBACK RUNNING  MTU:65536  Metric:1  
5          RX packets:1760 errors:0 dropped:0 overruns:0 frame:0  
6          TX packets:1760 errors:0 dropped:0 overruns:0 carrier:0  
7          collisions:0 txqueuelen:0   
8          RX bytes:168610 (168.6 KB)  TX bytes:168610 (168.6 KB)  
9

So after another google search she figured out the file to edit. Thanks to this website:

So all I had to do is edit /etc/network/interfaces file to tell the operating systems to choose and start the appropriate network interfaces. But now what do I tell it and how? All you have to do is run the following command:

1man interfaces  
2

Now I don't want to repeat configuration that is already suggested by the Linux manual. But I'll mention the highlights below:

 1/etc/network/interfaces contains network interface configuration information for the ifup(8) and ifdown(8) commands.  This is where you configure how your system is connected to the network.  
 2Lines starting with '#' are ignored. Note that end-of-line comments are NOT supported, comments must be on a line of their own.  
 3The file consists of zero or more "iface", "mapping", "auto", "allow-" and "source" stanzas.   
 4  
 5Lines  beginning  with  the  word  "auto"  are used to identify the physical interfaces to be brought up when ifup is run with the -a option.  (This option is used by the system boot scripts.)  
 6Physical interface names should follow the word "auto" on the same line.  There can be multiple "auto" stanzas.  ifup brings the named interfaces up in the order listed.  
 7  
 8Lines beginning with "allow-" are used to identify interfaces that should be brought up automatically by various subsytems. This may be done using a command such as "ifup --allow=hotplug  eth0  
 9eth1", which will only bring up eth0 or eth1 if it is listed in an "allow-hotplug" line. Note that "allow-auto" and "auto" are synonyms.  
10  
11IFACE  physical name of the interface being processed  

So I've pasted the most important bits from the manual over here. This is so that it will be easy for you to understand my configuration now. I didn't choose a static ip, because it doesn't really matter to me. I am okay with starting the tutorial vbox and finding out the ip and then manually connecting to that ip. Okay so configuration now:

1auto lo  
2iface lo inet loopback  
3  
4auto eth3  
5iface eth3 inet dhcp

So what I did was to let my operating system know that it could load lo and eth3 interfaces when starting my system. And also mentioned the configuration to use when loading them. lo is configured to be the loopback address and eth3 is configured to be an address retrieved dynamically using DHCP protocol. So that means it is not a static ip. Now that you have edited your configuration file, you have to tell your system to start the network interfaces based on the configuration that you have recently made. You can do this by asking the operating system to restart networking interfaces.

1sudo /etc/init.d/networking restart  

And you will see it attempting to start up network interfaces printing out some information and giving you information. And to confirm if you have your new setup ready all you have to do is run:

1ifconfig -a  
2

It should list out the new inet address of eth3 and also show what lo is set to.

Okay so I hope that was good learning for today. Happy learning!

comments powered by Disqus