Setting Up a Private Nethack Server on Ubuntu Lite

We already established that terminally incoherent readers love them some nethack. The nice thing about nethack is that it takes only few hundred kb on your drive, and provides you with endless tons of entertainment. But hell, you don’t even need to install it. All you need to taste the nethack goodness is telnet.

There are several public nethack servers that let you play via telnet. The biggest and most popular one is located at alt.org. Or at least they are the one that shows up on Google results first. You simply telnet in, create an account and play online. This is such an awesome concept that I decided I need some of that. I want my own public server! This would be a perfect new role for that funky old Compaq Presario sitting under my desk and currently running Ubuntulite. So I started digging around for a solution.

And I hit a brick wall because the documentation for this kind of stuff is scant and/or nonexistent. Nevertheless I persevered and you can see the end effect at luke.kicks-ass.org. Sorry for the dyndns domain name, but this is a temporary sort of a thing. For now you can simply telnet in and play. I will probably keep the machine running over the weekend unless you guys manage to crash it. ;)

Note: Use PuTTY or some real terminal client. The windows cmd.exe messes up the menu layout pretty badly. But I’m not sure if there’s anything I can do about it.

Once again, if you want to try out the server, just do:

telnet luke.kicks-ass.org

It’s running on port 23, and it should log you in automatically. From there you need to (r)egister an account. I don’t use the emails for anything, so when asked just type in anything as long as it has an email syntax. There is no email activation or any of that shit. Username and password are up to you. Just remember that this is telnet – so your password will be sent in plain text. Make up some silly one that you won’t be using elsewhere and you won’t cry when you lose it. When you are done it should dump you back at the initial prompt. There you can either (l)og in to play or (w)atch someone else play. Chances are no one is playing yet so log in.

On the next screen you will see bunch of options. Note that I left the nethack config files in bare bones state. You will probably want to use the “o” option to edit your options file to include the number_pad:2 bit that makes movement little easier for people who don’t like HJKL. The editor that ships with dgamelaunch is a vim clode so just fucking deal with it. Move down to one of the uncommented OPTIONS lines add number_pad:2 at the end, press Esc, then :wq and you should be back at the prompt. ;) Now all that is left is to (p)lay.

Let me know how the server works for you. It may be a bit slow (the box is a very old laptop siting on an asymetric residential connection) but then again, this is nethack. You don’t really need rapid speed here. If you like it I might try to figure out a way to make this a permanent fixture of the site. :)

Here is a screenshot of me playing from my winXP box via PuTTY by telneting to luke.kicks-ass.org:

Playing Nethack on the New Server

What follows below is the lengthy account of the issues I encountered while setting up this damn thing. If you don’t care about installation details, just skip down to comments.

So, how do you run a public nethack server? First you need the server software. Most servers out there use DGameLaunch which works, but is a major pain in the ass to use. It’s not in the repositories so you will need to download it from the website, compile and configure it yourself. And let me tell you it’s not a picnic. First, you will need to download few dependencies. You will need ncurses development headers, a telnet server and two lexical analyzers flex and bison. You also, obviously need gcc and make to compile the code. And naturally, nethack. You may already have these things on your system – my bare bones install of Ubuntulite didn’t. Just in case run the following:

aptitude install libncurses5-dev bison flex telnetd gcc make nethack-console

Allright, now we can get the server software and compile it:

wget ftp://ftp.alt.org/pub/dgamelaunch/dgamelaunch-1.4.6.tar.gz
tar -xzvf dgamelaunch-1.4.6.tar.gz
cd dgamelaunch-1.4.6/
./configure
make
sudo make install

Have fun. I know I did, because the only documentation that ships with dgamelaunch is a 6 Kb README file. Out of the 117 lines of text it contains, maybe 3 or for actually mention compilation and dependencies. This means that you need to pay close attention to the output of make. Funny thing is that the configure script noticed that I don’t have bison/yacc or flex/lex but did not consider that a stop condition and gleefully generated a makefile. Of course without these apps make would die a horrible death in a flurry of semi-random error message. Same goes for the ncurses header files – it knew it was missing, but did nothing. Thanks!

By default, dgamelaunch will get installed into /usr/local/. Once you compile it you need to do two things. First copy the dgamelaunch.conf from the examples folder to your /etc:

sudo cp examples/dgamelaunch.conf /etc/

Next you want to create chroot jail in which the server will be running. There is a script that does that which ships with dgamelaunch. Simply run it and you should be all set:

sudo ./dgl-create-chroot

It should create /var/lib/dgamelaunch directory and dump bunch of files in there. In my case the script failed to do all the work so I had to do few things manually. Most of this I figured out by trial and error because the README file only gives you cryptic hints on what to do if things go sour.

For example, the script keeled over trying to copy appropriate libs to the chroot directory. It kept failing with an error message pointing out that it can’t find some file, but instead of printing out the file name it would print out a hex value (memory address?). I looked at the script and noticed this was the very last few lines. It also had some small comment which suggested which libraries will probably get imported.

I manually copied all the listed file from /lib/ to /var/lib/dgamelaunch/lib/ then tried to run the binary. It kept failing telling me about other missing files. After 3 or 4 tries I got the full complement of needed libraries. If this happens to you, here is what you should do:

sudo mkdir /var/lib/dgamelaunch/lib/
sudo cp /lib/ld-linux.so.2 /var/lib/dgamelaunch/lib/
sudo cp /lib/libc.so.6 /var/lib/dgamelaunch/lib/
sudo /lib/libdl.so.6 /var/lib/dgamelaunch/lib/
sudo /lib/libdl.so.2 /var/lib/dgamelaunch/lib/
sudo /lib/libncurses.so.5 /var/lib/dgamelaunch/lib/

I also needed to populate /var/lib/dgamelaunch/etc/terminfo with files from /lib/terminfo. For some reason the terminal descriptions were not copied over to this location by the chroot script. I’m not sure this was intended behavior or just a glitch. If you are having problems running the game or the server interface take a peek in this folder. If it’s empty do the following:

sudo cp /lib/terminfo/* /var/lib/dgamelaunch/etc/terminfo/

Btw, when you are testing you need to run dgamelaunch with sudo. This is actually a small tidbit of knowledge that is outlined in the README file. Once you can run the app, register and account, edit the option file, and play few rounds of the game, you can move on to the next stage.

Now all we need to do is set up a telnet server so that people can connect and play. Of course This is the one place where the readme actually does offer you some help. Make sure telnetd is installed, and simply copy and paste the following file into your /etc/inetd.conf:

telnet stream tcp nowait root.root /usr/sbin/tcpd /usr/sbin/in.telnetd -h -L /usr/sbin/dgamelaunch -q -f /etc/dgamelaunch.conf

This may or may not work for you. It work for me. The -L option telnetd in feisty is retarded and doesn’t allow you to use any command line parameters to the shell you are specifying with it. The README file actually mentions that near the bottom. It also mentions that you can use an abridged version of this line:

telnet stream tcp nowait root.root /usr/sbin/tcpd /usr/sbin/in.telnetd -h -L /usr/sbin/dgamelaunch

If you do however it is important to make sure your dgamelaunch.conf is in the root of the /etc directory. If you plan place it in a subdirectory, you have to change the make file before you compile it. Check the README file for hints on how to do this.

After you change the inetd.conf file you want to restart the inetd server. There are several ways to do this, but a simple way that will work on just about any platform is:

killall -HUP inetd

This kills the process and forces it to restart and re-read it’s config file. It’s a tad brutal way to do it so don’t use it on a shared machine or one that is actually handling some critical data. What the hell are do doing installing nethack server on a critical server anyway?

If you do all of the above, you should have a working dgamelaunch installation, and a working telnet server. Just telnet in, and play. :) Id not, post in the comments and we can maybe figure out what is going on together.

tldr: dgamelaunch documentation sucks balls, but setting up the server is doable

[tags]nethack, nethack server, dgamelaunch, public nethack server[/tags]

This entry was posted in video games and tagged , , . Bookmark the permalink.



29 Responses to Setting Up a Private Nethack Server on Ubuntu Lite

  1. Jarek UNITED STATES Mozilla Firefox Ubuntu Linux says:

    Btw, your telnet server works fine, except every time an actual game of nethack is started, the connection is terminated. It works fine editing the options and stuff, just no game.

    Reply  |  Quote
  2. Ian Clifton UNITED STATES Epiphany Linux says:

    It was plenty fast for me, so I guess text isn’t too much for your old Compaq to handle… yet!

    Reply  |  Quote
  3. Luke Maciak UNITED STATES Mozilla Firefox Windows says:

    @Jarek – very odd. I got a similar issue initially, but I thought it got fixed when I dumped the correct libs into the right directories.

    I just tested it from here and it seems to be working. What telnet app are you using? I really do recommend PuTTY on windows – the standard telnet client doesn’t work very well.

    @Ian – Nice! I don’t expect many people playing here simultaneously. I really don’t see it having to deal with 2 or 3 simultaneous connections which should be working just fine for that machine.

    Of course, since this is my home network you will probably notice lag when I’m downloading torrents. ;P

    Reply  |  Quote
  4. Jarek UNITED STATES Mozilla Firefox Ubuntu Linux says:

    I’m using the default telnet client for the linux terminal.

    Reply  |  Quote
  5. Luke Maciak UNITED STATES Mozilla Firefox Windows says:

    :( Does it give you any error message, or does it just disconnect?

    Reply  |  Quote
  6. Jarek UNITED STATES Mozilla Firefox Ubuntu Linux says:

    Just standard message: “Connection closed by foreign host.”

    Reply  |  Quote
  7. Luke Maciak UNITED STATES Mozilla Firefox Windows says:

    @Jarek – Weird. I tested it on two different machines here at home, and from one offsite linux server. It works for me. I can’t figure out why would it cut out like that.

    Btw, can you use the alt.org server?

    Reply  |  Quote
  8. k00pa FINLAND Konqueror Linux says:

    Yet another awesome article! Thanks!

    Reply  |  Quote
  9. Jarek UNITED STATES Mozilla Firefox Ubuntu Linux says:

    I have the same problem on the alt.org server, so it is something on my end, not yours. Odd.

    Reply  |  Quote
  10. Luke Maciak UNITED STATES Mozilla Firefox Windows says:

    @K00pa – :) thanks!

    @Jarek – what terminal and/or shell are you using? I have no clue what might be causing it, but see if you can connect with just a plan xterm and bash.

    Reply  |  Quote
  11. Jarek UNITED STATES Mozilla Firefox Ubuntu Linux says:

    I use fish and konsole. I tried bash on both a tty and with xterm, with the same problem. I’ll live with a local nethack game, I guess. But my problem-solving mind is intrigued.

    Reply  |  Quote
  12. Luke Maciak UNITED STATES Mozilla Firefox Ubuntu Linux says:

    It’s definitely not Konsole because that is working here as well. Very odd. Let me know what was if if you figure it out.

    Reply  |  Quote
  13. Pingback: Terminally Incoherent » Blog Archive » Installing AUCTex with EmacsW32 UNITED STATES WordPress

  14. Wolf UNITED STATES Mozilla Firefox Windows says:

    I am running kanotix on a VMware Workstation and attempting to run my own nethack server, i followed everything to the letter but a few things happened, first in
    [quote post="2095"]sudo /lib/libdl.so.6 /var/lib/dgamelaunch/lib/ sudo /lib/libdl.so.2 /var/lib/dgamelaunch/lib/ sudo /lib/libncurses.so.5 /var/lib/dgamelaunch/lib/[/quote]

    my terminal says these files dont exsist, but i pushed on anyways and i get to the end where i test it but all i get after doing a ./dgamelaunch is

    [quote] Error opening terminal: xterm [/quote]

    should i try and use ubuntu like you did for my vmware install or can i get around this some how also tried this in a minimal debian install and got the same results. but with errors using “telnet” aswell.

    could some one post me to a debian install for this or am i just doing somethinng wrong being that i am new to linux

    Reply  |  Quote
  15. Luke Maciak UNITED STATES Mozilla Firefox Ubuntu Linux Terminalist says:

    @Wolf: You just need to install the correct packages. Were you able to install the following?

    - libncurses5-dev
    - bison
    - flex
    - telnetd
    - gcc
    - make
    - nethack-console

    These files should be included there. Some of these packages may not exist in debian. Try apt-get search-ing for them.

    If you did, see if you can do:

    locate libdl.so.2
    locate libdl.so.6

    To see where these files are. If they are on your system they will show up there.

    Reply  |  Quote
  16. Wolf UNITED STATES Mozilla Firefox Windows says:

    well i decided to rehash my vmware with ubuntulite and follow your tut word for word instead and i am pleased to say dgamelaunch works great and runs perfect :)

    i did see those later as my missing libs in debian but had way to much difficulty installing them so thus i went with ubuntulite, which btw i love.

    Now my big issue is telent when i use you commands i get an error saying -h isnt an option so i remove -h then i get another error saying -q isnt an option and so on till im left with -L but it still keeps telling me im using it incorrectly.

    i decided to change it to telnetd instead of telnet in hopes that would be a small typo or something and it seemed to go through but however when i try to connect to the machine all i get is connection refused through putty.

    if you have any further assistance on this it is appreciated but im sure ill get it eventualy…. im a very persistant person :)

    thanks again for this wonderful article and my latest bookmark!

    Reply  |  Quote
  17. Luke Maciak UNITED STATES Mozilla Firefox Ubuntu Linux Terminalist says:

    Are you running that from the command line or pasting it into /etc/inetd.conf. Cause I think you need to paste it. Check the README file that came with dgamelaunch – maybe I have a typo in this line. :)

    Reply  |  Quote
  18. Wolf UNITED STATES Kazehakase Debian GNU/Linux says:

    well that was my fault lol, it was connection refused because it was ssh not telnet in putty

    However….
    nethack@ubuntu:~/dgamelaunch-1.4.7$ telnet nethack.game-server.cc
    Trying 64.151.45.133…
    Connected to nethack.game-server.cc.
    Escape character is ‘^]’.
    Connection closed by foreign host.
    this is my actual problem as i was getting origonaly did this get figured out

    Reply  |  Quote
  19. Luke Maciak UNITED STATES Mozilla Firefox Ubuntu Linux Terminalist says:

    Hmm… It sounds like it is crapping out at the moment when it should toss you over to the actual nethack console. Is nethack running properly on that machine? Ie. can you start it from the command line?

    Also, did you make sure you copied all the files from /lib/terminfo?

    Reply  |  Quote
  20. Wolf UNITED STATES Kazehakase Debian GNU/Linux says:

    yes i can start nethack from the command line and i did see however that cp was ommiting the directories and not copying them so i did a cp -r to fix this however now even with the terminfo the way it should be i am still getting the same error though telnet even as a localhost connect i get this.

    Reply  |  Quote
  21. Wolf UNITED STATES Kazehakase Debian GNU/Linux says:

    well as a follow up i seem to be getting a lot closer and it seems all of my problems are rooting from dgamelaunch, it just wasnt copying files over even the “dgamelaunch” wasnt even in sbin
    I have gotten a connection via local host now but as soon as i press play same error all over again, and i still cant get connection outside localhost even with tweaking the hosts.allow file to allow all telnet connection and even all connections ill keep working at this and if i actualy find a solution ill post but im slowly starting to lean towards looking for an alternative to dgamelaunch :P

    Reply  |  Quote
  22. Wolf UNITED STATES Mozilla Firefox Windows says:

    Well after several days of agonizing torture with this problem and soon before i almost gave up entirely i am happy to report i have solved this issue!

    So as it would seem that port 23 on my machine was getting a “stealth” option meaning that all packets recieved to this port would be droped and i could not find what was causing this to open that port, so as an alternative i nano /etc/services and changed telnet to port 7777 and now it will connect :)

    so anyone who is having a similar problem i suggest giving this solution a try as it may not be anythign but a simple firewall or some sort of internet security in your router (ie SPI) stopping you from getting those connections.

    happy hacking! ;)

    Reply  |  Quote
  23. Luke Maciak UNITED STATES Mozilla Firefox Windows Terminalist says:

    @Wolf: Nice! I’m glad to hear you have figured it out. I didn’t think to check whether or not a port is blocked. Good call!

    Reply  |  Quote
  24. Pingback: Samui’s Blog » Blog Archive » a post UNITED STATES WordPress

  25. Dan Salvato UNITED STATES Google Chrome Windows says:

    I hope someone reads this, because I’d have really needed it.

    Ubuntulite (now U-lite) gave me all kinds of problems, so I just used regular Ubuntu. Here’s what I did differently from this tutorial:

    1. Use dgamelaunch-1.4.6, even though it’s not the newest version. You’ll get an error when running dgl-create-chroot, as mentioned. However, instead of using that manual workaround, grab the dgl-create-chroot from dgamelaunch-1.4.7.

    2. You have to modify dgamelaunch.conf and comment out these two lines:
    shed_user = “games”
    shed_group = “games”

    3. The terminfo copying step is unnecessary. dgamelaunch does copy them, but in a different directory.

    4. For adding the telnet line to /etc/inetd.conf, use the second one provided. Also, if you receive a “no process” error when trying to killall, just ignore that step and instead type:
    sudo inetd /etc/inetd.conf

    Hope this helps someone.

    Reply  |  Quote
  26. Dan Salvato UNITED STATES Google Chrome Windows says:

    @ Dan Salvato:

    I forgot to mention this. As a final step, type in:
    sudo mv /usr/local/sbin/dgamelaunch /usr/sbin/dgamelaunch
    If it gives you an error, don’t worry about it.

    Reply  |  Quote
  27. paxed FINLAND Mozilla Firefox Linux says:

    I’ve written some install docs for the dgamelaunch devel version: http://nethackwiki.com/wiki/User:Paxed/HowTo_setup_dgamelaunch

    Reply  |  Quote
  28. Andy UNITED STATES Google Chrome Windows says:

    Old article I know, but does anyone have instructions for setting up other roguelikes. I’d love to get Crawl, or even an older version of the original Rogue running all on the same server. I’m not a Linux expert, but I setup a Debian7 machine via paxed guide, was easy, just can’t get Crawl to compile with the needed information to incorporate it into DGL. android8675 at shodan dot synchro dot net.

    Reply  |  Quote
  29. Luke, I happened across your blog here all by accident. It’s a small web I guess! You’re linked from this dgamelaunch wiki page. I was looking into how dgamelaunch worked because I wanted to expose my ncurses flappy bird clone as a telnet game. For the moment you can try it out here:


    telnet flappy.nullprogram.com

    Reply  |  Quote

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>