Setting v6 Route Cost Metrics (default gateway)

I have two IPv6 tunnels. One to SixXS.net and the other to HE.net. As you know, a default route must be set (route -n add -inet6 default <remote_gateway_addr>).

What I'm looking for, is if there is a way to set a Cost Metric on a default route? Working with Cisco routers, I know you can set cost metrics on routes, but I'm not aware if that is possible in the FreeBSD OS.

My goal is to have the HE.NET tunnel be the primary default. If that tunnel dies, traffic will flow via the SixXS tunnel which is secondary.
 
SirDice said:
You can add a metric to the route(8) command but as far as I know FreeBSD itself doesn't use it.

I would start looking at lagg(4) (failover mode): Handbook: 32.6 Link Aggregation and Failover.


Hmmmm, I'm not sure lagg(4) would work, since that gets into link aggregation of doubling your bandwidth by adding in links. Thus, you would need 2+ links from the same provider for that to work.

As for a metric using route(8), would you have an example? I'm not able to find one in the manpage.
 
AlbyVA said:
Hmmmm, I'm not sure lagg(4) would work, since that gets into link aggregation of doubling your bandwidth by adding in links. Thus, you would need 2+ links from the same provider for that to work.
Not in failover mode. Look at the example covering automatic switching between wired and wireless. In your case you'd switch from one IPv6 provider to another.
 
bbzz said:
Would
# ifconfig metric <n>
under respective tunnel interface(s) work?



Hmmmm, now that I think about it. This just puts a cost on the interfaces and not the routes. It might work, but are you aware of being able to set a (route) metric in some way?

Thanks,
 
SirDice said:
Not in failover mode. Look at the example covering automatic switching between wired and wireless. In your case you'd switch from one IPv6 provider to another.



Thanks. I see it now. Let me read down a little further, :)
 
SirDice said:
Not in failover mode. Look at the example covering automatic switching between wired and wireless. In your case you'd switch from one IPv6 provider to another.



I just had an interesting thought. For the failover to work, the interface has to go go down, correct? But with a tunnel, does the interface remain up in ifconfig even when the far end of the tunnel might be dead? As such, there is no way for failover to work since the system things the link-state is still active. Whereas with physical interfaces, when they go dead, that death is reflected in the port stats that ifconfig sees.
 
AlbyVA said:
Hmmmm, now that I think about it. This just puts a cost on the interfaces
and not the routes. It might work, but are you aware of being able to set a
(route) metric in some way?


Thanks,

Yeah I figured that won't work. Even on Cisco routers you change administrative distance, not metric for static routes, e.g [cmd=]ip route 0.0.0.0 0.0.0.0 tunnel0 10[/cmd] but I don't think FreeBSD has this, weird.
 
AlbyVA said:
I just had an interesting thought. For the failover to work, the interface has to go Down, correct? But with a Tunnel, does the interface remain Up in ifconfig even when the far end of the tunnel might be dead? As such, there is no way for failover to work since the system things the link-state is still active. Whereas with physical interfaces, when they go dead, that death is reflected in the port stats that ifconfig sees.
Yes, you may be right. I'm not sure what tunnels you have but it's possible the tunnel stays up even if there's no data going through it.

In that case I'm afraid you have to resort to a script that's periodically fired off. Ping one of the tunnel end-points and if that fails change the default gateway to the other tunnel.
 
SirDice said:
Yes, you may be right. I'm not sure what tunnels you have but it's possible the tunnel stays up even if there's no data going through it.

In that case I'm afraid you have to resort to a script that's periodically fired off. Ping one of the tunnel end-points and if that fails change the default gateway to the other tunnel.

Hmmmm, yeah, I think you might be right. I already have a script that runs pings to verify the tunnel and send me an email to my cellphone when it's dead. Doing one which does a quick route delete/route add might be the best option.

Got any samples for a Level0 scripting guy that might mesh with this script to add/delete routes for a failover?

Code:
#!/bin/sh
HOSTS="<v6_addr>"
COUNT=4
for myHost in $HOSTS
do
  count=$(/sbin/ping6 -c $COUNT $myHost | grep 'received' | awk -F',' '{ print $2 }' | awk '{ print $1 }')
  if [ $count -eq 0 ]; then
    # 100% failed 
    echo "Host : v6 Tunnel is down (ping failed) at $(date)" | /usr/bin/mail <email_addr>
  fi
done
 
Back
Top