Hello,
I've fairly recently stepped into the FreeBSD world after being a long time Linux user. I'm running into a problem that I've managed to solve in my Linux servers but I can't seem to figure it out on the FreeBSD machines, running FreeBSD 10.1.
So the servers all have two interfaces, one has ip 10.4.32.12 on the network 10.4.32.0/25 and the other has ip 192.168.16.12 on the network 192.168.16.0/20. On each network there are routers (10.4.32.1 and 192.168.16.1) that connect to other networks, currently the default route is 192.168.16.1.
The problem arises when I connect to the 10.4.32.12 address from the outside (another 10. network), I successfully reach the server, but it's replies go out the default route to 192.168.16.1 and never reach me, I can see the incoming packets on the 192.168.16.1 router.
So how do I configure FreeBSD to send traffic from ip address 10.4.32.12 through the default gw 10.4.32.1 ? On my Linux boxes I would set up 2 routing tables, one for each default gateway, then I can say:
I've seen quite a few threads on these forums, but for some reason I can't seem to get the suggestions to work for me. I recompiled the kernel to support multiple routing tables (options ROUTETABLES=16). Relevant configurations are as follows:
Related threads:
- http://daemonforums.org/showthread.php?t=4610
- https://forums.freebsd.org/threads/...d-routing-ipfw-configuration-for-jails.42112/
- https://forums.freebsd.org/threads/two-default-routes-and-vlans.37900/
Am I missing something obvious? Any hints are appreciated! Thank you.
I've fairly recently stepped into the FreeBSD world after being a long time Linux user. I'm running into a problem that I've managed to solve in my Linux servers but I can't seem to figure it out on the FreeBSD machines, running FreeBSD 10.1.
So the servers all have two interfaces, one has ip 10.4.32.12 on the network 10.4.32.0/25 and the other has ip 192.168.16.12 on the network 192.168.16.0/20. On each network there are routers (10.4.32.1 and 192.168.16.1) that connect to other networks, currently the default route is 192.168.16.1.
The problem arises when I connect to the 10.4.32.12 address from the outside (another 10. network), I successfully reach the server, but it's replies go out the default route to 192.168.16.1 and never reach me, I can see the incoming packets on the 192.168.16.1 router.
So how do I configure FreeBSD to send traffic from ip address 10.4.32.12 through the default gw 10.4.32.1 ? On my Linux boxes I would set up 2 routing tables, one for each default gateway, then I can say:
ip rule add from 10.4.32.12 table alternate_routing_table
I've seen quite a few threads on these forums, but for some reason I can't seem to get the suggestions to work for me. I recompiled the kernel to support multiple routing tables (options ROUTETABLES=16). Relevant configurations are as follows:
Code:
root@storage:~ # cat /boot/loader.conf
ipfw_load="YES"
net.fibs=16
root@storage:~ # sysctl net.fibs
net.fibs: 16
Code:
root@storage:~ # cat /etc/rc.conf # cut out irrelevant things
ifconfig_vmx0="inet 192.168.16.12 netmask 255.255.240.0"
ifconfig_vmx1="inet 10.4.32.12 netmask 255.255.255.128"
defaultrouter="192.168.16.1"
firewall_enable="YES"
firewall_script="/etc/rc.firewall"
firewall_type="open"
Code:
root@storage:~ # cat /etc/rc.local
#!/bin/sh
setfib 0 route delete default
setfib 0 route add default 192.168.16.1
setfib 1 route delete default
setfib 1 route add default 10.4.32.1
ipfw -f flush
ipfw add allow all from any to any via lo0
ipfw add setfib 1 ip from any to any via vmx1
ipfw add setfib 0 ip from any to any via vmx0
ipfw add allow ip from any to any
Code:
root@storage:~ # setfib 0 netstat -rn4
Routing tables
Internet:
Destination Gateway Flags Netif Expire
default 192.168.16.1 UGS vmx0
10.4.32.0/25 link#2 U vmx1
10.4.32.12 link#2 UHS lo0
127.0.0.1 link#3 UH lo0
192.168.16.0/20 link#1 U vmx0
192.168.16.12 link#1 UHS lo0
root@storage:~ # setfib 1 netstat -rn4
Routing tables (fib: 1)
Internet:
Destination Gateway Flags Netif Expire
default 10.4.32.1 UGS vmx1
10.4.32.0/25 link#2 U vmx1
127.0.0.1 link#3 UH lo0
192.168.16.0/20 link#1 U vmx0
- http://daemonforums.org/showthread.php?t=4610
- https://forums.freebsd.org/threads/...d-routing-ipfw-configuration-for-jails.42112/
- https://forums.freebsd.org/threads/two-default-routes-and-vlans.37900/
Am I missing something obvious? Any hints are appreciated! Thank you.