Configure different specific default routes, nameserver, searchdomains etc. for different networks, bound to different nics

freeBSDNew

New Member


Messages: 7

Hello,

sorry, if my question ist stupid.

I want to configure a freebsd-server, that has different nic's, bound to different networks.

For example

em0
- 10.0.1.0 / 24
- defaultrouter 10.0.1.1
- nameserver 8.8.8.8, a.a.a.a, ...
- search domain lan.home.arpa

em1
- 10.1.1.0 / 24
- defaultrouter 10.1.1.1
- nameserver b.b.b.b, c.c.c.c, ...
- search domain mngmt.home.arpa

em2
- 10.2.1.0 / 24
- defaultrouter 10.2.1.1
- search domain IoT.home.arpa

...

Is ist possible to define different / multiple networks persistent in rc.conf oder resolv.conf or otherwise?

I know, that I can define f. e, one defaultrouter in rc.conf. but what, if i need different routers for different networks, same with searchdomains and nameserver?

Thank you all.
 

cmoerz

Member

Reaction score: 37
Messages: 98

If your FreeBSD system is connected to those three LANs directly, wouldn't it already know about the routes? Do you want a DNS to resolve hostnames differently for systems on those LANs or what particular use case are you looking for?

If you are looking for a solution to do multiple uplinks, you could look at something like https://www.quagga.net/
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 12,357
Messages: 38,883

I know, that I can define f. e, one defaultrouter in rc.conf. but what, if i need different routers for different networks
There's always only one default gateway, that's the definition of a default gateway, it's the one that is used if no other (stricter) static or dynamic routes can be found. I like the definition Cisco uses; gateway of last resort. In other words, it's the gateway that's used if no other routes apply.

Additional static routes can be added like this:
Code:
static_routes="network1 network2"
route_network1="1.2.3.0/24 10.0.0.1"
route_network2="2.3.4.0/24 10.0.0.2"

Note that directly connected networks will already have an implied route. You can check your routing table with netstat -rn. And don't forget to enable routing by adding gateway_enable="YES" to /etc/rc.conf.
 

Zirias

Son of Beastie

Reaction score: 1,578
Messages: 2,705

Wouldn't this thread be related?
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 12,357
Messages: 38,883

I have something like "-net 1.2.3.0/24 10.0.0.1" in those assignments. Is -net optional? I can't make it out from /etc/rc.d/routing.
It just executes route(8) with the value as arguments.
 
Top