Find the answer to your Linux question:
Results 1 to 9 of 9
Hi all, Host - Ubuntu 12.04 64bit VM - CentOS6 Virtualizer - VirtualBox On reboot device br0 does not seem to be present. I must run; # /usr/sbin/brctl addbr br0 ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Guru
    Join Date
    Sep 2004
    Posts
    1,807

    CentOS 6 - networking problem


    Hi all,

    Host - Ubuntu 12.04 64bit
    VM - CentOS6
    Virtualizer - VirtualBox

    On reboot device br0 does not seem to be present. I must run;
    # /usr/sbin/brctl addbr br0
    # /usr/sbin/brctl setfd br0 0
    # /usr/sbin/brctl sethello br0 0
    # /usr/sbin/brctl addif br0 eth0
    # service network restart

    # brctl show
    Code:
    bridge name     bridge id               STP enabled     interfaces
    br0             8000.0800277eccb9       no              eth0
    Then it works

    # cat /etc/sysconfig/network-scripts/ifcfg-eth0
    Code:
    DEVICE=eth0
    BOOTPROTO=none
    ONBOOT=yes
    NETMASK=255.255.255.0
    #IPADDR=192.168.124.10
    GATEWAY=192.168.124.1
    TYPE=Ethernet
    # cat /etc/sysconfig/network-scripts/ifcfg-br0
    Code:
    DEVICE=br0
    BOOTPROTO=none
    #HWADDR=00:1c:c0:61:d8:b2
    ONBOOT=yes
    IPADDR=192.168.0.214
    NETMASK=255.255.255.0
    GATEWAY=192.168.0.1
    TYPE=bridge
    USERCTL=no
    IPV6INIT=no
    PEERDNS=yes
    Please help. TIA

    B.R.
    satimis

  2. #2
    Linux Enthusiast scathefire's Avatar
    Join Date
    Jan 2010
    Location
    Western Kentucky
    Posts
    626
    You could always just script it:
    Code:
    #!/bin/bash
    PATH="/sbin:/usr/sbin:/usr/local/sbin";
    slaveIfs="1 2 3 4 6 7 8 9 10";
    cmd="$1";
    [ -z "$cmd" ] && cmd="start";
    case "$cmd" in
      start)
        brctl addbr br0;
    #    brctl stp br0 on; # No STP
        brctl addif br0 eth0;
        brctl addif br0 eth1;
        (ifdown eth0 1>/dev/null 2>&1;);
        (ifdown eth1 1>/dev/null 2>&1;);
        ifconfig eth0 0.0.0.0 up;
        ifconfig eth1 0.0.0.0 up;
        ifconfig br0 192.168.0.x up ### Adapt to your needs.
        route add default gw 192.168.0.x; ### Adapt to your needs.
    #    i removed the br0 from the for statement
        for file in eth0 eth1;
        do
          echo "1" > /proc/sys/net/ipv4/conf/${file}/proxy_arp;
          echo "1" > /proc/sys/net/ipv4/conf/${file}/forwarding;
        done;
        echo "1" > /proc/sys/net/ipv4/ip_forward;
        ;;
      stop)
        brctl delif br0 eth0;
        brctl delif br0 eth1;
        ifconfig br0 down;
        brctl delbr br0;
        ifdown eth0; ### Adapt to your needs.
        ifdown eth1; ### Adapt to your needs.
        ;;
      restart,reload)
        $0 stop;
        sleep 3;
        $0 start;
        ;;
    esac;
    linux user # 503963

  3. #3
    Linux Guru
    Join Date
    Sep 2004
    Posts
    1,807
    Quote Originally Posted by scathefire View Post
    You could always just script it:
    Code:
    #!/bin/bash
    PATH="/sbin:/usr/sbin:/usr/local/sbin";
    slaveIfs="1 2 3 4 6 7 8 9 10";
    cmd="$1";
    [ -z "$cmd" ] && cmd="start";
    case "$cmd" in
      start)
        brctl addbr br0;
    #    brctl stp br0 on; # No STP
        brctl addif br0 eth0;
        brctl addif br0 eth1;
        (ifdown eth0 1>/dev/null 2>&1;);
        (ifdown eth1 1>/dev/null 2>&1;);
        ifconfig eth0 0.0.0.0 up;
        ifconfig eth1 0.0.0.0 up;
        ifconfig br0 192.168.0.x up ### Adapt to your needs.
        route add default gw 192.168.0.x; ### Adapt to your needs.
    #    i removed the br0 from the for statement
        for file in eth0 eth1;
        do
          echo "1" > /proc/sys/net/ipv4/conf/${file}/proxy_arp;
          echo "1" > /proc/sys/net/ipv4/conf/${file}/forwarding;
        done;
        echo "1" > /proc/sys/net/ipv4/ip_forward;
        ;;
      stop)
        brctl delif br0 eth0;
        brctl delif br0 eth1;
        ifconfig br0 down;
        brctl delbr br0;
        ifdown eth0; ### Adapt to your needs.
        ifdown eth1; ### Adapt to your needs.
        ;;
      restart,reload)
        $0 stop;
        sleep 3;
        $0 start;
        ;;
    esac;
    Thanks for your script.

    Where shall I put the script?

    I have no idea which file will be evoked by CentOS at boot finally. Actually I can put following commands on that file;
    Code:
    # /usr/sbin/brctl addbr br0
    # /usr/sbin/brctl setfd br0 0
    # /usr/sbin/brctl sethello br0 0
    # /usr/sbin/brctl addif br0 eth0
    Then network will be connected at boot automatically.

    B.R.
    satims

  4. #4
    Linux Enthusiast scathefire's Avatar
    Join Date
    Jan 2010
    Location
    Western Kentucky
    Posts
    626
    Then just take those commands, put them in a script. Make sure its executable (chmod +x filename - or something to that effect).

    Or you don't want to script, drop them directly into rc.local

    If you decide to script, then modify /etc/rc.local, which is like the last thing ran in the boot sequence, a line that might look like:
    Code:
    /home/someuser/directory/scriptname
    linux user # 503963

  5. #5
    Linux Guru
    Join Date
    Sep 2004
    Posts
    1,807
    Quote Originally Posted by scathefire View Post
    Then just take those commands, put them in a script. Make sure its executable (chmod +x filename - or something to that effect).

    Or you don't want to script, drop them directly into rc.local

    If you decide to script, then modify /etc/rc.local, which is like the last thing ran in the boot sequence, a line that might look like:
    Code:
    /home/someuser/directory/scriptname
    I hope I understand your advice correctly.

    copy your script on /home/user/directory/scriptname.sh

    $ sudo chmod +x /home/user/directory/scriptname.sh

    On /path/to/rc.local
    entering
    Code:
    /home/user/directory/scriptname.sh
    If wrong, please correct me. TIA

    satimis

  6. #6
    Linux Enthusiast scathefire's Avatar
    Join Date
    Jan 2010
    Location
    Western Kentucky
    Posts
    626
    Basically that's about it. You may want to put an exit code at the end of the script. Sometimes they can hang if its not there. So in your case your script might look like:
    Code:
    /usr/sbin/brctl addbr br0
    /usr/sbin/brctl setfd br0 0
    /usr/sbin/brctl sethello br0 0
    /usr/sbin/brctl addif br0 eth0
    exit 0
    linux user # 503963

  7. #7
    Linux Guru
    Join Date
    Sep 2004
    Posts
    1,807
    Quote Originally Posted by scathefire View Post
    Basically that's about it. You may want to put an exit code at the end of the script. Sometimes they can hang if its not there. So in your case your script might look like:
    Code:
    /usr/sbin/brctl addbr br0
    /usr/sbin/brctl setfd br0 0
    /usr/sbin/brctl sethello br0 0
    /usr/sbin/brctl addif br0 eth0
    exit 0
    Your advice works here. Thanks

    B.R.
    satimis

  8. #8
    Just Joined!
    Join Date
    Nov 2012
    Posts
    1
    Quote Originally Posted by satimis View Post
    Your advice works here. Thanks

    B.R.
    satimis
    I have the same problem.....

    But is your problem not in the capitalization of the variable "bridge"??

    TYPE=Bridge

  9. #9
    Linux Guru
    Join Date
    Sep 2004
    Posts
    1,807
    Quote Originally Posted by krielallmighty View Post
    I have the same problem.....

    But is your problem not in the capitalization of the variable "bridge"??

    TYPE=Bridge
    Sorry, this is an old thread. The CentOS 6 VM has been wiped out already.

    satimis

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •