Centos 6.3 bridging

Source: Internet
Author: User

I had a hard night yesterday and finally got it done. Now I can access the Internet. Pay attention to the following points during bridging:

1. After the bridge is successful, br0 has an IP address and eth0 does not have an IP address. You can access the Internet normally.

2. Make sure that the value of CAT/proc/sys/NET/IPv4/ip_forward is 1. If not 1 is found, run the echo "1">/proc/sys/NET/IPv4/ip_forward command.

3. After the brctl show command is executed, br0 and eth0 information must be followed.

 

My configuration file (based on your own network information ):

Ifcfg-eth0:

Device = eth0
Onboot = Yes
Bridge = br0

Ifcfg-br0:

Device = "br0"
Onboot = Yes
Type = Bridge
Bootproto = none
Ipaddr = 192.168.1.100
Netmask = 255.255.255.0
Gateway = 192.168.1.1
Delay = 0
Dns1 = 202.118.66.6)
Ifcfg-eth0
Device = eth0
Onboot = Yes
Bridge = br0

 

After the configuration is complete, restart the network:/etc/init. d/network restart

I have a Daniel who gave me a script to execute the install. Sh file ~~

#!/bin/sh# Just For RedHat/CentOSif [ ! -f /etc/redhat-release ]; then    echo "Just support RedHat/CentOS distribution now."    exit 1fi# arch must be x86_64if [ $(arch) != "x86_64" ]; then    echo "Your arch is $(arch), but I need x86_64 !"    exit 1fi# Need rootif [ $UID -ne 0 ]; then    echo "Need root to run install"    exit 1fiLUOYUNTOP=/opt/LuoYun/TOPDIR=${PWD}DISTRIBUTION=unalias cp > /dev/null 2>&1# RPM_LISTRPM_LIST="qemu-kvm bridge-utils libvirt"# prepare requiresfunction prepare_env(){    NOT_EXIST_RPMS=""    for RPM in $RPM_LIST; do        if ! rpm -q ${RPM} > /dev/null 2>&1; then            echo "  => ${RPM} not found"            NOT_EXIST_RPMS="${NOT_EXIST_RPMS} ${RPM}"        fi    done    # try install    if [ -n "$NOT_EXIST_RPMS" ]; then        if ! yum install $NOT_EXIST_RPMS; then            exit 1        fi    fi}function load_kvm(){    INTEL_KVM="kvm-intel"    AMD_KVM="kvm-amd"    if grep vmx /proc/cpuinfo  > /dev/null 2>&1; then        modprobe kvm $INTEL_KVM    else        modprobe kvm $AMD_KVM    fi}function setup_br0(){    echo "Setup br0 NIC"    if ifconfig br0 > /dev/null 2>&1; then        echo "  => br0 is already working !"        return    fi    for nic in $(ifconfig -a | grep ^[a-z] | awk '{print $1}'); do        ip=$(ifconfig $nic | grep Mask | awk -F: '{print $2}' | awk '{print $1}')        if [ -n "$ip" ]; then            netmask=$(ifconfig $nic | grep Mask | awk -F: '{print $4}' | awk '{print $1}')            break        fi    done    if [ -z "$ip" ]; then        echo "  => not found you ip address. please setup your bridge network manually."        return    else        echo "  => found your ip: $ip"    fi    route=$(route -n | grep UG | awk '{print $2}')    BR_FILE="/etc/sysconfig/network-scripts/ifcfg-br0"    NIC_FILE="/etc/sysconfig/network-scripts/ifcfg-$nic"    cp ${BR_FILE}{,.bak} > /dev/null 2>&1    cp ${NIC_FILE}{,.bak} > /dev/null 2>&1    cat > $BR_FILE <<EOFDEVICE="br0"ONBOOT=yesTYPE=BridgeBOOTPROTO=noneIPADDR=$ipNETMASK=$netmaskGATEWAY=$routeDELAY=0EOF    cat > $NIC_FILE <<EOFDEVICE=$nicONBOOT=yesBRIDGE=br0EOF    service network restart }function install_lynode(){    echo "Install lynode"    if [[ "X$DISTRIBUTION" != "XRHEL5" && "X$DISTRIBUTION" != "XRHEL6" ]]; then        echo "  => unsupported distribution: $DISTRIBUTION !"        exit 1    fi    mkdir -pv ${LUOYUNTOP}/platform/bin/ \        ${LUOYUNTOP}/platform/node_data/{appliances,instances} \        ${LUOYUNTOP}/platform/etc/luoyun-cloud/ \        ${LUOYUNTOP}/logs            NODEDIR="${TOPDIR}/lynode/${DISTRIBUTION}"    cp ${NODEDIR}/etc/init.d/lynoded /etc/init.d/    cp ${NODEDIR}/opt/LuoYun/platform/etc/luoyun-cloud/lynode.conf ${LUOYUNTOP}/platform/etc/luoyun-cloud/    cp ${NODEDIR}/opt/LuoYun/platform/bin/lynode ${LUOYUNTOP}/platform/bin/    chkconfig --add lynoded    chkconfig --level 2345 lynoded on}function common_install(){    prepare_env    load_kvm    #install_lynode    setup_br0}function install_rhel5(){    echo "Install LuoYun web console on redhat 5 series"    common_install}function install_rhel6(){    echo "Install LuoYun web console on redhat 6 series"    common_install}# For 5if cat /etc/redhat-release | grep 5 > /dev/null 2>&1; then    DISTRIBUTION="RHEL5"    install_rhel5    exit 0fi# For 6if cat /etc/redhat-release | grep 6 > /dev/null 2>&1; then    DISTRIBUTION="RHEL6"    install_rhel6    exit 0fi# Could not come hereecho "Just support redhat/centos 5 or 6 series"exit 2

 

 

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.