Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I create a virtual network interface like virbr0-nic? I am trying to find a way to create a NIC like virbr0-nic but everything which I can find on the Internet is how to create an interface attached to the physical interface like eth0:0. When I write

# brctl show
bridge name bridge id       STP enabled interfaces
virbr0      8000.525400e0af01   yes virbr0-nic
virbr1      8000.525400e8a6b1   yes virbr1-nic
                            vnet1

So virbr0 is the bridge to which virbr0-nic is attached. So how are virbr0-nic and vnet1 created?

share|improve this question
    
usually that's associated with something like a bridge specific to a bit of software. What're you REALLY trying to do? – Journeyman Geek Jun 17 '13 at 14:54
    
I have installed KVM and noticed that it created new NIC virbr0-nic. I am just wondering how can I create my own NIC such as this one. – cosimo Jun 17 '13 at 15:30

These are dummy devices. You can run

modprobe dummy

To create a network interface called dummy0.

If you want more than one device, you can create say 5 with

modprobe dummy numdummies=5

You can then control these devices like any other network device.

Give it a MAC address with

ip link set dummy0 address aa:aa:aa:bb:bb:bb

Give it an IP address with

ip addr add 10.0.0.1/24 dev dummy0

Add it to your existing bridge with

brctl addif virbr0 dummy0

Set it up, set it down, NAT off it, and so on.

share|improve this answer
1  
This answers seems to be more correct than the alternative but it lacks detail about just creating an interface that's equivalent of what KVM setups by default (virbr0-nic). – pepper_chico Feb 12 at 21:44
    
The poster of the question seems to understand what the bridge does and what the dummy device does, he just wanted to know how to create similar interfaces. You are welcome to improve the answer if you feel it could be better. – suprjami Feb 24 at 11:11

virbr0-nic stands for Virtual bridge NIC.

It's basically a bridge between your physical Network Card and your Virtual Machine's virtual Network Card.

To manage bridged interface you can use the brctl command. You can list all your bridged interfaces with

brctl show 

and add or modify bridges accordingly to your needs. To create a new bridge use

brctl addbr <name>

where <name> will be your new bridge's name (as virbr0-nic).Then you can add interfaces to the bridge with

brctl addif <brname> <ifname>

You can refer to the man page for additional information.

share|improve this answer
    
This actually doesn't tell about creating a new "virbr1-nic", just a new "virbr1" whose interface to be set ("virbr1-nic") is implied to exist previously. – pepper_chico Feb 12 at 21:36

It is not clear exactly which types of devices virbr0-nic and vnet1 are in your setup. There are a few types of virtual devices which can be useful to include in a bridge, some of which can be created using the ip command.

One kind of virtual devices is veth which creates pairs of connected virtual Ethernet interfaces.

ip link add veth0 type veth peer name veth1

In this example veth0 and veth1 are arbitrary interface names that I came up with for the example. This method can for example be useful if you want to move one of the two interfaces to a different networking namespace.

Another kind of virtual interface is vlan where you create a single virtual Ethernet interface attached to a specific 802.1q tag on a physical interface:

ip link add link eth0 name eth0.10 type vlan id 10

There is a man page with information about even more types of virtual interfaces which can be created with the ip command. The name of the man page depends on which version you have installed, I have seen it named ip-link or just ip.

Additionally if you are using any virtualization there are virtual interfaces connecting host and VM. The specifics of those depend on the virtualization solution you are using.

share|improve this answer

The libvirt is using TUN device for this purpose. You can manually create this device by following command:

# /usr/bin/tunctl -t virbr0-nic
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.