VirtualBox

source: vbox/trunk/src/VBox/Devices/Network/solaris/vnicinit_solaris.sh@ 8178

Last change on this file since 8178 was 8178, checked in by vboxsync, 17 years ago

rebranding

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Revision Id
File size: 2.5 KB
Line 
1#!/bin/bash
2# Sun xVM VirtualBox
3# VirtualBox VNIC setup script for Solaris hosts with Crossbow.
4#
5# Copyright (C) 2007 Sun Microsystems, Inc.
6#
7# This file is part of VirtualBox Open Source Edition (OSE), as
8# available from http://www.virtualbox.org. This file is free software;
9# you can redistribute it and/or modify it under the terms of the GNU
10# General Public License (GPL) as published by the Free Software
11# Foundation, in version 2 as it comes in the "COPYING" file of the
12# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
13# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
14#
15# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
16# Clara, CA 95054 USA or visit http://www.sun.com if you need
17# additional information or have any questions.
18#
19
20if [ -z "$1" ]; then
21 echo "Missing MAC address."
22 echo
23 echo "Usage: $0 macaddress [vnicname]"
24 echo " A new VNIC is created if no vnicname is provided."
25 exit 1
26fi
27
28mac=$1
29# Create the VNIC if required
30if [ -z "$2" ]; then
31 # Try obtain a physical NIC that is currently active
32 phys_nic=`/usr/sbin/dladm show-dev | /usr/bin/awk 'NF==7 && $3=="up" { print $1 }'`
33 if [ -z "$phys_nic" ]; then
34 # Failed to get a currently active NIC, get the first available NIC.
35 phys_nic=`/usr/sbin/dladm show-link | /usr/bin/nawk '/legacy/ {next} {print $1; exit}'`
36 if [ -z "$phys_nic" ]; then
37 # Failed to get any NICs!
38 echo "Failed to get a physical NIC to bind to."
39 exit 1
40 fi
41 fi
42
43 # To use a specific physical NIC, replace $phys_nic with the name of the NIC.
44 vnic_name=`/usr/lib/vna $phys_nic $mac`
45 if [ $? != 0 ]; then
46 exit 1
47 fi
48else
49 vnic_name=$2
50fi
51vnic_id=${vnic_name##*[a-z]}
52
53if [ ${vnic_id} -lt 10 ]; then
54 host_ip="192.168.1.10${vnic_id}"
55 guest_ip="192.168.1.20${vnic_id}"
56elif [ ${vnic_id} -lt 256 ]; then
57 host_ip="192.168.1.${vnic_id}"
58 guest_ip="192.168.2.${vnic_id}"
59elif [ ${vnic_id} -gt 899 ]; then
60 let "temp_id = $vnic_id % 900"
61 host_ip="192.168.1.10${temp_id}"
62 guest_ip="192.168.1.20${temp_id}"
63else
64 # VNIC ID is probably off the scale!
65 host_ip="192.168.1.10"
66 guest_ip="192.168.1.20"
67fi
68
69netmask="255.255.255.0"
70
71if [ -z "$2" ]; then
72 /sbin/ifconfig $vnic_name plumb
73 /sbin/ifconfig $vnic_name $host_ip destination $guest_ip netmask $netmask up
74#else
75# Do existing VNIC configuration here if needed...
76fi
77
78echo "$vnic_name"
79exit 0
80
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette