Configure 2 gateways on a freebsd box for 2 interfaces
on at cs.ait.ac.th
Thu Sep 11 03:02:07 UTC 2008
> The first interface 192.168.0.1 255.255.255.0
> The second interface: 10.228.44.1 255.255.255.0
> The gateway for the first interface must be 192.168.0.254 and the
> interface must be 10.228.44.254
> How can I configure them? In rc.conf we have just defaultrouter but
> we can't
> specify the interface.
There is no way to specify an interface with the default route.
If your default route is set to 192.168.0.254, then it will use the
first interface, if the default route is set to 10.228.44.1 it will
use the second interface.
Now you need to explain why you need to default route. That is more
routing issue than FreeBSD issue.
In the routing table, you set a list of destination networks and the
interface to use to access them.
The default route is used to reach all the destinationsthat are not
listed else where in the routing table.
Your routing table will contain the default information:
- to reach network 192.168.0.0/255.255.255.0 you go through the first
interface; no need for default route;
- to reach the network 10.228.44.0/255.255.255.0 you go through the
second interface; no need for default route;
- to reach the locakhost you go through interface lo0; no need for
You can use the route command to add more (many more) entries into
your routing table, and use the default route for everything else.
If your host is connected to two Internet sources (two ISPs for
example) and you want to add all the best routes for reaching ISP 1
and its clients through the first interface; and all the best routes
for reaching ISP 2 and its client through the second interface, then
you need to enable some routing protocol. And use the default route
for all everything else.
To see the routing table on your machine: netstat -r
More information about the freebsd-questions