$NetBSD: patch-doc_networking.html,v 1.1 2020/10/07 00:43:05 thorpej Exp $ Document tap(4)-based networking. --- doc/networking.html.orig 2020-10-05 22:53:41.969487340 +0000 +++ doc/networking.html 2020-10-05 22:54:17.309695478 +0000 @@ -46,6 +46,7 @@ SUCH DAMAGE.


@@ -60,9 +61,11 @@ SUCH DAMAGE.

Introduction:

-

GXemul's current networking layer supports two modes: +

GXemul's current networking layer supports three modes:

    +
  1. A vitual Ethernet switch built on top of a tap device. +

  2. A NAT-like layer, which allows guest OSes to access the outside internet world (IPv4 only, so far). When only one machine is being emulated, the following default values apply to the guest OS:
    @@ -78,7 +81,7 @@ SUCH DAMAGE.
     	ethernet packages from/to the emulator.
     
-

NOTE: Both these modes have problems. The NAT-like layer is very +

NOTE: The latter two modes have problems. The NAT-like layer is very "hackish" and was only meant as a proof-of-concept, to see if networking like this would work with e.g. NetBSD as a guest OS. (If you are interested in the technical details, and the reasons why NAT networking is @@ -120,6 +123,83 @@ href="machine_decstation.html#netbsdpmax +


+ +

Virtual Ethernet switch using a tap device:

+ +

The simplest way to emulate a real Ethernet network is using a tap +device. In this mode, the emulator disables the simulated NAT and +direct-access machinery and internally treats all emulated NICs as if +they are on a single Ethernet switch. In this mode, packets destined for +the guest's specific MAC address as well as Ethernet multicast and broadcast +packets are send to the individual guest instances. Individual NIC +emulations may also apply their own multicast filtering; multcast filtering +is implemented for the DEC 21143 and Lance NICs. + +

The tap interface on the host can be thought of as an upstream +link on the virtual Ethernet switch. In addition to providing a "port" +for the host, the tap interface can be bridged to a physical Ethernet +port on the host, allowing the guests to access the host's connected LAN. + +

Networking services such as DHCP and DNS must be provided either by +the host or by the host's connected LAN. + +

Support for the tap device was developed on NetBSD, but should +also work on FreeBSD, OpenBSD, and Linux hosts. + +

Here is a simple example: + +

+!  Configuration file for
+!  virtual Ethernet switch networking
+!  using a tap device.
+
+net(
+	tapdev("/dev/tap0")
+)
+machine(
+	name("guest machine")
+
+	type("dec")
+	subtype("5000/200")
+
+	!  Add a disk, etc.
+)
+
+ +

Before starting the emulator, you will need to create the tap +interface on the host. Here is an example for NetBSD: + +

+#ifconfig tap0 create up
+
+ +

If you wish to simply network the host and the guests together, then +simply assign an IP address to the tap interface on the host: + +

+# ifconfig tap0 10.0.0.254
+
+ +

You can now run a DHCP server on the host for the guests, or you can +configure the guests manually. + +

If instead you would like to bridge to the host's connected LAN, +Here is an example for NetBSD: + +

+# ifconfig bridge0 create up
+# brconfig add tap0 add wm0
+
+ +

Although it is possible to have more than one machine per +configuration file, I strongly recommend against it. Please use one +configuration file for one emulated machine. Each configuration file +must have a unique tap instance, and machines in separate +configuration files must use bridged tap devices if they wish +to communicate with each other as if on the same LAN. + +