This procedure shows how to create a virtual network interface card (VNIC). VNICs are pseudo-interfaces upon which to build the containers of the virtual network. The resulting VNIC has an automatically generated MAC address. Depending on the network interface in use, you can instead explicitly assign a MAC address to a VNIC, as described in the dladm(1M).
When you first log in to a system, you are automatically in its global zone, which is where you configure VNICs. You can use VNICs in the global zone or as the building blocks for a particular type of non-global zone, the exclusive IP zone. For an introduction to zones, refer to Zones Overview in System Administration Guide: Virtualization Using the Solaris Operating System.
Become superuser or assume the equivalent root role.
To create and assign the root role, see How to Make root User Into a Role in System Administration Guide: Security Services.
View information about the system's available physical interfaces.
# dladm show-phys LINK MEDIA STATE SPEED DUPLEX DEVICE e1000g2 Ethernet unknown 0 half e1000g2 e1000g0 Ethernet up 1000 full e1000g0 |
Currently the system has two installed interfaces, e1000g0 and e1000g2.
Check the status of the data links on the system.
# dladm show-link LINK CLASS MTU STATE OVER e1000g2 phys 1500 unknown -- e1000g0 phys 1500 up -- |
Only the e1000g0 data link is running over that interface and is configured “UP”.
Unless you create customized names for your data links, the data link has the same name as the network interface device name that is displayed by dladm show-phys. For example, network interface e1000g0 has the data link name e1000g0 until you customize it. For more information on customized data link names, refer to Data Link and IP Interface Configuration (Tasks).
Check the status of any interfaces on the IP layer.
# ifconfig -a lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1 inet 127.0.0.1 netmask ff000000 e1000g0: flags=201000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4,CoS> mtu 1500 index 2 inet 192.168.3.70 netmask ffffff00 broadcast 192.168.3.255 ether 0:14:4f:94:d0:40 |
The output indicates that interface e1000g0 has the IP address 192.168.3.70. Therefore, the system is connected to the 192.168.3.0/24 network. e1000g0 has the MAC address 0:14:4f:94:d0:40.
Create a VNIC in the system's global zone.
# dladm create-vnic -l data-link vnic-name |
data-link is the name of the interface where the VNIC is to be configured.
vnic-name is the name that you want to give the VNIC.
For example, to create a VNIC named vnic0 on interface e1000g0, you would type the following:
# dladm create-vnic -l e1000g0 vnic0 |
Repeat this step for all planned VNICs in the virtual network.
Plumb the VNIC and assign it an IP address.
All VNICs must be configured and plumbed on the IP level. VNICs that are used in conjunction with an exclusive IP zone can be plumbed as part of the initial zone configuration or manually, using the steps in How to Manually Configure the VNIC and Exclusive IP Zone.
For VNICs to be configured in the global zone, do the following:
Use the ifconfig command as shown to configure the interface.
# ifconfig vnic-name plumb # ifconfig vnic-name IP-address # ifconfig vnic-name up |
For example, you would configure and plumb vnic0 over interface e1000g0as follows:
# ifconfig vnic0 plumb # ifconfig vnic0 192.168.3.250 # ifconfig vnic0 up |
Verify that the VNIC is configured and plumbed.
# ifconfig -a |
Your output should resemble the following:
lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1 inet 127.0.0.1 netmask ff000000 e1000g0:flags=201100843<UP,BROADCAST,RUNNING,MULTICAST,ROUTER,IPv4,CoS> mtu 1500 index 2 inet 192.168.3.70 netmask ffffff00 broadcast 192.168.3.255 ether 0:14:4f:94:d0:40 vnic0: flags=201100843<UP,BROADCAST,RUNNING,MULTICAST,ROUTER,IPv4,CoS> mtu 9000 index 5 inet 192.168.3.250 netmask ffffff00 broadcast 192.168.0.255 ether 2:8:20:c2:39:38 |
Look for the VNIC that you just configured in the ifconfig output. For example, vnic0 is in the previous output. The IP address that you specified and the ifconfig “UP” flag in the output must also be present. These items indicate that the VNIC is correctly configured and plumbed.
Ensure that the VNIC configuration persists across reboots
Create the file /etc/hostname.vnic-name.
In the global zone, do the following:
# cd /etc # vi hostname.vnic-name IP address of vnic-name |
For example, you type the following:
# cd /etc # vi hostname.vnic0 192.168.3.250 |
Update the /etc/inet/hosts file with entries for all the VNICs you have created.
The entries in the file should have the following format:
vnic-IP-address zoneID-vnic-IP-address |
For example, you might create the following entries:
192.168.3.250 zone0-192-168-3-250 |
When creating the zone alias entry, be sure to put a dash after the zoneID. Additionally, substitute dashes for the dot delimeters in the IP address, as shown previously.
For exclusive IP zones, refer to the instructions in How to Verify the Exclusive IP Zone Over VNIC Configuration
Verify that the new VNIC is created.
# dladm show-vnic LINK SPEED MACADDRESS MACADDRTYPE vnic0 0 Mbps 2:8:20:c2:39:38 random |
This example contains the commands to use to create and verify three VNICs. One VNIC is used in the global zone. Two other VNICs are used with the exclusive IP zones in the upcoming tasks. This example illustrates the steps in Configuring a Basic Virtual Network to accomplish the following:
Create three VNICs, vnic0, vnic1, and vnic2 on the data link e1000g0.
Verify that the VNICs were created
.
Configure and plumb vnic0 in the global zone.
Make vnic0 persist across reboots.
You must log in to the system as superuser or equivalent role to run the next commands.
# dladm show-phys LINK MEDIA STATE SPEED DUPLEX DEVICE e1000g2 n unknown 0 half e1000g2 e1000g0 Ethernet up 1000 full e1000g0 # dladm show-link LINK CLASS MTU STATE OVER e1000g2 phys 1500 unknown -- e1000g0 phys 1500 up -- # ifconfig -a lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1 inet 127.0.0.1 netmask ff000000 e1000g0: flags=201000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4,CoS> mtu 1500 index 2 inet 192.168.3.70 netmask ffffff00 broadcast 192.168.3.255 ether 0:14:4f:94:d0:40 |
# dladm create-vnic -l e1000g0 vnic0 # dladm create-vnic -l e1000g0 vnic1 # dladm create-vnic -l e1000g0 vnic2 # dladm show-vnic LINK OVER SPEED MACADDRESS MACADDRTYPE vnic0 e1000g0 1000 Mbps 2:8:20:c2:39:38 random vnic1 e1000g0 1000 Mbps 2:8:20:5f:84:ff random vnic2 e1000g0 1000 Mbps 2:8:20:54:f4:74 random |
# ifconfig vnic0 plumb # ifconfig vnic0 192.168.3.250 # ifconfig vnic0 up |
# ifconfig -a |
lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1 inet 127.0.0.1 netmask ff000000 e1000g0:flags=201100843<UP,BROADCAST,RUNNING,MULTICAST,ROUTER,IPv4,CoS>mtu 1500 index 2 inet 192.168.3.70 netmask ffffff00 broadcast 192.168.3.255 ether 0:14:4f:94:d0:40 vnic0: flags=201100843<UP,BROADCAST,RUNNING,MULTICAST,ROUTER,IPv4,CoS> mtu 9000 index 5 inet 192.168.3.250 netmask ffffff00 broadcast 192.168.0.255 ether 2:8:20:c2:39:38 |
# vi /etc/hostname.vnic0 192.168.3.250 # vi /etc/inet/hosts # Internet host table # ::1 localhost 127.0.0.1 localhost 192.168.3.70 myhost loghost 192.168.3.250 zone0-192-168-3-250 |
To configure a zone over the VNIC, see How to Create an Exclusive IP Zone Over a VNIC.
To configure an xVM domain over VNICs, information is to come.
For an example of the configuration of a basic virtual network, see Example 11–6.