How to Create Virtual Network Interface Cards

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.

  1. Start a privileged shell.

    user@opensolaris:-$ pfexec bash
    #
    

    In this example, the bash shell is selected. You can choose to use any shell with the pfexec command. If you support multiple versions of the SolarisTM OS, use the standard su – root command. The su command works on all Solaris versions.

  2. View the data links in the system.
    For example:
    # dladm show-link
    LINK        CLASS     MTU      STATE       OVER
    e1000g0     phys      1500     unknown     --
    e1000g2     phys      1500     up          --
    

    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.

  3. 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.
    # dladm rename-link <old-name> <new-name>
    

    For example, to rename e1000g<n> as net<n>, issue the following commands:

    # 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
    

    The output shows the new link names. The links remain unconfigured and thus are in an "unknown" state.

    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.
  4. Configure an IP interface over a data link.
    For example:
    # ifconfig net0 plumb 192.168.3.70/24 up
    
  5. Check the status of the IP interface.
    For example:
    # 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
    

    If you use the dladm command to display link status, the output would be as follows:

    # dladm show-link
    LINK        CLASS     MTU      STATE       OVER
    net0        phys      1500     up          e1000g0
    net2        phys      1500     unknown     e1000g2
    
  6. Create a VNIC over the configured data link.
    By default, VNICs are configured in the system's global zone.
    # dladm create-vnic -l <data-link> <vnic>
    

    where
    <data-link> is the name of the link over which the VNIC is created.
    <vnic> is the name of the VNIC.
    For example:

    # dladm create-vnic -l net0 vnic0
    
  7. Configure the VNIC with an IP address.
    For example:
    # ifconfig vnic0 plumb 192.168.3.250/24 up
    
  8. Check the status of the interfaces.
    For example:
    # 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
    

    You can also use the dladm show-vnic command to list the system's VNICs.

    # dladm show-vnic
    LINK      SPEED      MACADDRESSS         MACADDRTYPE
    vnic0     0 Mbps     2:8:20:c2:39:38     random
    
  9. Make the VNIC configuration persist across system reboots.
    1. Add the host name to the /etc/hostname.<vnic> file.
      For example, suppose that your system's name is sys001. Issue the following commands:
      # echo sys001 > /etc/hostname.vnic0
      
      # cat /etc/hostname.vnic0
      sys001
      
    2. Add the VNIC and its IP address to the /etc/hosts file.
      # vi /etc/hosts
      ...
      192.168.3.70     net0
      192.168.3.250    vnic0
      

Labels

admin admin Delete
task task Delete
configuring configuring Delete
network network Delete
singleadmin singleadmin Delete
vnic vnic Delete
zones zones Delete
smallsiteadmin smallsiteadmin Delete
virtualization virtualization Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

Sign up or Log in to add a comment or watch this page.


The individuals who post here are part of the extended Sun Microsystems community and they might not be employed or in any way formally affiliated with Sun Microsystems. The opinions expressed here are their own, are not necessarily reviewed in advance by anyone but the individual authors, and neither Sun nor any other party necessarily agrees with them.

Copyright 1994-2009 Sun Microsystems, Inc.
Powered by Atlassian Confluence
Sun Guidelines on Public Discourse Privacy Policy Terms of Use Trademarks Site Map Employment Investor Relations Contact