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: <info> [1612472574.8311] dhcp6 (enp> Feb 04 15:02:54 wakko NetworkManager: <warn> [1612472574.8312] device (en> Feb 04 15:03:02 wakko NetworkManager: <info> [1612472582.6467] agent-mana> Feb 04 15:03:34 wakko NetworkManager: <info> [1612472614.5986] policy: se> Feb 04 15:03:47 wakko NetworkManager: <info> [1612472627.4148] policy: se> Feb 04 15:13:53 wakko NetworkManager: <info> [1612473233.0786] policy: se> Feb 04 15:15:20 wakko NetworkManager: <info> [1612473320.4621] policy: se> Feb 04 15:16:02 wakko NetworkManager: <info> [1612473362.0738] policy: se> Feb 04 15:54:40 wakko NetworkManager: <info> [1612475680.1599] agent-mana> Feb 04 16:11:37 wakko NetworkManager: <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
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.