Fixed IP Ubuntu 16.04

Suppose you want your freshly installed Ubuntu to have a fixed IP.

First check ifconfig to see which interface should get a fixed IP adress.

Now for Ubuntu 16.04 the naming of the interfaces has been changed. Lan eth0 is now called enp3s0. wlp2s0 is the wireless network. The numbers may vary.


SSH on Ubuntu 16.04.3

Installing OpenSSH

Install openssh-server on ubuntu 16.04

This installs open-ssh and will start the ssh server on startup

You can now start a session from another machine

Password login isn’t the safest way to use ssh. Intead we prepare to use keypairs.


Create a two-router DMZ (rough steps)

Building a DMZ

modem + router (Router 1) connected to internet
extra router (Router 2)

Router1  has internet access and gets IP from ISP.
Router 1 Lan
Router 1 DHCP from to (mask
Router 1 Lan 1 attached to Wan on Router 2
Router 1 Lan 2 attached to Linux box (Ubuntu

Router 2 Wan IP gateway (=LAN Router 1)
Router 2 Lan
Router 2 DHCP from to (mask

Now the Linux box is the DMZ and cannot reach router2. Devices connected to Router2 are your normal network but can also see Router 1 DMZ traffic (Because of the LAN->WAN connection) So this only works if DMZ is on Router1 and trusted network on Router 2.

Don’t forget to:
– stop services that you don’t need on the Linux box.
– disable wifi and bluetooth radio in the bios of the linux box or remove the module from the mobo
– ssh only with keypair
– backup in case someone does get hold on your DMZ
– disable WPS on Router2 in case wifi get’s activated on DMZ

– Cannot disable webinterface Router1 so DMZ can reach it and mess with your network. Yet they still can’t get into to Router2 so all you risk there is a factory reset of your Router1. Ideas?

Next Steps:
Set fixed IP for your DMZ server:
Enable SSH on your DMZ server:


Shared folders in VirtualBox

It might be handy to share files between your host and guest system in VirtualBox. In this example the host is Windows and the guest OS is ‘Xubuntu 16.04.2’.

First we need to create a ‘Shared Folder’ in virtualbox. We could use the userinterface or commandline to accomplish this.

Create shared folder method 1: User Interface

Within the machine named “XubuntuVM”, go to the menu ‘Devices’ and start the ‘Shared Folders’ option.  Give the folder a meaningfull name, eg ‘Share’.  Tell VirtualBox which folder on the hostsystem to use. This might by ‘C:\VboxSharedFolder’. Check ‘Make permanent’. Press ‘OK’. This creates the shared folder.

Create shared folder method 2: Commandline

Start a new terminal on the host.  We need the following:
– VM name: “XubuntuVM”
– Sharename inside VBox:  “Share”
– HostPath: “C:\VBoxSharedFolder”

Mounting the drive

The shared folder is created within VirtualBox, but the guest OS still needs to mount the shared folder. First we need to create a folder, the mount point. Next we need to actually mount the VirtualBox share to the mountpoint. Start a terminal inside the guest (choose Menu -> Terminal Emulator). Now enter the following lines.

Your host drive is now accessible thru ‘/mnt/hostshare’. Any data placed inside this folder will be visible on the host inside ‘C:\VboxSharedFolder’ and vice versa.



Gradle (002): Getting started

Let’s create a very simple Gradle java project. Make sure Gradle is installed. See this link. Also java must be installed.

Create the Project folder:
devbox$ cd ~/Development/projects
devbox$ mkdir FirstGradle
devbox$ cd FirstGradle
devbox$ mkdir -p src/main/java/demo

Create the class and add some code
devbox$ vi src/main/java/demo/
:i (insert text)
1 package demo;
3 public class HelloGradle{
4 public static void main(String[] args) {
5 System.out.println("Hi Gradle!");
6 }
7 }
:x (save and close)

Now create a basic build file
devbox$ vi build.gradle
:i (insert text)
1 apply plugin: 'java'
:x (save and close)

Next we comple the code. Note that we are still in ~/Development/projects/FirstGradle.
devbox$ gradle build

We can list the folders created by Gradle on the mac using this command:
devbox$ find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'

The jar is stored in ./build/libs/ The file isn’t usable yet. If you run it you get a error because no Main method is found.
devbox$ java -jar build/libs/FirstGradle.jar

We need to add something to the file to make sure the manifest is created.
apply plugin: 'java'

jar {
manifest {
attributes ‘Main-Class’: ‘demo.HelloGradle’

Now rebuild and run the example.
devbox$ gradle build
devbox$ java -jar build/libs/FirstGradle.jar


Gradle (001): Download Gradle and install

We will download and install gradle on Mac OSX Sierra. Replace commands below with more recent version numbers.

Download the software:
devbox$ cd ~/Development/software
devbox$ curl -O
devbox$ ls -la

Whoops. The downloaded file is empty. What happened? Let’s see what the HTTP response tells us (-I option).
devbox$ curl -I

The response is of type 301 (Moved permantly). Now let’s add the -L flag to follow redirects.
devbox$ curl -LI

That looks better. It does still get the 301, but then follows until the 200 (OK). So try again without -I and output the file to disk (-O).
devbox$ curl -LO

Unzip the file and install in path like we did for Maven:
devbox$ unzip
devbox$ echo 'PATH=$PATH:~/Development/software/gradle-3.5/bin' >> ~/.bash_profile
devbox$ source ~/.bash_profile

Test our installation:
devbox$ gradle -version


Devbox (002): Download Maven with MD5 check and install.

We will download and install maven on Mac. Replace commands below with more recent version numbers. During this operation we will also check the md5 hash to check if our download is the same as the file on the server. We will also learn how to untar a file unix style.

Download the software:
devbox$ cd ~/Development/software
devbox$ curl -O

Download the checksum from maven:
devbox$ curl -O

Generate your own checksum against the downloaded file:
md5 -q apache-maven-3.5.0-bin.tar.gz > my-checksum.md5

Compare the two md5 hashes. If they are the same we know the downloaded file is not malformed during download. The -w option is to ignore any whitespaces (also newlines and tabs) during comparison. This is needed in this case because my md5 ends with a newline while maven’s md5 doesn’t and that would break the diff. No result running diff? That’s a good thing.
diff -w my-checksum.md5 apache-maven-3.5.0-bin.tar.gz.md5

Now let’s un-tar.
devbox$ tar xvzf apache-maven-3.5.0-bin.tar.gz
x -> Output to disk
v -> Verbose output (see output of what it is doing)
z -> Decompress
f -> Filename

The new un-tarred filename is apache-maven-3.5.0. This isn’t very easy to use. So let’s rename it and also clear the downloads.
devbox$ mv apache-maven-3.5.0 mvn
devbox$ rm apache-maven-3.5.0-bin.tar.gz
devbox$ rm apache-maven-3.5.0-bin.tar.gz.md5
devbox$ rm my-checksum.md5

Finally, mvn must be visible outside ~/Development/software/mvn. To do so we add this to the path variable. The fastest way is to redefine the PATH at the end of .bash_profile. The following command does that and will even create the file if it doesn’t exist. The source command is used to reload the file so we can use it right away.
devbox$ echo 'PATH=$PATH:~/Development/software/mvn/bin' >> ~/.bash_profile
devbox$ source ~/.bash_profile

Now let’s test. This should output the version we are using, but also the home directory where we’ve installed maven. Verify to see we are not being overruled by another installation.
devbox$ mvn -version



Devbox (001): Organizing stuff

Organisation on my development machine (mac)

devbox$ cd ~
devbox$ mkdir Development
devbox$ cd Development
mkdir projects
mkdir servers
mkdir software