Date: Wed, 10 Dec 2025 17:40:41 +0200 From: John Hay <john@sanren.ac.za> To: Peter Eriksson <pen@lysator.liu.se> Cc: "net@freebsd.org" <net@freebsd.org> Subject: Re: Is it possible to force packets to go over a loopback cable? Message-ID: <CAGv8uapkTxsOc4rCsEdimXmZR1SYZ%2BJW=BYF=CE-b7-dCF087A@mail.gmail.com> In-Reply-To: <3C76FF27-49A7-4C45-8E8F-51C1BBF3C6E0@lysator.liu.se> References: <3C76FF27-49A7-4C45-8E8F-51C1BBF3C6E0@lysator.liu.se>
index | next in thread | previous in thread | raw e-mail
[-- Attachment #1 --] Hi Peter, On Wed, 10 Dec 2025 at 16:25, Peter Eriksson <pen@lysator.liu.se> 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 [-- Attachment #2 --] <div dir="ltr"><div dir="ltr">Hi Peter,</div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Wed, 10 Dec 2025 at 16:25, Peter Eriksson <<a href="mailto:pen@lysator.liu.se">pen@lysator.liu.se</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">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 :-)<br> <br> I’ve found references that back in the pre-FreeBSD 10 days there used to exist a sysctl:<br> <br> net.link.ether.inet.useloopback<br> <br> that could be set to 0 to disable this internal shortcut and force the packets out onto the cable…<br> <br> Any suggestions? :-)<br> <br> - Peter<br></blockquote><div><br></div><div>You can use a jail + vnet. There are examples in this pdf:</div><div><a href="https://freebsdfoundation.org/wp-content/uploads/2020/03/Jail-vnet-by-Examples.pdf">https://freebsdfoundation.org/wp-content/uploads/2020/03/Jail-vnet-by-Examples.pdf</a></div><div><br></div><div>I do something similar. There are basically 3 steps. Create the vnet capable jail, move the interface inside, configure the address(es).</div><div><br></div><div>Here is one half of it:</div><div>########</div><div>if1="mce0"<br>if1_jail_name="via_mce0"<br>if1_ip="<a href="http://10.0.0.1/24">10.0.0.1/24</a>"<br>if1_testip="10.0.0.2"</div><div>jail -i -c name=${if1_jail_name} host.hostname=${if1_jail_name} vnet persist</div><div>ifconfig ${if1} vnet ${if1_jail_name}</div><div>jexec ${if1_jail_name} ifconfig ${if1} ${if1_ip}</div><div><br></div><div># Check by pinging the other side<br>echo jexec ${if1_jail_name} ping -c 3 ${if1_testip}<br>jexec ${if1_jail_name} ping -c 3 ${if1_testip}<br>#########</div><div><br></div><div></div><div>John</div><div><br></div><div><br></div></div></div>help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAGv8uapkTxsOc4rCsEdimXmZR1SYZ%2BJW=BYF=CE-b7-dCF087A>
