0

I'm looking to set up an emulator so that its emulated Ethernet interface acts like a real one connected to my LAN. For this example, I'm going to use the address 192.168.120.6 for the Linux host on which the emulator runs, and 192.168.120.19 for the emulator. (For the curious, the emulator will be Hercules with a QETH adapter running in layer 2 mode, so it'll use a TAP interface.) I want any packet from the real wire to go to the emulator, and any packet the emulator sends to go to the wire. I also want to be able to connect to the emulator from the host it's running on.

This seems like a job for a TAP device and a bridge. So, I created a persistent TAP interface with tunctl and told the emulator to use it. Then I created a bridge with brctl addbr br0, added both the TAP device and the Ethernet device to it with brctl addif br0 tap0 and brctl addif br0 enp4s0, and life should be good, right?

There's only one problem: when I do the brctl addif br0 enp4s0, my routing table gets screwed up and I can't communicate on the real wire any more. There are default routes and routes to the gateway on both the real interface and the bridge, and now the kernel can't decide where to send the frames to the LAN.

I'm not looking for routing here. I want a layer 2 bridge, and the emulated machine to do its own ARPing just like a real computer would. The kernel's routing table shouldn't even get involved. Where am I going wrong?

Edit: The host computer is a System76 Oryx Pro running Pop!_OS 20.10 (an Ubuntu derviative). Eventually, I also want to do this on a Raspberry Pi running the system formerly known as Raspbian. I use whatever the default network configuration packages on those systems are, but am willing to install others if that's needed to make it work - but I'd rather use the existing stuff.

Edit 2 As requested:

(2061) jmaynard@wakko:/etc$ systemctl status systemd-networkd
● systemd-networkd.service - Network Service
     Loaded: loaded (/lib/systemd/system/systemd-networkd.service; disabled; ve>
     Active: inactive (dead)
TriggeredBy: ● systemd-networkd.socket
       Docs: man:systemd-networkd.service(8)
(2062) jmaynard@wakko:/etc$ systemctl status NetworkManager
● NetworkManager.service - Network Manager
     Loaded: loaded (/lib/systemd/system/NetworkManager.service; enabled; vendo>
     Active: active (running) since Thu 2021-02-04 15:02:50 CST; 1h 14min ago
       Docs: man:NetworkManager(8)
   Main PID: 889 (NetworkManager)
      Tasks: 3 (limit: 38216)
     Memory: 15.7M
     CGroup: /system.slice/NetworkManager.service
             └─889 /usr/sbin/NetworkManager --no-daemon

Feb 04 15:02:54 wakko NetworkManager[889]: <info>  [1612472574.8311] dhcp6 (enp>
Feb 04 15:02:54 wakko NetworkManager[889]: <warn>  [1612472574.8312] device (en>
Feb 04 15:03:02 wakko NetworkManager[889]: <info>  [1612472582.6467] agent-mana>
Feb 04 15:03:34 wakko NetworkManager[889]: <info>  [1612472614.5986] policy: se>
Feb 04 15:03:47 wakko NetworkManager[889]: <info>  [1612472627.4148] policy: se>
Feb 04 15:13:53 wakko NetworkManager[889]: <info>  [1612473233.0786] policy: se>
Feb 04 15:15:20 wakko NetworkManager[889]: <info>  [1612473320.4621] policy: se>
Feb 04 15:16:02 wakko NetworkManager[889]: <info>  [1612473362.0738] policy: se>
Feb 04 15:54:40 wakko NetworkManager[889]: <info>  [1612475680.1599] agent-mana>
Feb 04 16:11:37 wakko NetworkManager[889]: <info>  [1612476697.9046] policy: se>
(2063) jmaynard@wakko:/etc$ nmcli
enp4s0: connected to Wired connection 1
        "Realtek RTL8111/8168/8411"
        ethernet (r8169), 80:FA:5B:66:A7:72, hw, mtu 1500
        ip4 default, ip6 default
        inet4 192.168.120.6/24
        inet4 192.168.120.132/24
        route4 192.168.120.0/24
        route4 0.0.0.0/0
        inet6 2001:48f8:7032:13a:7c00:8452:ce3f:9534/64
        inet6 2001:48f8:7032:13a:9a29:6d38:c636:307/64
        inet6 2001:48f8:7032:13a:ad68:dad3:227a:b804/64
        inet6 2001:48f8:7032:13a:3adb:958b:61fb:82db/64
        inet6 fe80::ea05:da80:dfa4:2978/64
        route6 2001:48f8:7032:13a::/64
        route6 ::/0
        route6 2001:48f8:7032:13a::/64
        route6 fe80::/64
        route6 fe80::/64
        route6 ::/0
        route6 ff00::/8

wlp3s0: unavailable
        "Intel 8265 / 8275"
        wifi (iwlwifi), 74:70:FD:F2:0C:B0, sw disabled, hw, mtu 1500

lo: unmanaged
        "lo"
        loopback (unknown), 00:00:00:00:00:00, sw, mtu 65536

DNS configuration:
        servers: 192.168.120.1
        interface: enp4s0

        servers: 2001:48f8:7032:13a:21b:78ff:fec3:851e
        domains: conmicro.com
        interface: enp4s0

Use "nmcli device show" to get complete information about known devices and
"nmcli connection show" to get an overview on active connection profiles.

Consult nmcli(1) and nmcli-examples(7) manual pages for complete usage details.
(2064) jmaynard@wakko:/etc$ 

I don't know why there's that extra IP address on enp4s0. dhcpcd feels compelled to try to get an address for it even though I have DHCP turned off for that interface. So far, it has resisted all attempts to get rid of it.

1
  • 1
    In the end you should first have a host system working correctly with an IP on the bridge instead of on the real ethernet interface now acting as bridge port. Then once this works, proceed to the emulation/tap part.
    – A.B
    Feb 6 at 16:04
-1

Firstly, it is quite important to decide what network manager to use. For example on Debian, you can use systemd-networkd, networking and NetworkManager. These tools are generally not mutually exclusive but while manipulating multiple interfaces using different tools you have to be careful and specify which tool manages certain interfaces.

NetworkManager comes with command line tools nmcli and nmtui. The latter one enables you to set up interfaces in a user-friendly environment.

I am not sure how Hercules works, but you can try to set up macvtap, so that the virtualized environment has access to the physical adaptor. Such an approach would not provide a link between the host and Hercules. For this purpose, you may create an isolated local network where you plug both host and Hercules.

You can find more about macvatap at RedHat site.

If you share further details, such as the system you are running or network tools you use, we might be able to provide a more detailed guide.

Edit: Since we gained new piece of information -- the system is Pop! -- it seems you can achieve the network setup using systemd-networkd configuration files. The idea seems correct. The only problem I see is that you picked tools like brctl from networking while using system with deployed systemd-networkd. You can of course use both network systems but without proper care you may end up with colliding configuration.

Edit 2: brctl is part of "the old network system" called networking. Basically, there are several network toolkits that enable you to set up networks in Linux. I have already mentioned networking, NetworkManager and systemd-networkd. Unless you are sure you know how to combine them, try to keep all the setup within one type of network tools.

I should have written "what kind of network tools your system uses"; quite clearly you used brctl...

8
  • Actually, Pop!_OS uses NetworkManager. I had no more success using its facilities to do the configuration. I'm pretty sure the problem is in the configuration I'm setting up, not the tools I'm using to get there. Feb 4 at 19:14
  • That is true. I actually somehow assumed you might be equipped with NM. The problem is that brctl comes from networking. The tools actually matter. I know it seems confusing but each networking system has its inherent tools. Feb 4 at 19:38
  • All network systems run as a service. If you do not mind trying yourself it is very instructive to just pick one of these and turn off the others. Try to set up basic networking for your computer. Then try to add a bridge etc. You can save great deal of time knowing that the services do not interfere. Problems only arise from misconfiguration. I'd use systemd.networkd. Feb 4 at 19:45
  • I used brctl because that's what the documents I saw on how to set it up used. Even so, doing the equivalent configuration with nmctl didn't work either, with the same failure. Again, the problem appears to be in the configuration, not which tool I use to set it up. Feb 4 at 20:10
  • Could you add output of these command: systemctl status systemd-networkd (prints whether systemd-networkd is active or not) systemctl status NetworkManager (print the activity of NetworkManager) nmcli (returns list of connections from NetworkManager). Feb 4 at 21:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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