Skip to content

Instantly share code, notes, and snippets.

@UshF
Forked from jameskyle/bonding.sh
Created April 1, 2014 18:31
Show Gist options
  • Save UshF/9920128 to your computer and use it in GitHub Desktop.
Save UshF/9920128 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
#
# Copyright 2011, AT&T Services, Inc.
#
# All rights reserved - Do Not Redistribute
#
# Next we have to fix udev. Since all of our hardware is the same, we can do it this way to make sure all deviceds are always the same
cat <<EOF >/etc/udev/rules.d/70-persistent-net.rules
# This file was generated by cede.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.
ACTION=="add", SUBSYSTEM=="net", SUBSYSTEMS=="pci", KERNELS=="0000:06:00.0", NAME="eth0"
ACTION=="add", SUBSYSTEM=="net", SUBSYSTEMS=="pci", KERNELS=="0000:06:00.1", NAME="eth1"
ACTION=="add", SUBSYSTEM=="net", SUBSYSTEMS=="pci", KERNELS=="0000:03:00.0", NAME="eth2"
ACTION=="add", SUBSYSTEM=="net", SUBSYSTEMS=="pci", KERNELS=="0000:03:00.1", NAME="eth3"
EOF
cat <<EOF > /etc/network/interfaces
# This file was generated by cede.
#
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
EOF
cat <<EOF > /etc/rc.local
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing. This file was generated by cede.
#
# This file describes the network interfaces available
modprobe bonding
echo 1 > /sys/class/net/bond0/bonding/mode
echo +eth0 > /sys/class/net/bond0/bonding/slaves
echo +eth1 > /sys/class/net/bond0/bonding/slaves
ip link set bond0 up
dhclient bond0
# 10gb bond
echo +bond1 > /sys/class/net/bonding_masters
echo 4 > /sys/class/net/bond1/bonding/mode
echo 100 > /sys/class/net/bond1/bonding/miimon
echo 200 > /sys/class/net/bond1/bonding/downdelay
echo 200 > /sys/class/net/bond1/bonding/updelay
echo 1 > /sys/class/net/bond1/bonding/xmit_hash_policy
echo 1 > /sys/class/net/bond1/bonding/ad_select
echo 1 > /sys/class/net/bond1/bonding/lacp_rate
echo +eth2 > /sys/class/net/bond1/bonding/slaves
echo +eth3 > /sys/class/net/bond1/bonding/slaves
ip link set bond1 up
# Interfaces
ip link add link bond0 name bond0.198 type vlan id 198
ip link set bond0.198 up
#dhclient bond0.198
ip link add link bond1 name bond1.2001 type vlan id 2001
ip link set bond1.2001 up
dhclient bond1.2001
ip link add link bond1 name bond1.2002 type vlan id 2002
ip link set bond1.2002 up
exit 0
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment