#!/bin/sh

# Test if second NIC exists.
eth1_exists=`grep eth1 /proc/ioports|grep eth1|wc -l`

if [ $eth1_exists -eq 1 ]
then
	#
	# Double NIC configuration.
	#
	echo "ifconfig eth1 $1 netmask $2 up">/tmp/log
	ifconfig eth1 $1 netmask $2 up
else
	#
	# Sigle NIC configuration.
	#
	echo "ifconfig eth0:1 $1 netmask $2 up">/tmp/log
	ifconfig eth0:1 $1 netmask $2 up
fi

echo "ifconfig eth0 $3 netmask $4 up">>/tmp/log
ifconfig eth0 $3 netmask $4 up

echo "route add default gw $5">>/tmp/log
route add default gw $5

iptables -t nat -A POSTROUTING -j MASQUERADE

echo 1 > /proc/sys/net/ipv4/ip_forward
