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 09:52:14 UTC
On 10/09/2025 15:26, Sad Clouds wrote:
> Hello, I have two network interfaces ix0 and ix1 on the same FreeBSD
> host. When transferring data between those interfaces, is there a way
> to force FreeBSD to send and receive packets across the physical
> network, instead of using loopback? I'd like to use this for NIC
> hardware testing.
>
> I tried adding various static routes, but this does not seem to work.
>
> Thanks.

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.

e.g.
ifconfig ix0 inet 192.168.1.2/24
ifconfig ix1 inet 192.168.2.2/24
route add 192.168.2.0/24 192.168.1.1

Enable forwarding. You might also add a firewall rule to stop it:

ipfw add 100 deny ip from 192.168.1.2 to 192.168.2.2 via lo0 or (pf) 
block in on lo0 from 192.168.1.2 to 192.168.2.2

Another way might be to use a bridge.

Regards, Frank.