Welcome to Machine Unix

Search Below

Wire Me a Virtual Nic, Would Ya?

The idea of having a Virtual Nic in a Solaris environment is actually really cool. Virtual Nics have really nice features. It will let you have multiple IP addresses in only 1 NIC thus preventing you to use different physical NICs wired up if it is not necessary. You can find some FAQ’s related to Virtual NICs here. So why would one want to use a Virtual NIC? I am going to demonstrate one of the benefits of using a virtual nic in the following scenario:

I want to drink a Mocha and have my Networking too

So imagine that you are in your favorite coffee shop and you just ordered your Mocha. You are a happy person because you have your Mac and you installed a Virtualization software such as Virtual Box or Vmware Fusion, so that you can have multiple OS’es running in the same laptop. Among your other Linux distributions,  you have your beloved Solaris 10/11 installed and it is ready to be booted up. So you do the inevitable and boot your Solaris 10 VM, and soon you realize that you are not going to be able to reach to your system through your local host and especially if you are running your Solaris 10 in headless-mode. You can boot the OS, you can login to the OS and do interesting things through the GUI but you just can’t ssh into it because you configured your Solaris 10 system at your home with your home network information. So what do you do? Enter the virtual NIC.

Then you decide to configure a Virtual NIC so that you can access your OS in headless-mode by just playing with the network a bit. First thing you will do is to figure out what your network is, so at your coffee shop, in your MAC you just do ifconfig ( adding only relevant part here, and edited )

$ ifconfig -a

en1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ether 10:60:1b:50:f7:fa
inet6 6033::fe81:f4bf:f41e:bff7%en1 prefixlen 64 scopeid 0x5
inet 192.168.11.88 netmask 0xffffff00 broadcast 192.168.11.255
media: autoselect
status: active

Ok, so your IP is 192.168.11.88 and you are in 192.168.11.x network. Next thing you do through your VM GUI is to give a VirtualNIC to your Solaris system. You also do an ifconfig in your solaris VM ( Again adding the relevant parts with edits):

root@solu9# ifconfig -a

e1000g0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
inet 192.168.1.120 netmask ffffff00 broadcast 192.168.1.255
ether 8:0:27:dc:14:ff

So your system is in 192.168.1.X network instead of 192.168.11.X network. Also notice that your physical Nic is e1000g0. Here is how you configure your VirtualNic and give it an IP address:

First you create a /etc/hostname.e1000g0:1 file and add a hostname information there so that it will be persistent across reboots.

$ cat /etc/hostname.e1000g0:1

solu9local

e1000g0:1 is a virtualnic and you also want to add this information with the IP address of your choice to your /etc/hosts file:

$ cat /etc/hosts

….

solu9local 192.168.11.9

With the following you now configure your VNIC:

# ifconfig e1000g0:1 plumb
# ifconfig e1000g0:1 inet 192.168.11.9 netmask 255.255.255.0 broadcast + up

You basically told the system to plumb the virtual nic and asked it to calculate the broadcast address from the given IP address. So throw in your ifconfig command to see what you have now:

 e1000g0:1: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
inet 192.168.11.9 netmask ffffff00 broadcast 192.168.11.255

So now you smile, because from your MAC:

$ ping 192.168.11.9
PING 192.168.11.9 (192.168.11.9): 56 data bytes
64 bytes from 192.168.11.9: icmp_seq=0 ttl=255 time=0.280 ms
64 bytes from 192.168.11.9: icmp_seq=1 ttl=255 time=0.248 ms
64 bytes from 192.168.11.9: icmp_seq=2 ttl=255 time=0.389 ms
^C
— 192.168.11.9 ping statistics —
3 packets transmitted, 3 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.248/0.306/0.389/0.060 ms

Now, you can run your Virtualization Software in headless mode and access to your Solaris 10 system:

$ ssh root@192.168.11.9
Last login: Sat Aug 20 20:02:42 2011 from 192.168.11.88
Oracle Corporation      SunOS 5.10      Generic Patch   January 2005
root@solu9#

Now you are a happier person because you have your mocha and your networking too.