Virtual Ethernet Interfaces

Description

A virtual ethernet interface is a pseudo device that can be used as clone ethernet device. It will respond to ethernet packages for another IP address than the normal address for the machine. Thus you can have several IP addresses for a single ethernet interface.

Solaris has a build in clone device and knowledgeable users probably have already seen such "le0:1" pseudo devices.

Needed stuff

First of all, you'll need the package vif-1.11.tar.gz

Since modload is broken on SunOS 4.1.1 we'll plug VIF statically into the kernel. This is not too complicated.
Disadvantage: you cannot modunload the driver.
Advantage: you cannot modunload the driver while being in use, which surely crashes the machine.

Installation

Unpack it:
	gzcat vif-1.11.tar.gz | tar xvf -
	cd vif-1.11
Edit the file if_vif.c
	vi if_vif.c
Right after the line reading
	#include "vif.h"
add the following:
	#if NVIF > 0
and add a corresponding
	#endif
at the very end of the file.

Copy the driver source to /sys/net

	cp if_vif.c /sys/net/
Next, add the following line to /sys/conf.common/files.cmn:
	net/if_vif.c		optional vif
A good place would be right before the entry for net/if.c.

Edit /sys/sun/conf.c and add the stubb for the device. Add this after the definition for the graphics accellerator (NGAONE):

	#include "vif.h"
	#if NVIF > 0
	int vif_open(),vif_close(),vif_read(),
		vif_write(),vif_ioctl(),vif_select();
	#else
	#define vif_open nodev
	#define vif_close nodev
	#define vif_read nodev
	#define vif_write nodev
	#define vif_ioctl nodev
	#define vif_select nodev
	#endif
Then use entry #14 (formerly cgone) in the cdevsw-structure and modify it to:
    {
        vif_open,       vif_close,      vif_read,       vif_write,       /*14*/
        vif_ioctl,      nodev,          vif_select,     0,      /* was cgone */
        0,
    },
The major device number of the virtual ethernet interfaces will be 14 now!

Last, but not least, add this line to your kernel config file:

	pseudo-device	vif8
A good place would be behind the other pseudo devices and right before the comments for the "config vmunix" line.

You can change the number behind the "vif" as needed. I'd recommend not to use more than 10 virtual ethernet interfaces, since netstat is broken and will show these interfaces in a "funny" way.

Config your kernel, install it and reboot. Then create the devices:

	cd /dev
	mknod vif0 c 14 0
	mknod vif1 c 14 1
	mknod vif2 c 14 2
	mknod vif3 c 14 3
	mknod vif4 c 14 4
	mknod vif5 c 14 5
	mknod vif6 c 14 6
	mknod vif7 c 14 7
	:
	:
	:

How to use VIF

Add entries to /etc/hosts (and/or NIS and/or DNS):
        127.0.0.1       localhost
        192.68.1.1      myhost          # this is my host
        192.68.1.2      othername       # another name for my host
Add an arp-entry:
	arp -s othername 8:0:20:0:1b:a5 pub
Init the devices (important!):
	echo >/dev/vif0
Config the device:
	ifconfig vif0 othername up
Enjoy!

Troubleshooting

If you encounter problems with arp while the virtual device(s) are up, take them down for a few seconds and redo the arp entry:
        ifconfig vif0 down
        arp ...
        ifconfig vif0 up
If you wanto to see if it's working, type:
	netstat -ian
	netstat -rn
	ifconfig -a
	arp -a
If everything looks ok, try to ping and then telnet to the new address from another machine.

To find out the ethernet address of your machine, ping it from another machine and read its arp-table:

        # ping myhost
        # arp -a
        :
        myhost (123.234.56.78) at 8:0:20:0:1b:a5
        :
				  ^^^^ here ^^^^

Copyright 1999-2007 Peter Koch