NAT and Network Bridge

Source: Internet
Author: User

CentOS Setup Virtual NIC to do Nat and bridge bridging Time:2015-02-25 23:30 Source:Blog.51cto.com Author:Samlei
Summary: Two ways to configure a KVM virtual Machine network: NAT mode and bridge mode. The configuration principle and procedure of bridge mode. Bridge mode is suitable for virtualization of server hosts.

The problem? After the client installation is complete, you need to set up a network interface for it to communicate with the host network and the client network. In fact, if you want to use network traffic during installation, you need to set up the client's network connection in advance.

There are two ways to connect a KVM client network:

    • User Networking: A simple way for a virtual machine to access resources on a host, internet, or local network, but it cannot access the client from a network or other client, and it requires significant performance adjustments. Nat mode.
    • Virtual Bridge: This is more complicated than the user network, but the client and the Internet, the communication between the client and the host computer is easy to set up. Bridge Way.

This paper mainly explains the configuration of bridge mode.

Bridge mode principle

Bridge mode is the network connection mode of virtual bridge, and the machines inside the client and subnet can communicate with each other. You can make a virtual machine a host with a separate IP in the network.

A bridged network (also called a physical device share) is used to replicate a physical device to a single virtual machine. A bridge is used as an advanced setting, especially if the host has multiple network interfaces.

For example, the basic principle of a bridge is to create a bridging interface, BR0, to pass data between physical and virtual network interfaces.

Bridge mode Application scope: Server host virtualization.

Bridge mode configuration steps

1, edit modify network device script file, increase 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 configures the virtual network card in the 10.0.112.* network segment. If you do not need a static address, you can mask the dependencies of the configuration address. Such as:

Device= "Br0"
onboot= "Yes"
Type= "Bridge"
Bootproto=dhcp

2, edit modify network device script file, modify NIC device eth0

Device= "Eth0"
Nm_controlled= "No"
onboot= "Yes"
Type=ethernet
Bootproto=none
Bridge= "Br0"
Name= "System eth0"
Hwaddr=44:37:e6:4a:62:ad

Nm_controlled This attribute value, according to Redhat Company's document is must be set to "no" (this value is "yes" means can be managed by the service NetworkManager. The NetworkManager service does not support bridging, so set to "no". ), but actually found no problem with set to "Yes". Communication is normal.

3. Restart the Network Service

#service Network Restart

4, check the bridge interface

#brctl Show
Bridge name Bridge ID STP enabled interfaces
Br0 8000.4437E64A62AD No eth0

Client Configuration

During client installation, be aware that the network chooses to use the Br0 bridging method.

The graphical way:

Text mode:

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

<interface type= ' bridge ' >
<mac address= ' 52:54:00:da:c3:dc '/>
<source bridge= ' br0 '/>
<model type= ' Virtio '/>
<address type= ' PCI ' domain= ' 0x0000 ' bus= ' 0x00 ' slot= ' 0x03 ' function= ' 0x0 '/>
</interface>

After the virtual machine starts, verify that the network interface is healthy:

# Brctl Show
Bridge name Bridge ID STP enabled interfaces
Br0 8000.4437E64A62AD No eth0
Vnet0

NAT and Network Bridge

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.