Question: How to add multiple gateways to a FreeBSD?
Answer: No you can not do this (at least directly) on FreeBSD. FreeBSD don't support multiple gateways.
Workaround solution: If you have a server with 2 set of IPs and each set have there own gateway.
- First, you must select one of the gateway to be a default gateway.
- Then, You need ipfw (or any FreeBSD firewall solution),
Check that your kernel support ipfw, if not, recompile your kernel with the following options(IPDIVERT and DUMMYNET is not required, but if you add IPFW/IPFW2 it better to also add these two options)#Firewall & NAT & DummyNet
add the following rule to your ipfw rules set.
options IPFIREWALL
options IPDIVERT
options IPFIREWALL_DEFAULT_TO_ACCEPT
options IPFIREWALL_VERBOSE
options IPFIREWALL_VERBOSE_LIMIT=100
options DUMMYNET
options IPFW2ipfw add rule_no fwd second_gateyway_ip ip from ip_of_this_gateway to not me
For example, I have 2 ip set (10.0.0.100,10.0.0.101,10.0.0.102 for gateway 10.0.0.254) and (192.168.0.77,192.168.0.78 for gateways 192.168.0.254). I chose 10.0.0.254 as the default gateway. So, my ipfw rules areipfw add 100 fwd 192.168.0.254 ip from 192.168.0.77 to not me
ipfw add 110 fwd 192.168.0.254 ip from 192.168.0.78 to not me
No comments:
Post a Comment