# Channel balancing FreeBSD 8.1



## eeluve (Dec 13, 2011)

Could someone link me to a good how-to manual on using two channels? Because I can't seem to find anything useful for weeks. Got FreeBSD 8.1 and ipfw. Two external interfaces, one local. Currently only one (in my case igb0) is working. I do kind of know how to do that on 8.2 with pf, but this update would require a lot of testing on some virtual machine with all utilities and services (how would they update, work, configure etc) and I don't feel like doing it at all. And yes, I'm fine with ipfw.


----------



## SirDice (Dec 13, 2011)

eeluve said:
			
		

> Could someone link me to a good how-to manual on using two channels?


What exactly do you mean by "two channels"?

This is the most likely explanation:
Handbook: 32.6 Link Aggregation and Failover


----------



## eeluve (Dec 14, 2011)

That is absolutely not my case. Two external interfaces connected to what rc.conf calls "defaultrouter"s, only one at a time. FreeBSD simply does not allow me to use two at the same time, if link is lost on one maybe but not balancing. On Linux distros it's much easier but I dont feel like changing my whole gateway to say Gentoo. And my routers are not Cisco, nor HP or some of those you usually config for vlan. I'm sure someone done that on pre 8.2 without packet filter, if so please throw me something.


----------



## SirDice (Dec 14, 2011)

eeluve said:
			
		

> 2 external interfaces connected to what rc.conf calls "defaultrouter"s, only 1 at a time. BSD simply does not allow me to use 2 at the same time, if link is lost on one maybe but not balancing.


Use the fail-over mode of lagg(4).


----------



## eeluve (Dec 14, 2011)

Mate, excuse me if I am maybe wrong. But failover connects my "backup" router only in case "main" one does not get link. And I don't want this, I want them both to balance traffic between each other at the same time.


----------



## SirDice (Dec 14, 2011)

eeluve said:
			
		

> Mate, excuse me if i am maybe wrong. But failover connects my "backup" router only in case "main" one does not get link. And i dont what this, i want them both to balance traffic between eachother at the same time.



Then use the lagg(4) interface to aggragate/load-balance the interfaces.



> *loadbalance*
> Balances outgoing traffic across the active ports based on hashed protocol header information and accepts incoming traffic from any active port.  This is a static setup and does not negotiate aggregation with the peer or exchange frames to monitor the link.  The hash includes the Ethernet source and destination address, and, if available, the VLAN tag, and the IP source and destination address.


----------



## eeluve (Dec 15, 2011)

Have you ever done that yourself? You would need routers to be configured on the "other" side, that is not possible at all, and mostly used for router-to-router aggregation. I mean, maybe that's me, maybe I can't understand how this should be done one-sided, but doesn't seem so.


----------



## SirDice (Dec 15, 2011)

eeluve said:
			
		

> Have you ever done that yourself?


Yes.



> You would need routers to be configured on the "other" side, that is not possible at all, and mostly used for router-to-router aggregation. I mean, maybe that's me, maybe I can't understand how this should be done one-sided, but doesn't seem so.


No, you can even use lagg(4) to automatically switch from wireless to wired network. See example 32-3 of the handbook.


----------



## eeluve (Dec 15, 2011)

Still not clear. Is it possible to say:
[cmd=]# ifconfig lagg0 up laggproto loadbalance laggport igb0(my1st inc) laggport igb1(2nd inc)[/cmd]

and this is going to work, just like that? What about rc.conf settings? What IP will this lagg interface get and how? Should I comment defaultrouter there or uncomment my "backup" defaultrouter and add lagg0 as my only inet? Or, I don't get how this is going to work seriously. Could you if possible write a little more about it? I do read all the links you give me.


----------



## silicium (Dec 26, 2011)

Is lagg(4) useful at all as it works at link level, while dual WAN load balancing takes place at network level? Or is what you call 'load balancing' just dynamic traffic shaping like dispatching some new connections to the second router when one bandwidth trigger has been reached on the first one?


----------



## eeluve (Dec 27, 2011)

SirDice tips were useless m8. Im done with PBR and ipfw. Dont use lagg - my suggestion, unless you got cisco, hp routers, on the short hand with your ISP and both your channels are of the same type.


----------



## aragon (Dec 27, 2011)

Set one default route in rc.conf, and use an ipfw fwd rule with a 0.5 match probability to your other gateway.


----------



## eeluve (Dec 28, 2011)

Yeah, this one is nice too, haven't thought of it. Though divert both channels dancing with the subnets allows for more precise balancing. Sometimes you get, say, some bank who allows connections only through unseparate interface with certain ports and stuff. By the way, hope no one will delete this part, why when I'm */etc/netrestart*ing through ssh remotely everything goes down? Whatever changes are done to rc.conf and without any. When locally of course it's fine.


----------

