VOGONS


First post, by mike_canada

User metadata
Rank Member
Rank
Member

Hello,

After reading guides, I am able to access internet through DOSBOX but I want to also run a webserver designed in Qbasic with it but that part will not work. For the rest of this post, I'll call the qbasic web server the DBWS (for DosBox Web server).

I got the web server software from here: http://rubbermallet.org/software/webserv.html

I have configured DOSBOX startup script in the dosbox config file as follows under the autoexec section:

mount C /path/to/dos/drive
C:
ethersl -p 0x60 3 0x2F8 115200
set MTCPCFG=\dosbox.cfg
ping google.ca

Under the serial section I have:

serial2=nullmodem server:127.0.0.1 port:8001 transparent:1

\dosbox.cfg is necessary so the mTCP suite knows what internet info to use for its applications. \dosbox.cfg contains:

TIMESTAMP unknown 2
packetint 0x60
ftpsrv_password_file NUL
ftpsrv_log_file NUL
IPADDR 192.168.7.2
NETMASK 255.255.255.252
GATEWAY 192.168.7.1
NAMESERVER 8.8.8.8
LEASE_TIME 6000

This is the script I execute to make everything in action:

#!/bin/bash
killall socat > /dev/null
killall slattach > /dev/null
echo 1 > /proc/sys/net/ipv4/ip_forward
echo DOSBOX with networking
echo Uses ETHERSL dos driver + socat
socat -4 PTY,link="/tmp/dbnet",raw,echo=0 TCP4-LISTEN:"8001" &
sleep 1
slattach -d -s 115200 -p adaptive "/tmp/dbnet" &
sleep 1
ifconfig sl0 192.168.7.1 dstaddr 192.168.7.2 netmask 255.255.255.252 mtu 576 up
iptables -t nat -A POSTROUTING -s 192.168.7.0/30 -j MASQUERADE
sleep 1
dosbox

I am able to ping from google.ca inside DOSBOX no problem, but the problem happens when I run the DBWS.

The DBWS when launched indicates that it is ready.

I launch seamonkey on the host machine and try to access DBWS. I get a response "The document contains no data. The network link was interrupted while negotiating a connection. Please try again.".

If instead of seamonkey, I run a linux console and used wget on the same ip, I get "--2020-12-26 (try: X) http://192.168.7.2/
Connecting to 192.168.7.2:80... connected.
HTTP request sent, awaiting response... Read error (Connection reset by peer) in headers.
Retrying."

where X is the attempt number. and the console will continue to spit that message out.

Now when I stop the DBWS, then on the local machine, seamonkey and wget report different results. Seamonkey reports:

"Failed to Connect

The connection was refused when attempting to contact 192.168.7.2.

Though the site seems valid, the browser was unable to establish a connection.

Could the site be temporarily unavailable? Try again later.
Are you unable to browse other sites? Check the computer's network connection.
Is your computer or network protected by a firewall or proxy? Incorrect settings can interfere with Web browsing."

and wget reports:

" (try: 4) http://192.168.7.2/
Connecting to 192.168.7.2:80... failed: Connection refused."

If I replaced the DOSBOX environment with a PC running the same environment, the whole thing works. The only difference is, I'll need 2 active PC's and the initial network packet driver isn't ethersl because I'm connecting that PC to the router via an RJ45 cable, but the steps after loading the packet driver are exactly the same.

I wonder if there is something I can do on the linux side of things to make things work. Do I need to do another thing with iptables or something?

Reply 1 of 8, by mbbrutman

User metadata
Rank Member
Rank
Member

Your setup seems to be confused. If you are using NAT (Network Address Translation) on the Linux machine, then outbound connections from the DOSBox side will work, but no inbound connections to the DOSBox side can be routed. You need explicit rules to make inbound connections work.

The mTCP docs discuss a similar setup that uses Proxy Arp instead. I would use that as the basis of your setup, as Proxy Arp allows inbound connections to the DOSBox side.

Reply 2 of 8, by mike_canada

User metadata
Rank Member
Rank
Member
mbbrutman wrote on 2020-12-26, 21:53:

Your setup seems to be confused. If you are using NAT (Network Address Translation) on the Linux machine, then outbound connections from the DOSBox side will work, but no inbound connections to the DOSBox side can be routed. You need explicit rules to make inbound connections work.

The mTCP docs discuss a similar setup that uses Proxy Arp instead. I would use that as the basis of your setup, as Proxy Arp allows inbound connections to the DOSBox side.

I was borrowing my idea from:

https://www.dosbox.com/wiki/Slip_configuration_on_linux_host

but I condensed its script to make it work with my setup.

but I'll have a look at the mTCP document you suggested to see if it helps.

Reply 3 of 8, by mike_canada

