Setting up network connection on NFIT cable network from Ubuntu CLI

First you need to register your MAC address to be able to use the cable network at NFIT. The simple solution is to send a mail to Michael Glad with our MAC-address and NFIT username if you already know the MAC address. However if you want to help yourself and lighten the workload on Michael Glad you simply setup a DHCP-client on your server and register using a web browser. In the case that you installed Ubuntu server where there isn’t any default web browser installed and you are limited to text versions like Lynx. It should be noted that as long as you haven’t registered your device you wouldn’t be able to do anything outside of the LAN, this means no apt-get or alike! So therefore you can’t even install Lynx that way around. First of you need to setup the DHCP-lease and be able to ping your default gateway or Google DNS (that service is open).

If there is only a single NIC this fairly simple – the reference you need for the first part is namely “eth0”. However with multiple NICs and maybe even multiple ports per NIC, this becomes a little more tricky. The way to solve this is to use some of the basic tools available, in this case the lshw command. Depending on how many NICs and ports your machine has it might be a good idea to pipe the output into a separate file as it might not all fit into one screen. So first of you need to connect the network cable to the machine and then execute the following command in your terminal:

ip addr > network.txt

This will take the standard output from the command and write it to a file instead of displaying it on the screen. Next up we will need to find the line there says that the port is physically UP, it looks something like:

2: eth0: mtu 1500 qdisc pfifo_fast state UP qlen 1000

Now that we know which reference we need, e.g. “eth0”, we can edit the interface setting of your system. This is done in the /etc/network/interfaces-file. Use any text editor to edit the file, i.e.:

vi /etc/network/interfaces

Add the following code to the file if the reference is “eth0”, otherwise change of a different reference:

auto eth0
iface eth0 inet dhcp

Finally to get a DHCP-lease you need to restart your network module of the server which can be done with the following command:

sudo /etc/init.d/networking restart

When the restart is complete you should be able to ping the default gateway and/or Google DNS (8.8.8.8 or 8.8.4.4). Next you need to install some text based web browser like Lynx, this requires you to have a internet connection on some different machine and a USB-stick. You need to download a .deb-file of Lynx which can be found at http://pkgs.org/ubuntu-12.04/ubuntu-main-amd64/lynx-cur_2.8.8dev.9-2_amd64.deb/download/

Now download the file and transfer it your USB-stick (has to be FAT or alike for your Ubuntu Server to be able open it). To access the USB-stick on the server you first need to mount which requires a little work:

sudo mkdir /media/external/
sudo mount -t vfat /dev/sdb1 /media/external -o uid=1000,gid=1000,utf8,dmask=027,fmask=137

The code above assumes that USB-stick in the sdb1 in dev and that it uses a FAT filesystem, if this is not the case please consult the Ubuntu Help pages. To unmount the USB-stick again use the following command:

sudo umount /media/external

Now copy the .deb-file on to the server, i.e. your home folder, and execute it:

cp /media/external/lynx.deb /home/rewt/lynx.deb
cd /home/rewt/
sudo dpkg -i lynx.deb

Now that you have install Lynx all you need to do is start with some random target like Google and follow the instruction on the screen from NFIT.

lynx google.dk

After the recommended reboot of the system should you now be able to go any website with Lynx, use apt-get and other services.