In a single system, you can create multiple virtual network interface cards (VNICs) over a single physical NIC. Creating VNICs and using them with zones enable you to create a "network-in-a-box", in which several zones in the system are configured with their individual VNICs. These zones function like a network of multiple systems where traffic flows among the zones and with the larger local area networks (LANs) or the Internet.
# {include:root_step}
# *View the data links in the system.*
For example:
{code}
# dladm show-link
LINK CLASS MTU STATE OVER
e1000g0 phys 1500 unknown --
e1000g2 phys 1500 up --
{code}
Two data links exist in the system. These data links are configured over their corresponding physical interfaces. The {{e1000g2}} data link is plumbed, as indicated by its "up" status. The {{e1000g0}} link is not configured.
# *Rename data links with neutral names.*
By default, a link's name matches the name of its associated physical interface. You can customize the name of a link to distinguish the link from the physical interface. A link must be unplumbed before its name can be changed.
{code}
# dladm rename-link <old-name> <new-name>
{code}
For example, to rename {{e1000g<_n_>}} as {{net<_n_>}}, issue the following commands:
{code}
# dladm rename-link e1000g0 net0
# ifconfig e1000g2 unplumb
# dladm rename-link e1000g2 net2
# dladm show-link
LINK CLASS MTU STATE OVER
net0 phys 1500 unknown e1000g0
net2 phys 1500 unknown e1000g2
{code}
The output shows the new link names. The links remain unconfigured and thus are in an "unknown" state.
{info:title=Note} As a best administrative practice, assign either neutral names or customized names to the data links. Using neutral or customized names for your links facilitates administrative tasks that you might need to perform later, such as replacing physical interfaces in the system.
{info}
# *Configure an IP interface over a data link.*
For example:
{code}
# ifconfig net0 plumb 192.168.3.70/24 up
{code}
# *Check the status of the IP interface.*
For example:
{code}
# ifconfig -a
lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
inet 127.0.0.1 netmask ff000000
net0: 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
{code}
If you use the {{dladm}} command to display link status, the output would be as follows:
{code}
# dladm show-link
LINK CLASS MTU STATE OVER
net0 phys 1500 up e1000g0
net2 phys 1500 unknown e1000g2
{code}
# *Create a VNIC over the configured data link.*
By default, VNICs are configured in the system's global zone.
{code}
# dladm create-vnic -l <data-link> <vnic>
{code}
where
_<data-link>_ is the name of the link over which the VNIC is created.
_<vnic>_ is the name of the VNIC.
For example:
{code}
# dladm create-vnic -l net0 vnic0
{code}
# *Configure the VNIC with an IP address.*
For example:
{code}
# ifconfig vnic0 plumb 192.168.3.250/24 up
{code}
# *Check the status of the interfaces.*
For example:
{code}
# ifconfig -a
lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
inet 127.0.0.1 netmask ff000000
net0: 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
vnic0: flags=201100843<UP,BROADCAST,RUNNING,MULTICAST,ROUTER,IPv4,CoS> mtu 9000 index 5
inet 192.168.3.250 netmask ffffff00 broadcast 192.168.3.255
ether 2:8:20:c2:39:38
{code}
You can also use the {{dladm show-vnic}} command to list the system's VNICs.
{code}
# dladm show-vnic
LINK SPEED MACADDRESSS MACADDRTYPE
vnic0 0 Mbps 2:8:20:c2:39:38 random
{code}
# *Make the VNIC configuration persist across system reboots.*
## Add the host name to the {{/etc/hostname.<_vnic_>}} file.
For example, suppose that your system's name is sys001. Issue the following commands:
{code}
# echo sys001 > /etc/hostname.vnic0
# cat /etc/hostname.vnic0
sys001
{code}
## Add the VNIC and its IP address to the {{/etc/hosts}} file.
{code}
# vi /etc/hosts
...
192.168.3.70 net0
192.168.3.250 vnic0
{code}
# {include:root_step}
# *View the data links in the system.*
For example:
{code}
# dladm show-link
LINK CLASS MTU STATE OVER
e1000g0 phys 1500 unknown --
e1000g2 phys 1500 up --
{code}
Two data links exist in the system. These data links are configured over their corresponding physical interfaces. The {{e1000g2}} data link is plumbed, as indicated by its "up" status. The {{e1000g0}} link is not configured.
# *Rename data links with neutral names.*
By default, a link's name matches the name of its associated physical interface. You can customize the name of a link to distinguish the link from the physical interface. A link must be unplumbed before its name can be changed.
{code}
# dladm rename-link <old-name> <new-name>
{code}
For example, to rename {{e1000g<_n_>}} as {{net<_n_>}}, issue the following commands:
{code}
# dladm rename-link e1000g0 net0
# ifconfig e1000g2 unplumb
# dladm rename-link e1000g2 net2
# dladm show-link
LINK CLASS MTU STATE OVER
net0 phys 1500 unknown e1000g0
net2 phys 1500 unknown e1000g2
{code}
The output shows the new link names. The links remain unconfigured and thus are in an "unknown" state.
{info:title=Note} As a best administrative practice, assign either neutral names or customized names to the data links. Using neutral or customized names for your links facilitates administrative tasks that you might need to perform later, such as replacing physical interfaces in the system.
{info}
# *Configure an IP interface over a data link.*
For example:
{code}
# ifconfig net0 plumb 192.168.3.70/24 up
{code}
# *Check the status of the IP interface.*
For example:
{code}
# ifconfig -a
lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
inet 127.0.0.1 netmask ff000000
net0: 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
{code}
If you use the {{dladm}} command to display link status, the output would be as follows:
{code}
# dladm show-link
LINK CLASS MTU STATE OVER
net0 phys 1500 up e1000g0
net2 phys 1500 unknown e1000g2
{code}
# *Create a VNIC over the configured data link.*
By default, VNICs are configured in the system's global zone.
{code}
# dladm create-vnic -l <data-link> <vnic>
{code}
where
_<data-link>_ is the name of the link over which the VNIC is created.
_<vnic>_ is the name of the VNIC.
For example:
{code}
# dladm create-vnic -l net0 vnic0
{code}
# *Configure the VNIC with an IP address.*
For example:
{code}
# ifconfig vnic0 plumb 192.168.3.250/24 up
{code}
# *Check the status of the interfaces.*
For example:
{code}
# ifconfig -a
lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
inet 127.0.0.1 netmask ff000000
net0: 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
vnic0: flags=201100843<UP,BROADCAST,RUNNING,MULTICAST,ROUTER,IPv4,CoS> mtu 9000 index 5
inet 192.168.3.250 netmask ffffff00 broadcast 192.168.3.255
ether 2:8:20:c2:39:38
{code}
You can also use the {{dladm show-vnic}} command to list the system's VNICs.
{code}
# dladm show-vnic
LINK SPEED MACADDRESSS MACADDRTYPE
vnic0 0 Mbps 2:8:20:c2:39:38 random
{code}
# *Make the VNIC configuration persist across system reboots.*
## Add the host name to the {{/etc/hostname.<_vnic_>}} file.
For example, suppose that your system's name is sys001. Issue the following commands:
{code}
# echo sys001 > /etc/hostname.vnic0
# cat /etc/hostname.vnic0
sys001
{code}
## Add the VNIC and its IP address to the {{/etc/hosts}} file.
{code}
# vi /etc/hosts
...
192.168.3.70 net0
192.168.3.250 vnic0
{code}