# How to set static routing



## pit (Nov 17, 2016)

How can I set  routing tables and routing rules for interfaces in FreeBSD 11?

Thanks


----------



## pit (Nov 18, 2016)

Is this a right way 
	
	



```
ifconfig_re0="-inet 192.168.0.1 netmask 0xffffff00 fib 1
 route add -net 192.168.0.0/24 192.168.0.1 -fib 1
```


----------



## SirDice (Nov 18, 2016)

Note, this has nothing to do with source routing. Source routing is a horrible security nightmare and most, if not all, routers simply ignore it.

What you're trying to do is just normal routing but using two or more different routing tables.


----------



## snark (Dec 1, 2016)

Try to insert in rc.conf(5) something like this

```
static_routes="foo bar"
route_foo="-host 172.16.0.100 192.168.0.1"
route_bar="-net 172.16.1.0/24 192.168.1.1"
```


----------



## SirDice (Dec 1, 2016)

pit said:


> ```
> ifconfig_re0="-inet 192.168.0.1 netmask 0xffffff00 fib 1 route add -net 192.168.0.0/24 192.168.0.1 -fib 1
> ```


Note that there's no need to add a route for 192.168.0.0/24 as it is an implied route because the interface is in that network.


----------

