15. Networking using DOSEMU

15.1. Direct NIC access

The easiest (and not recommended) way to set up the networking in DOSEMU is to use the direct NIC access. It means that DOSEMU will exclusively use one of your network interfaces, say eth0. No other processes will be able to use that interface. If they try to, the data exchange will became unreliable. So you have to make sure that this network interface is not used by anything including the kernel itself, before starting DOSEMU. The settings for this method are as follows:

    $_pktdriver = (on)
    $_netdev = "eth0"
    $_vnet = "direct"
Note that this method requires root privileges.

As you can see, this simple method has many shortcomings. If you don't have the network card dedicated specially for dosemu, consider using more advanced method called "Virtual Networking".

15.2. Virtual networking

Virtual networking is a mechanism that allows to overcome all the limitations of the direct NIC access method, but it requires more work to set up everything properly. A special virtual network devices can be created using TUN/TAP interface. This will enable multiple dosemu sessions and the linux kernel to be on a separate virtual network. Each dosemu will have its own network device and ethernet address.

First make sure that your Linux kernel comes with support for TUN/TAP; for details check Documentation/networking/tuntap.txt in the Linux kernel source. The user who runs DOSEMU should have read/write access to /dev/net/tun. Then either:

  1. Set

        $_vnet = "tap"
        $_netdev = ""

    Start DOSEMU as usual and configure the network device while DOSEMU is running (using ifconfig manually as root, a script, or usernetctl if your distribution supplies that), e.g.

        ifconfig tap0 up

    Configure the DOS TCP/IP network clients to have another IP address in the subnet you just configured. This address should be unique, i.e. no other dosemu, or the kernel, should have this address. For the example addresses given above, would be good. Your network should now be up and running and you can, for example, use a DOS SSH client to ssh to your own machine, but it will be down as soon as you exit DOSEMU.

  2. Or set

        $_vnet = "tap
        $_netdev = "tap0"

    Obtain tunctl from the user mode linux project. Then set up a persistent TAP device using tunctl (use the -u owner option if you do that as root). Configure the network using ifconfig as above, but now before starting DOSEMU. Now start DOSEMU as often as you like and you can use the network in the same way as you did above.

    Note, however, that multiple DOSEMU sessions that run at the same time need to use multiple tapxx devices. $_netdev can be changed without editing dosemu.conf/~./dosemurc (if you leave it commented out there) by using [x]dosemu -I "netdev tap1".

With the above you did set up a purely virtual internal network between the DOSEMU and the real Linux box. This is why in the above example should *not* be a real IP address of the Linux box, and the 192.168.74 network should not exist as a real network. To enable DOS programs to talk to the outside world you have to set up Ethernet bridging or IP routing.

15.2.1. Bridging

Bridging, using brctl (look for the bridge-utils package if you don't have it), is somewhat easier to accomplish than the IP routing. You set up a bridge, for example named "br0" and connect eth0 and tap0 to it. Suppose the Linux box has IP on eth0, where 192.168.1.x can be a real LAN, and the uid of the user who is going to use DOSEMU is 500, then you can do (as root):

    brctl addbr br0
    ifconfig eth0 promisc up
    brctl addif br0 eth0
    ifconfig br0 netmask up
    tunctl -u 500
    ifconfig tap0 promisc up
    brctl addif br0 tap0
Now the DOSEMU's IP can be set to (for example) It will appear in the same network your linux machine is.

15.2.2. IP Routing

If you like to use IP routing, note that unlike with bridging, each DOSEMU box will reside in a separate IP subnet, which consists only of 2 nodes: DOSEMU itself and the corresponding TAP device on Linux side. You have to choose an IP address for that subnet. If your LAN has the address and the netmask is, the dosemu subnet can have the address and tap0 can have the address

    ifconfig tap0 netmask up
Choose a valid IP address from that subnet for DOSEMU box. It can be Configure your DOS client to use that IP. Configure your DOS client to use a gateway, which is the TAP device with IP Then you have to add the proper entry to the routing table on your Linux box:
    route add -net netmask dev tap0
The resulting entry in the routing table will look like this:
    Destination   Gateway  Genmask         Flags Metric Ref    Use Iface  *   U     0      0        0 tap0
Then, unless the Linux box on which DOSEMU is running is a default gateway for the rest of you LAN, you will have to also add an entry to the routing table on each node of your LAN:
    route add -net netmask gw
( is the IP of the box DOSEMU is running on). Also you have to check whether IP forwarding is enabled, and if not - enable it:
    echo 1 > /proc/sys/net/ipv4/ip_forward
Now DOSEMU will be able to access any node of your LAN and vice versa.

Yet one more thing have to be done if you want dosemu to be able to access Internet. Unlike in your LAN, you are not supposed to change the routing tables on an every Internet host, so how to make them to direct the IP packets back to dosemu's virtual network? To accomplish this, you only have to enable the IP Masquerading on the network interface that looks into Internet. If your machine serves as a gateway in a LAN, then the masquerading is most likely already enabled, and no further work is required. Otherwise you must add the following into your iptables configuration file (assuming the eth0 interface serves the Internet connection):

After restarting iptables, you'll find your dosemu session being able to access Internet. For more info about the IP Masquerading have a look into IP-Masquerade-HOWTO.