Port Channels
A lot of people do this the wrong way. So maybe this can be of help. Setting up an etherchannel, Trunk, Link Aggregation, Port Channel, Bonding - it's all about the same thing: Add some redundancy, and maybe also multiply the network speed. The ideal way to do this in my opinion is to stack 2 cisco switches to behave like one, and speak 802.3ad with them. That means: one switch can fail and the communication on the server-side will not be interrupted. If you want to add VLANs to the etherchannel you can do this on the port-channel interface, so only one place to configure. You have double or however many lines you choose throughput, and failover is done transparently.
Linux
This is my setup on linux (/etc/network/interfaces on ubuntu server / debian linux).
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
auto lo
iface lo inet loopback
auto eth0
auto eth2
auto bond0
auto br0
iface eth0 inet manual
up ip link set up dev eth0
down ip link set down dev eth0
bond-master bond0
iface eth2 inet manual
up ip link set up dev eth2
down ip link set down dev eth2
bond-master bond0
iface bond0 inet manual
up ip link set up dev bond0
down ip link set down dev bond0
slaves eth0 eth2
bond-mode 802.3ad
# The primary network interface
iface br0 inet static
address 1.2.3.4
netmask 255.255.255.224
network 1.2.3.0
broadcast 1.2.3.255
gateway 1.2.3.1
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 8.8.8.8
dns-search wogri.at
bridge_ports bond0
bridge_stp off
bridge_fd 0
If you want to add vlans to your bonding-interface, it's as simple as:
1
2
3
4
iface vlan108 inet manual
vlan-raw-device bond0
up ip link set up dev vlan108
down ip link set down dev vlan108
don't forget the 'auto vlan98' in your /etc/network/interfaces.
Cisco Switch
Here's how I have done it on the cisco stack:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
interface Port-channel3
description +++ custernode-2 loadbalance/INTERNET +++
switchport trunk native vlan 109
switchport trunk allowed vlan 107-109
switchport mode trunk
switchport nonegotiate
interface GigabitEthernet1/0/15
description +++ custernode-2 eth0/loadbalance/INTERNET +++
switchport trunk native vlan 109
switchport trunk allowed vlan 107-109
switchport mode trunk
switchport nonegotiate
load-interval 60
spanning-tree portfast trunk
spanning-tree bpdufilter enable
channel-protocol lacp
channel-group 3 mode active
interface GigabitEthernet2/0/15
description +++ custernode-2 eth2/loadbalance/INTERNET +++
switchport trunk native vlan 109
switchport trunk allowed vlan 107-109
switchport mode trunk
switchport nonegotiate
load-interval 60
spanning-tree portfast trunk
spanning-tree bpdufilter enable
channel-protocol lacp
channel-group 3 mode active
Linux Active / Passive Bonding
If you don't have awesome 802.3ad switches and still want failover you can do it on the pure linux - side. You can even use 2 different switches in this scenario who don't need to know about each other.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
auto lo
iface lo inet loopback
auto eth2
iface eth2 inet manual
up ip link set up dev eth2
bond-master bond0
auto eth3
iface eth3 inet manual
up ip link set up dev eth3
bond-master bond0
auto bond0
iface bond0 inet manual
up ip link set up dev bond0
down ip link set up dev bond0
bond-mode 1
bond-slaves none
auto vlan130
iface vlan130 inet manual
up ip link set up dev vlan130
down ip link set down dev vlan130
vlan_raw_device bond0
auto bridge_130
iface bridge_130 inet manual
pre-up brctl addbr bridge_130
pre-up brctl stp bridge_130 off
pre-up brctl setbridgeprio bridge_130 65535
pre-up brctl addif bridge_130 vlan130
pre-up ip addr add1.2.3.4/24 dev bridge_130
up ip link set up dev bridge_130
up ip route add default via 1.2.3.1
down ip route del default via 1.2.3.1
down ip link set down dev bridge_130
post-down ip addr del 1.2.3.4/24 dev bridge_130
post-down brctl delif bridge_130 vlan130
post-down brctl delbr bridge_130
dns-nameservers 8.8.8.8