I'm looking for a network interface simulator, that offers both ends of a network on a single machine (particularly for UDP).

The way com0com works for serial ports, but simulating a network card instead of a serial port.

Is this behavior possible by using the existing network stack in a creative way? (Port forwarding or some such?) Or some creative configuration of OpenVPN, L2TP/IPSec, SoftEther, PPTP, etc.?

I have software I can't change, that binds to certain UDP ports and sends outgoing messages on those same ports. I'd like to intercept and route those messages, but I can't bind to those same ports myself since that software is already binding to them.

2 Answers 2


First off, you actually already have one on pretty much every platform that has a network interface. It's called the loopback interface, and it's actually one of the fastest ways you can do this type of thing. By default, this provides one address for the whole system, but on many platforms, but if you're using IPv4 you can add multiple addresses out of the block, and it will generally work correctly (you unfortunately can't do this with IPv6, as there is only one address reserved there for loopback usage).

There are multiple alternative options out there though, depending on what system you're running on:

  • Software bridge interfaces. On many UNIX systems, you can create ethernet bridges in software to provide transparent bridging between multiple physical interfaces. On most such systems, you don't actually have to bind any physical interfaces to them, and can just use the bridges as private internal network interfaces.
  • Linux provides a special driver that can be used to do literally exactly what you're asking for. The virtual devices it provides are known as 'virtual ethernet pair devices'. Using this driver, you get two network interfaces which simulate an (near-zero latency) Ethernet link.
  • Many operating systems that have a modern networking stack provide a special type of network interface allows an application to provide basic network emulation. On most systems, these are known as tun and tap interfaces (the difference is what layer they are emulating), and they're used for a wide variety of things, from VPN interfaces to network emulation for virtual machines.
  • A bit unconventional, but you already mentioned serial emulation software so I'll mention it here: You could run PPP or SLIP over the emulated serial link. This might actually be one of the best options, as it should prevent any optimizations by the OS that might interfere with the routing you want to do.
  • As Lucio Crusca mentioned, you could use a virtual machine for this, although I'd argue that that's probably overkill on most systems (except Windows, because doing complicated networking things there is a pain in the arse).
  • VDE, also known as Virtual Distributed Ethernet, might work for what you need. It's mostly designed for providing an emulated ethernet network to virtual machines that are located physically far from each other, but it can operate locally too.
  • Open vSwitch, another virtualization oriented technology, may similarly be of use to you.
  • Thanks for the batch of great ideas! A network stack native solution like would be awesome: know of a how-to for it? I'm a little familiar with tun and tap from OpenVPN: can we get at that in some native way? (My most immediate concern is Windows, I'll update my Q's tag.)
    – JimB
    Nov 10, 2018 at 15:10
  • Here's something on using OpenVPN's tun driver by itself, which seems not to work for what they're trying, but it's not clear if it would work for UDP.
    – JimB
    Nov 12, 2018 at 10:45
  • I think that you can do the same things as the tun and tap drivers on Windows using natively built drivers (this is what most VM offerings on Windows do), but it's a lot more effort. Nov 12, 2018 at 15:16

You didn't tell what OS you are using, anyway it's always possible to install a virtual machine (VirtualBox on Windows, qemu/KVM on Linux for example) and install your software into that.

From there you have a whole virtual network where you can add all kinds of virtual routers you need.

  • Thanks! I considered a VM, but it's pretty heavyweight for just the ethernet driver, and having it fire up on machine start, then start our software, seems like kind of a lot.
    – JimB
    Nov 10, 2018 at 13:51
  • If you compare it to the hassle of setting up virtual interfaces under Windows, you probably are better off with virtualization. BTW, starting a VM upon boot is quite straightfoward with VirtualBox or any other virtualization system, the same is true for your software into the VM... Nov 10, 2018 at 21:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.