Serving HTML from MS-DOS

The TCP/IP protocol stack missing from MS-DOS has always been a reason for heated discussions – and this despite the fact that initially its support in the OS was not planned at all. And the point is not at all that MS-DOS would not be able to do it. TCP/IP at the time of DOS development had not yet been implemented by Microsoft itself. Except that IPX/SPX flashed in Windows 3.11. The TCP/IP stack was finally established only in Windows 95.

However, thanks to the amazing work on backports done by many enthusiasts around the world, We still managed to get TCP/IP to work in MS-DOS. In the 86Box emulator you can install a virtual network card, load its drivers and run TCP/IP. In this case it will even work browse the web. But now we’re going to do something even wilder. Let’s make our virtual MS-DOS machine work as a web server and place our HTML page on it. Let’s get started!

Virtual shamanism

Photo by Freddie Jacob on Unsplash

First of all, let’s decide on the 86Box configuration. I chose an Intel 80386 and an AMD network card because the TCP/IP stack is finicky and only works with select cards. In particular, the default Novel NE2000 does not suit him. But AMD and Realtek RTL8019AS successfully passed the test. The resulting system configuration will be as follows:

Configuration for Intel 80386 machine in 86Box

Configuration for Intel 80386 machine in 86Box

Note the modest amount of RAM and 33 MHz processor. During my brutal experiments, I wanted to subject the processor to maximum load. Now let’s move on to the network card:

AMD Virtual Network Card in 86box

AMD Virtual Network Card in 86box

For the AMD PCnet ISA virtual network card we will use SLiRP mode. This means a virtual router installed in the 86Box machine, connected to a virtual DHCP server. He will provide her with an IP address of 10.0.2.15 with a subnet of 225.225.225.0 and DNS 10.0.2.2. 86Box will have access to the Internet through the host, but it will not be able to access it itself.

Since we want to use the system as a web server, additional configuration is required. To do this, open the 86box.cfg file stored in the virtual machine folder:

MS-DOS virtual machine configuration file in 86Box

MS-DOS virtual machine configuration file in 86Box

Let’s add the code for port forwarding:

[SLiRP Port Forwarding #1]
0_external = 8080
0_internal = 80

Thus, we added port forwarding for our AMD ISA virtual network card. All traffic from external port 8080 will be redirected to internal port 80. This means that the 86Box virtual machine will serve HTML content on port 80, and the host machine will request it on port 8080. In other words, the MS-DOS web server, listening on port 80, will receive my requests through the real machine’s browser at 127.0 .0.1:8080.

Pay attention to the parameters 0_internal and 0_external. Zero denotes the port forwarding rule index. There may be several rules. For example, to forward both TCP and UDP you would add the following lines:

[SLiRP Port Forwarding #1]
0_external = 8080
0_internal = 80
1_external = 5000
1_internal = 50
1_protocol = udp

Our 86box.cfg file will end up looking like this:

86box.cfg file in VSCode with port forwarding added

86box.cfg file in VSCode with port forwarding added

Network Drivers and TCP/IP Stacks

A virtual machine configured for networking in 86Box

A virtual machine configured for networking in 86Box

The hardware setup is complete, it’s time to turn on the virtual machine. The screenshot shown above shows the result. All that remains is to launch the network driver. You can download it Here or from my page on GitHub. The archive on my GitHub is called amdnet.zip and contains both the network card driver and the TCP/IP stack driver. The network card driver is called pcntpk.exe, and you can run it by specifying the network card address (0x60 by default):

C:\>PCNTPK INT=0x60

After installing the card we will get the MAC address:

Installation of AMD PCI network card in 86Box was successful

Installation of AMD PCI network card in 86Box was successful

The next step is to install the TCP/IP stack. To do this, run ntcpdrv.exe without parameters:

TCP/IP stack installed

TCP/IP stack installed

The IP address 10.0.2.15 mentioned earlier has been received. Everything is ready to work with HTML files!

Web servers

Photo from NASA on Unsplash

At first it seemed that finding web servers for MS-DOS would not be an easy task. But the situation turned out to be more like a good noir film with unexpected plot twists. As it turned out, there are many web servers for MS-DOS, and some of them even implement processing of multiple requests simultaneously. One of the web servers is even built in BASIC. The MS-DOS developers would be proud!

The first one I tried was called Sioux and could process multiple requests simultaneously. The developer even shared a link to the drivers. This is the one I provided above for the AMD network card. But, unfortunately, this option did not work for me:

Mysterious error when starting Sioux web server

Mysterious error when starting Sioux web server

I tried everywhere to find a description of this error. I came across references to denial of access, something completely different. That this is probably somehow related to PowerBasic. But I never learned anything useful either about the error itself or what was behind it. I have no idea at all about PowerBasic, so I started testing another web server. And this one worked. It was written in BASIC and turned out to be very fancy. But at the same time it even had a laconic text user interface:

Running webserv.exe on an Intel 386 machine in 86Box

Running webserv.exe on an Intel 386 machine in 86Box

After launching it, port 80 is selected for listening. Forwarding is already configured, all that remains is to open the browser, type the local host address and port 8080. We see the default web page:

Our MS-DOS web server is ready to go

Our MS-DOS web server is ready to go

Web files are loaded from the HTMLDOCS folder:

List of files in the WebServ folder of an MS-DOS web server

List of files in the WebServ folder of an MS-DOS web server

It contains the index.htm file and an image of an alien with a thumbs up:

Default Website Files

Default Website Files

As stated, the web server supports CGI scripts, which allows you to send data to the page using HTML forms. It turned out that this is not the latest version of this web server (version 0.9). On one forgotten forum An even newer one called QuikServ 1.1 has been discovered, which has a number of advantages, including simultaneous processing of multiple requests. The file structure has changed somewhat, but the web page being served is still in the same HTMLDOCS folder:

File structure of QuikServ 1.1 in 86Box

File structure of QuikServ 1.1 in 86Box

Having launched the server, we see a slightly changed interface, as well as information about another recently implemented feature – FTP support:

QuikServ 1.1 text interface

QuikServ 1.1 text interface

Now let’s check the default website:

Default website offered by QuikServ 1.1

Default website offered by QuikServ 1.1

But the attempts did not end there. I managed to find Another one a web server written in MoonRock, a programming language developed by the author of the web server. To create an entire programming language and a web server on it, and even for MS-DOS – how do you like that?

Apparently MS-DOS died too early:

A directory simply named WWW contains a short list of files

A directory simply named WWW contains a short list of files

So let’s run it by typing the command www.com:

WWW web server text user interface

WWW web server text user interface

The text interface is quite convenient and pleasant. Unfortunately, this server doesn’t provide a default website, so calling it on localhost port 8080 won’t do anything for us:

Strange 404 error from MS-DOS web server

Strange 404 error from MS-DOS web server

However, the server itself recognizes the call and gives a full description of the problem:

Index.html object not found

Index.html object not found

Let’s finish here. An extensive family of MS-DOS web servers… Some of them are written in BASIC, others in PowerBasic, and still others, for mysterious reasons, in MoonRock. To tell the truth, such perseverance simply amazes me! And in general, when writing this article, every little thing, every detail was a pleasure. I hope that you will feel something similar, and perhaps even try out some of these servers. In this case, the work of enthusiastic programmers will be duly rewarded! Thanks for reading, see you next time!

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *