• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to create a networking bridge under CentOS/RHEL

by admin

The main component of libvirt networking is the virtual network switch, also known as the bridge. You can imagine a bridge as a physical switch. In a real switch, there are a limited number of physical ports to attach to your servers. Here, on the Linux bridge, there are unlimited numbers of virtual ports to which the interfaces to virtual machines are attached. Similar to a physical switch, bridge learns the MAC addresses from the packets it receives and stores those MAC addresses in the MAC table. The packet (frames) forwarding decisions are taken based on the MAC addresses that it learned and stored in the MAC table.

Let us see how to create a bridge in this post.

Creating a bridge temporarily

If you want to create a bridge temporarily, you can use the command:

# brctl addbr BRIDGE_NAME

For example:

# brctl addbr mybridge

You can verify the newly created beidge using the below command.

# brctl show
bridge name     bridge id               STP enabled     interfaces
mybridge        8000.000000000000       no
virbr0          8000.000000000000       yes
xenbr0          8000.feffffffffff       no              peth0
                                                        vif0.0

Creating a bridge persistently

If want to create a bridge and effect persistently, you can create a ifcfg file in /etc/sysconfig/network-scripts/:

# cat /etc/sysconfig/network-scripts/ifcfg-bridge0 
DEVICE=bridge0
TYPE=Bridge
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.200.254
NETMASK=255.255.255.0

Then the bridge will be created when the network service is restarted.

# service network restart
Please note in the line “TYPE=Bridge” ‘B‘ must be uppercase.

If you want to see the bridges via virt-manager in KVM environment, please create the xml file for each bridge in /etc/libvirt/qemu/networks/. For example,

# pwd
/etc/libvirt/qemu/networks
# cat bridge0.xml 
<network>
  <name>bridge0</name>
  <uuid>31ece935-71a7-952e-d656-f5fdf9ccdf6e</uuid>
  <bridge name='bridge00' stp='on' forwardDelay='0' />
  <ip address='192.168.200.254' netmask='255.255.255.0'>
  </ip>
</network>

Then restart libvirtd service and re-execute virt-manager.

# service libvirtd restart

Final Thoughts

Please fill name in bridge element correctly. You can generate the uuid for the device using the uuidgen command:

# uuidgen

More information please refer:

man brctl
/etc/init.d/network

Filed Under: CentOS/RHEL 6, CentOS/RHEL 7, Linux

Some more articles you might also be interested in …

  1. How to Test Port [TCP/UDP] Connectivity from a Linux Server
  2. UNIX / Linux : How crontab validates the access based on the cron.allow and cron.deny files
  3. fail2ban-client Command Examples in Linux
  4. CentOS / RHEL 5 : How to disable device mapper multipath (dm-multipath)
  5. numactl: command not found
  6. Linux: No space left on device while df command shows a lot of free space
  7. dar: command not found
  8. ptx Command Examples in Linux
  9. What does refid value “.LOCL.” mean in NTP
  10. lsof: command not found

You May Also Like

Primary Sidebar

Recent Posts

  • qm Command Examples in Linux
  • qm wait Command Examples in Linux
  • qm start Command Examples in Linux
  • qm snapshot Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright