Saturday, December 14, 2013

How to enable VPN over ICMP / DNS in SoftEther VPN

Or where is the damn VPN over ICMP / DNS setting in SoftEther

Because the infrequent times I need to install a SoftEther server I seem to waste half an hour trying to locate this setting.

BUT, it's already enabled by default.

Well enjoy this tip and if this has helped do thank me by following me on twitter @danielsokolows.

Sunday, December 8, 2013

CloudAtCost Buyer Beware

March 14, 2014 Update - I have sold am selling my 'Developer 3' for life instance


See performance stats below and email me at 'cloudatcost-dev3-for-sale [at] danols.com' if interested.

Below is latest performance snapshot - it's usable but not for what I need. Make me an offer in the comment section, the first reasonable amount will be accepted and we'll use a paypal for the transaction.

oot@debian7:~# . test-linode.sh 
$ openssl speed sha1
...
type             16 bytes     64 bytes    256 bytes   1024 bytes   8192 bytes
sha1             34431.17k    90492.32k   200161.54k   303043.38k   328540.16k

$ dd if=/dev/zero of=test bs=64k count=5k oflag=dsync && rm test
5120+0 records in
5120+0 records out
335544320 bytes (336 MB) copied, 84.5891 s, 4.0 MB/s

...
Resolving ipv4.download.thinkbroadband.com (ipv4.download.thinkbroadband.com)... 80.249.99.148
Length: 536870912 (512M) [application/zip]
Saving to: `/dev/null'

...
 536,870,912 1.18M/s   in 4m 25s  

Super cheap hosting but too good to be true

I've bought their for life Development 3 package about a month or so ago and aside from the rough administration panel at that time I was very impressed at the perfromance and support. The CloudAtCost instance was beating my good old and tried Linode VPS server and tickets were being answsered within hours - please use the previous or this Linode link if you decide to sign up as I get a small kickback .

Fast forward to today and I feel I might have fallen victim to the "Too good to be true" experience. My tickets go unanswered, there was a two week unable to re-image due to maintance message, and performance has hit rock bottom as seen per the stats below

CloudAtCost Dev 3 Package
512MB download ---> file avg speed 842K/s
dd if=/dev/zero of=test bs=64k count=5k oflag=dsync ---> 3.6 MB/s
SHA1 OpenSSL 8192 Test: 322022.06k

Linode 1GB Package
512MB download ---> file avg speed 6.92MB/s
dd if=/dev/zero of=test bs=64k count=5k oflag=dsync ---> 26.7 MB/s
SHA1 OpenSSL 8192 Test: 275749.84k

But let's be fair here and assume that CloudAtCost is simply swamped with the explosion of people jumping at their for life cloud packages, and so with that in mind I reserve the final verdict if I wasted my money to say 6-12 months from now. However the early lesson here is clearly that you get what you pay for.

Testing script used

Below is very rought testing script I use when comparing new services to Linode.

#!/bin/sh

#echo 'time arc a -mx temp.arc linux'
#rm temp.arc
#time arc a -mx temp.arc linux

echo 'time openssl speed sha1'
time openssl speed sha1

echo 'time tar cf - linux | bzip2 -9 - > temp.tar.bz2'
rm temp.tar.bz2
time tar cf - linux | bzip2 -9 - > temp.tar.bz2

echo 'time dd if=/dev/zero of=test bs=64k count=5k oflag=dsync && rm test'
time dd if=/dev/zero of=test bs=64k count=5k oflag=dsync && rm test

time wget --output-document=/dev/null http://ipv4.download.thinkbroadband.com/512MB.zip
#wget ftp://ftp.kernel.org/pub/linux/kernel/v2.4/linux-2.4.0.tar.bz2
#time tar -xvf linux-2.4.0.tar.bz2

Feel free to comment or follow me on twitter @danielsokolow.

Feb 01 2014 Update

New 2.0 control panel with better usability but network connection performance has further deteriorated.

CloudAtCost Dev 3 Package
512MB download ---> file avg speed 472KB/s
dd if=/dev/zero of=test bs=64k count=5k oflag=dsync ---> 10.7 MB/s
SHA1 OpenSSL 8192 Test: 379376.98k

Starbound Dedicated Server Setup

Setting up persistent Starbound on Debian

Starbound is a Terraria survival/build like game set in space. Based on watching few videos and playing it for a bit I concluded that except for the over abundant life and loot on every planet this game appeals to me very much. And so along with my minecraft.danols.com server I have decided to run a starbound.danols.com 24/7 dedicated one for Starbound; below is how I did it.

Get a dedicated Debian linux server

If you don't have yet a linux server I recommend going with Linode Xen VPS hosting - the basic first package will suffice. I have been with them for over 5 years now and can not say enough good things about them.

Yes, there are chepaer alternatives out there but heed the warning that you get what you pay for. With the basic package I am able to run a Freeswtich VOIP server, Minecraft, email, and few websites. Their setup instructions are solid so use that to provision a Debian 7 instance.

Please use the above link or this 7d884fa5262b62b8735502da003fee34061db49b referral code as I will get a small kick back if you do sign up.

Pick a domain address for your Starbound server

If you don't have a domain provider yet I recommend 1&1 Internet. I have used GoDaddy and 1and1 side-by-side over the last few years and I lean towards 1and1 since their prices are good and you also get private registration for free.

Once you get a domain, edit 1and1 or GoDaddy DNS (Domain Resolution Servers) entries and point them at Linode's servers.

After you get the DNS setup with your domain registrat, log into your Linode account and adjust the DNS entires there to point to your server, this is only needed if you are running the server under a subdomain like myself. Below is a screen shot of my starbound.danols.com settings.

To confirm everything is setup correctly ping your domain and if there is a response you are done with this step. This means that now when players want to join your server they just type your domain address instead of your IP.

root@sh1:/usr/local# ping starbound.danols.com
PING starbound.danols.com (69.164.217.6) 56(84) bytes of data.
64 bytes from sh1.danols.com (69.164.217.6): icmp_seq=1 ttl=64 time=0.051 ms
64 bytes from sh1.danols.com (69.164.217.6): icmp_seq=2 ttl=64 time=0.065 ms
64 bytes from sh1.danols.com (69.164.217.6): icmp_seq=3 ttl=64 time=0.064 ms
--- starbound.danols.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2000ms
rtt min/avg/max/mdev = 0.051/0.060/0.065/0.006 ms

Copy the Linux server binaries from your Steam's Starbound folder

Your windows Steam based installation of Starbound includes Linux execetubales to run a dedicated Starbound server. Using a SFTP WinSCP client copy <install directory>\Steam\SteamApps\common\Starbound\linux64\*.* files to /usr/local/starbound-server/linux64/ and <install directory>\Steam\SteamApps\common\Starbound\assets\*.* files to /usr/local/starbound-server/assets.

The final folder structures looks like this:

/usr/local/starbound-server/
                           /assets/  (files from asssets in steam folder)
                           /linux64/     (files from linux64 steam folder)

If you are curious why are we placing our Starbound server under '/usr/local/' folder structure feel free to read Debian FilesystemHierarchyStandard wiki.

Create a starbound-server user and the system startup script

To SSH remote into your server I use Kitty which is a putty clone with extra handy futures such as the ability to store passwords.

To create a limited starbound user which the server will run under execute adduser command as follows:

root@sh1:/usr/local/starbound-server# adduser --home /usr/local/starbound-server/ --shell /bin/false --no-create-home --ingroup daemon --disabled-password --disabled-login starbound-server
Adding user `starbound-server' ...
Adding new user `starbound-server' (1005) with group `daemon' ...
Not creating home directory `/usr/local/starbound-server/'.
Changing the user information for starbound-server
Enter the new value, or press ENTER for the default
        Full Name []: Starbound Server
        Room Number []:
        Work Phone []:
        Home Phone []:
        Other []:
Is the information correct? [Y/n]

Now to create the game server startup init system script execute nano /usr/local/starbound-server/starbound-server-init.d-script.sh and paste the following script contents into it.

#!/bin/sh
### BEGIN INIT INFO
# Provides:      starbound
# Required-Start:    $local_fs $remote_fs $network $syslog $named
# Required-Stop:    $local_fs $remote_fs $network $syslog $named
# Default-Start:    2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts the starbound server
# Description:      starts starbound using start-stop-daemon
### END INIT INFO

### NOTE: after linking it into init.d run `update-rc.d starbound-server.sh defaults`

### Settings
PID=/var/run/starbound-server.pid
DAEMON=/usr/local/starbound-server/linux64/starbound_server   # Server BIN
DAEMON_FOLDER=/usr/local/starbound-server/linux64/            # Folder where starbound_server file lives
DAEMON_OPTS=""                              
NAME=Starbound                                            # Name of process
DESC="Starbound server"                                   # Desc of process
USER=starbound-server                                     # User used to run the process (do not use root)


# Check if user exists
if ! id -u $USER > /dev/null 2>&1; then
        echo "The user does not exist; execute below commands to crate and try again:"
        echo "  root@sh1:~# adduser --home /usr/local/starbound-server/ --shell /bin/false --no-create-home --ingroup daemon --disabled-password --disabled-login $USER"
        echo "  ..."
        echo "  root@sh1:~# chown starbound-server:daemon /usr/local/starbound-server/ -R"
        exit 1
fi

### Check if server file exists and is executable
if [ ! -e $DAEMON ]; then echo "File $DAEMON does not exist"; exit 1; fi
if [ ! -x $DAEMON ]; then echo "Server file is not executable; run 'chmod +x $DAEMON' to fix."; exit 1; fi

set -e

. /lib/lsb/init-functions


start() {
        # start the server
        # echo "start-stop-daemon --start --make-pidfile --pidfile $PID --chuid $USER --chdir $DAEMON_FOLDER --exec $DAEMON -- $DAEMON_OPTS"
        start-stop-daemon --start --make-pidfile --pidfile $PID --chuid $USER  --chdir $DAEMON_FOLDER  --exec $DAEMON -- $DAEMON_OPTS > /dev/null &
       
}

stop() {
        # gracefully stop the server
        start-stop-daemon --stop --signal INT --pidfile $PID --chuid $USER --oknodo --exec $DAEMON
}

case "$1" in
        start)
                log_daemon_msg "Starting $DESC" "$NAME"
                start
                log_end_msg $?
                ;;

        stop)
                log_daemon_msg "Stopping $DESC" "$NAME"
                stop
                log_end_msg $?
                ;;
        restart)
                log_daemon_msg "Restarting $DESC" "$NAME"
                stop
                sleep 1
                start
                log_end_msg $?
                ;;

        status)
                status_of_proc -p $PID "$DAEMON" starbound
                ;;

        *)
                echo "Usage: $NAME {start|stop|backup|restart|status}" >&2
                exit 1
                ;;
esac

exit 0

error while loading shared libraries: libvorbisfile.so.3: cannot open shared object file: No such file or directory

You might get the above error message so let's run aptitude install libvorbisfile3 which resolved the missing library issue for me.

Final steps and test run

Ensure that all files are owned by the startbound-server user - do this by executing chown starbound-server:daemon /usr/local/starbound-server/ -R. Add the startup script to the boot process by linking it from '/etc/init.d' folder and adding it to the startup sequence as follows:

root@sh1:/usr/local/starbound-server/assets# ln -s /usr/local/starbound-server/starbound-server-init.d-script.sh /etc/init.d/starbound-server.sh
root@sh1:/usr/local/starbound-server/assets# update-rc.d starbound-server.sh defaults

Test the entire setup by starting the game server /etc/init.d/starbound-server.sh start, and logging into your new shiny server. Feel free to follow me on Twitter @danielsokolow and comment if you have any questions.

And lastly do log into my persistent server at starbound.danols.com to check it out.

Troubleshooting

Best way to troubleshoot is to start the server manually and look for any errors in the console, to start the server manually do as follows:

root@sh1:/etc/init.d# cd /usr/local/starbound-server/linux64/
root@sh1:/usr/local/starbound-server/bin# ./starbound_server
Info: Creating Star::Root with 1 assets sources and config file: './starbound.config'
Info: Loading Star::Assets from: '../assets'
Info: Loading Star::Root...
...

Warn: Slow asset 0.081 : /objects/generic/capsulemed/capsulemed.png:default
Warn: Perf: UniverseServer::createWorld millis: 6830
Warn: Perf: WorldServerThread::sync millis: 363
Warn: Perf: UniverseServer::doTriggeredStorage millis: 363
Warn: Perf: UniverseServer::run.innerloop millis: 473
Info: Shutting down world alpha:-61930447:-6722809:-4350314:8:6

Tips

Tailing the log in style

The log is very noisy, but you can mitiage some of that by using a good log coloriser like 'ccze'; to install and use execute the following:

root@sh1:~# aptitude install ccze
...
root@sh1:~# tail -f -n 50 /usr/local/starbound-server/linux64/starbound_server.log | ccze -A
...

Auto re-start the server if it dies

I've noticed the server seems to stops running after a while which - I attribute this to the beta code quality - as a work arround I created the following cron entry which just executes /etc/init.d/starbound-server start; the start-stop-deamon takes care of not spawning a new server if it is already running for us.

I like to be explicit so I anmed the below as /usr/local/starbound-server/starbound-server-cron.d-entry and linked it as /etc/cron.d/starbound-server-start-if-needed. Note that files in cron.d must not have periods in them.

# On Debian system symlink this file into your `/etc/cron.d` folder like so
#
# > ln -s /usr/local/starbound-server/starbound-server-cron.d-entry /etc/cron.d/starbound-server-start-if-needed
#
# Do ensure permissions and ownership are as follows (see http://askubuntu.com/questions/54857/can-symlinks-be-use$
#
#    -rwxr--r--  1 root daemon  215 Dec 12 15:01 starbound-server-cron.d-entry

 */15 * * * * root /etc/init.d/starbound-server start