CentOS sets the Virtual NIC for NAT and Bridge bridging

Source: Internet
Author: User
Abstract: two methods are available for KVM virtual machine network configuration: NAT and Bridge. The configuration principles and steps of Bridge. The Bridge mode is applicable to the virtualization of server hosts. Question? After the client is installed, you need to set up a network interface for it to communicate with the host network and the client network. In fact, to use network communication during installation, you need to set the network connection of the client in advance. There are two methods to connect the KVM client to the network:

Abstract: two methods are available for KVM virtual machine network configuration: NAT and Bridge. The configuration principles and steps of Bridge. The Bridge mode is applicable to the virtualization of server hosts.
Question? After the client is installed, you need to set up a network interface for it to communicate with the host network and the client network. In fact, to use network communication during installation, you need to set the network connection of the client in advance.

 

There are two methods to connect the KVM client to the network:

  • User Networking: a simple way for virtual machines to access resources on the host, Internet, or local network, but not from the network or other clients, performance also needs to be greatly adjusted. NAT mode.
  • Virtual Bridge: This method is more complex than the user's network, but after the configuration, the client and the Internet, the communication between the client and the host is easy. Bridge mode.

This article mainly explains the Bridge configuration.

Bridge mode principle

The Bridge mode is the network connection mode of the virtual Bridge, which enables the client and the machines in the subnet to communicate with each other. Virtual machines can become hosts with independent IP addresses in the network.

A bridge network (also called physical device sharing) is used to copy a physical device to a virtual machine. Bridges are used for advanced settings, especially when there are multiple network interfaces on the host.

For example, the basic principle of a bridge is to create a bridge interface br0 and transmit data between the physical Nic and the virtual network interface.

 

Bridge: server host virtualization.

Steps for configuring Bridge Mode

1. edit and modify the network device script file and add the bridge device br0

Vi/etc/sysconfig/network-scripts/ifcfg-br0
DEVICE = "br0"
ONBOOT = "yes"
TYPE = "Bridge"
BOOTPROTO = static
IPADDR = 10.0.112.39
NETMASK = 255.255.255.0
GATEWAY = 10.0.112.1
DEFROUTE = yes

The above configuration sets the virtual network card to the 10.0.112. * network segment. If you do not need a static address, you can block the configuration items. For example:

DEVICE = "br0"
ONBOOT = "yes"
TYPE = "Bridge"
BOOTPROTO = dhcp

 

2. edit the network device script file and modify the eth0 of the NIC device.

DEVICE = "eth0"
NM_CONTROLLED = "no"
ONBOOT = "yes"
TYPE = Ethernet
BOOTPROTO = none
BRIDGE = "br0"
NAME = "System eth0"
HWADDR = 44: 37: E6: 4A: 62: AD

The NM_CONTROLLED attribute value must be set to "no" according to the redhat document (this value is "yes", indicating that it can be managed by the service NetworkManager. The NetworkManager service does not support bridging, so you must set it to "no ".), However, it is found that setting "yes" is correct. Communication is normal.

3. restart the network service

# Service network restart

4. verify the bridge interface

# Brctl show
Bridge name bridge id STP enabled interfaces
Br0 8000.4437e64a62ad no eth0

 

Client Configuration

When installing the client, note that the network must be in br0 bridging mode.

Graphical method:

Text Mode:

Edit and modify the virtual machine configuration file/etc/libvirt/qemu/v1.xml, and add the following content:






 

Verify that the network interface is normal after the VM is started:

# Brctl show
Bridge name bridge id STP enabled interfaces
Br0 8000.4437e64a62ad no eth0
Vnet0

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.