Re: Is it possible to force packets to go over a loopback cable?

John Hay <[email protected]>
Newsgroups gmane.os.freebsd.devel.net
Message-ID <CAGv8uapkTxsOc4rCsEdimXmZR1SYZ+JW=BYF=CE-b7-dCF087A@mail.gmail.com>
Hi Peter,

On Wed, 10 Dec 2025 at 16:25, Peter Eriksson <[email protected]> wrote:

> I’d like to find some way to force FreeBSD to send a stream of packet over
> a loopback cable connected between two ethernet ports on the same machine,
> but it seems FreeBSD also short-circuits it and handles that traffic
> internally in the OS. Which normally is a good thing for speed, but bad
> when you are trying to test suspect cables :-)
>
> I’ve found references that back in the pre-FreeBSD 10 days there used to
> exist a sysctl:
>
>   net.link.ether.inet.useloopback
>
> that could be set to 0 to disable this internal shortcut and force the
> packets out onto the cable…
>
> Any suggestions? :-)
>
> - Peter
>

You can use a jail + vnet. There are examples in this pdf:
https://freebsdfoundation.org/wp-content/uploads/2020/03/Jail-vnet-by-Examples.pdf

I do something similar. There are basically 3 steps. Create the vnet
capable jail, move the interface inside, configure the address(es).

Here is one half of it:
########
if1="mce0"
if1_jail_name="via_mce0"
if1_ip="10.0.0.1/24"
if1_testip="10.0.0.2"
jail -i -c name=${if1_jail_name} host.hostname=${if1_jail_name} vnet persist
ifconfig ${if1} vnet ${if1_jail_name}
jexec ${if1_jail_name} ifconfig ${if1} ${if1_ip}

# Check by pinging the other side
echo jexec ${if1_jail_name} ping -c 3 ${if1_testip}
jexec ${if1_jail_name} ping -c 3 ${if1_testip}
#########

John
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.