Re: How to force network packets across network instead of loopback

From: Frank Leonhardt <freebsd-doc_at_fjl.co.uk>
Date: Thu, 11 Sep 2025 10:27:34 UTC
On 11/09/2025 11:19, Sad Clouds wrote:
> On Thu, 11 Sep 2025 10:52:14 +0100
> Frank Leonhardt <freebsd-doc@fjl.co.uk> wrote:
>
>> I haven't tested this but like any sane OS it will optimise local
>> traffic this way unless you trick it. One way might be to assign
>> different subnets to each interface. Then add a route between them.
> Hi, thanks for the suggestion. I think I tried adding different subnets
> and also using multiple routing tables with setfib, but none of that
> seemed to work properly. I was trying to avoid using packet filters, as
> they probably add overhead and latency to network I/O paths.
>
> Then I setup several VNET jails, and that seems to force packets across
> the physical network. So I'll be using this method for performance
> testing.
>
> On Solaris this setup is quite easy, just enable symmetric routing:
>
> $ ipadm set-prop -p hostmodel=strong ipv4
> $ ipadm set-prop -p hostmodel=strong ipv6
>
> I was hoping for something similar on FreeBSD, but apart from
> net.inet.ip.rfc1122_strong_es which doesn't quite achieve the same
> effect, I could not find anything.

Linux has network namespaces, I believe, would be an obvious answer and 
I I was going to suggest jails to get a similar effect, but was less 
sure it would work.

Did you try setting up as I suggested and looking at the routing table? 
You can always delete any direct (link#x) routes it creates 
automatically. FreeBSD doesn't have the global configuration options 
like Solaris (as you know) so normally you need to tweak the routing 
tables to get what you want.