# Default Route Question



## mlager (May 13, 2012)

I have a FreeBSD host that has two network cards. I've placed one public IP on bge0 and another public IP on the same subnet on bge1. It looks like this, I've masked my public IP addresses as 172.16.0.0

bge0: 172.16.0.100
bge1: 172.16.0.101

The default route is 172.16.0.1. When I issue a *netstat -rn*, the default route appears on the be0 interface.

I've created a jail and bound it to 172.16.0.101. I'm also graphing the traffic on both interfaces. What's interesting is traffic inbound to 172.16.0.101 shows on the bge1 interface but traffic outbound from 172.16.0.101 shows on the bge0 interface. Is this because the default route is attached to bge0? The only reason I put the additional IP on the second interface is because I wanted to graph its traffic separatly from the other IP.

Any advice would be appreciated.


----------



## DutchDaemon (May 13, 2012)

You can't put two IPs from the same subnet on two different interfaces (*). You observed what will happen. You can put the second IP as an alias with a /32 netmask on the same interface. Whether that would be 'graph-able', I don't know.

(*) perhaps with elaborate route statements and firewall and binding rules, but that would be more trouble than it's worth, if at all feasible.


----------



## mlager (May 13, 2012)

Interesting, good to know. If I put a public IP on the second interface that had a DIFFERENT subnet, would it still have to route through the default route on bge0, or can I specify a default route for bge0 and another default route for bge1? I.E. bge0 was plugged into one Internet connection and bge1 was plugged into a separate Internet connection?


----------



## bbzz (May 13, 2012)

Yes, it's called dual-homing. You could have connections to one service provider only, to different providers, use one link as a backup only or both for load-sharing, etc. It's cost of route (usually) that determines which link is used.

I'm not sure how FreeBSD handles this (multiple default routes), but it's easy to setup load-sharing with *pf*.


----------



## mlager (May 13, 2012)

Does anyone have a dual homing example? My understanding is that only one default route can exist on a given system... So bge0 would have the default route. So once I configure the other subnet on bge1, how do I tell the system to route traffic to or from the IP on bge1 through a gateway other than the default?


----------



## bbzz (May 13, 2012)

bbzz said:
			
		

> ...but it's easy to setup load-sharing with pf.


pf.


----------



## DutchDaemon (May 14, 2012)

See http://www.freebsd.org/doc/handbook/network-routing.html and possibly setfib(1) / setfib(2) (setfib allows you to set specific routing tables for specific applications).


----------