User metadata
Rank Member
Rank
Member
mbbrutman wrote on 2020-12-26, 21:53:

The mTCP docs discuss a similar setup that uses Proxy Arp instead. I would use that as the basis of your setup, as Proxy Arp allows inbound connections to the DOSBox side.

Ok, so I cleared my iptables and now I modified my startup script to be as follows:

#!/bin/bash
echo 1 > /proc/sys/net/ipv4/ip_forward
socat -4 PTY,link="/tmp/dbnet",cfmakeraw,echo=0,B115200 TCP4-LISTEN:"8001" &
sleep 1
stty -F /tmp/dbnet -clocal -crtscts 115200
slattach -dvL -s 115200 -p slip "/tmp/dbnet" &
sleep 1
ifconfig sl0 192.168.7.1 pointopoint 192.168.7.2 mtu 576 up
arp -s 192.168.7.1 00:16:6f:5e:f5:66 pub
arp -s 192.168.7.2 00:16:6f:5e:f5:66 pub
sleep 1
dosbox

and the results are the same. I can connect out with mTCP ping utility but webserv that requires trumpet sockets (ntcpdrv) won't serve pages and I still get the same issue as last time.

Reply 4 of 8, by mike_canada

User metadata
Rank Member
Rank
Member

wait nevermind. I took the nat entry out and now the ping does not work

Reply 5 of 8, by mbbrutman

User metadata
Rank Member
Rank
Member

It looks like the socat command is needed because DOSBox uses TCP/IP sockets for the nullmodem emulation. So it's a little weird to think about this setup because you are running a SLIP connection to get TCP/IP over what looks like a serial cable, but the serial cable is emulated by a TCP/IP connection. That's a DOSBox thing that my instructions don't deal with because I used a real DOS machine and a real Linux machine, and there was a real serial cable between them.

The socat instruction looks like it forwards traffic between a pseudo-tty named /tmp/dbnet and localhost:8001. So slattach sets up a SLIP connection on /tmp/dbnet (the pseudo tty), where everything magically gets forwarded into DOSBox on a serial port. If pinging out is working, then you are probably fine, as to get a response back routing has to work.

Have you tried making a connection to mTCP netcat, the FTP server, or the httpserver? If you can make inbound connections to those then your networking setup is not the problem. If you can't then your networking setup is the problem.

I don't think you are supposed to be using ARP to set both addresses to the same HW address. In the mTCP configuration instructions ARP is only used once, and you are telling the Linux machine to advertise it's HW address when somebody goes looking for the HW address of DOSBox. Line 9 should probably be deleted.

Reply 6 of 8, by mike_canada

User metadata
Rank Member
Rank
Member

Ok, so I did make an arp version of my startup script and when I used mTCP's ping , all 4 attempts returned a timeout.

#!/bin/bash
echo 1 > /proc/sys/net/ipv4/ip_forward
socat -4 PTY,link="/tmp/dbnet",raw,echo=0 TCP4-LISTEN:"8001" &
sleep 1
slattach -d -s 115200 -p slip "/tmp/dbnet" &
sleep 1
ifconfig sl0 192.168.7.1 dstaddr 192.168.7.2 netmask 255.255.255.252 mtu 576 up
arp -Ds 192.168.7.2 sl0 pub

Then I replaced:

arp -Ds 192.168.7.2 sl0 pub

with:

iptables -t nat -A POSTROUTING -s 192.168.7.0/30 -j MASQUERADE

and ping did work.

I then tried netcat from the same suite of tools (for DOS).

now it seems like something may be wrong with the trumpet sockets driver (ntcpdrv).

Reply 7 of 8, by mike_canada

User metadata
Rank Member
Rank
Member

Ok, so I'm debugging webserv.bas and now the trumpet socket driver is being odd.

Anyways, I make the connection, the result headers print but the data body does not print yet in my code, I only instructed it to print out 198 bytes of code. Somehow its calculating that I'm putting out 511 or 512 bytes?

well anyways, I executed curl -vvv 192.168.7.2 on the host while the server in dosbox is running and I got this...


* About to connect() to 192.168.7.2 port 80 (#0)
* Trying 192.168.7.2...
* connected
* Connected to 192.168.7.2 (192.168.7.2) port 80 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.27.0
> Host: 192.168.7.2
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-type: text/html
< Content-length: 198
<
* Excess found in a non pipelined read: excess = 313, size = 198, maxdownload = 198, bytecount = 0
* Connection #0 to host 192.168.7.2 left intact

Reply 8 of 8, by mike_canada

User metadata
Rank Member
Rank
Member

Ok I seemed to have figured it out. My setup is right but I modified the web server source code so much that it is outputting a series of null characters. I forgot that one part I did was a fixed-length string and I applied a string length check on that and it gave the full buffer space instead of the actual string length as a result. the joys of qbasic