# 2 pieces defaultrouter



## bagas (Apr 24, 2019)

Hello.
My system FreeBSD 12.0-RELEASE amd64.
How do I set up my defaultrouter for network aliases?
now.

```
netstat -rn
Routing tables

Internet:
Destination        Gateway            Flags     Netif Expire
default            1.1.1.1       UGS        igb0
1.1.1.0/24    link#1             U          igb0
1.1.1.1     link#1             UHS         lo0
127.0.0.1          link#3             UH          lo0
```


```
ifconfig_igb0="inet 1.1.1.10 netmask 255.255.255.0"
ifconfig_igb0_alias0="inet 1.1.2.9 netmask 255.255.255.0"
ifconfig_igb0_alias1="inet 1.1.2.4 netmask 255.255.255.0"
defaultrouter="1.1.1.1"
```
For aliases(alias0-alias1), another defaultrouter="1.1.2.1" is needed.
How do I do better?


----------



## ondra_knezour (Apr 24, 2019)

AFAIK you are not able to specify multiple default routes (at the end it is the _one_ location where you send packets you can not route better), but you may have some luck with multiple routing tables, setfib(1) and multiple routing tables support in some programs, for example see nginx _setfib_ directive.


----------



## tommiie (Apr 24, 2019)

In Cisco parlance, that's called _policy-based routing_, where you route depending on the source IP address. By default your only route based on the destination IP address. Check out Thread policy-based-routing-on-freebsd.39758.


----------

