# How does FreeBSD routing code take port speed into account



## swtools (Dec 20, 2010)

I know that ifconfig allows a user to set if_metric, but is there any FreeBSD user space application that will automate this, so that ports with high bandwidth will have a lower if_metric than ports with low bandwidth?  Or is there some other mechanism FreeBSD uses so that routes will prefer ports with high bandwidth?


----------



## SirDice (Dec 20, 2010)

swtools said:
			
		

> I know that ifconfig allows a user to set if_metric, but is there any FreeBSD user space application that will automate this, so that ports with high bandwidth will have a lower if_metric than ports with low bandwidth?


As far as I know, no. What if there are less hops behind the low bandwidth interface compared to the high bandwidth interface? Or the low bandwidth connection has less latency then the high bandwidth interface. That could make the low bandwidth interface faster then the higher one. Available bandwidth isn't the only thing that makes a connection fast.



> Or is there some other mechanism FreeBSD uses so that routes will prefer ports with high bandwidth?


Normally every route is treated the same, regardless of the interface metric. This will only come into play when using routing protocols like RIP. See routed(8).


----------



## swtools (Dec 20, 2010)

routed computes the route metric by summing the if_metric and the metric learned dynamically (from RIP). Actually you can add additional metrics to the dgateways file that become part of the sum, one for the inbound and one for the outbound path.  So routed is not a factor here, it supports the use of if_metric to identify a preferred interface.  The question remains, whether there are any user space applications that set if_metric based on port speed.


----------



## SirDice (Dec 21, 2010)

swtools said:
			
		

> The question remains, whether there are any user space applications that set if_metric based on port speed.


Nope. But it should be relatively easy to script something that does it.


----------

