Category Archives: Linux

Network Configuration with Raspberry Pi – WiFi and Ethernet

I was configuring my Raspberry Pi (B+) on Raspbian via the ethernet port, but also wanted to get the WiFi adapter up and running. I had some issues getting both running at the same time though – don’t know why as the device is running headless, but as soon as I disconnected the ethernet cable the WiFi was working as you would expect.

The workaround for this is a little messy, but I thought I’d share it here. First of all, use either the GUI or the config file to configure the WiFi (GUI is easier). The key point here, as I want to use a static IP when on my home network and DHCP the rest of the time, is to set the ‘id_str’ parameter to something meaningful e.g. home_network. The id_str allows us to match a WiFi access point to an interface configuration.

WiFi Config File

This is stored in /etc/wpa_supplicant/wpa_supplicant.conf

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
ssid="network-SSID"
psk="my_network_key"
proto=RSN
key_mgmt=WPA-PSK
pairwise=TKIP
auth_alg=OPEN
id_str="<strong>home_static</strong>"
}

Interfaces File

This is /etc/network/interfaces
Note how the iface name is the same as the id_str for the home network/static IP configuration

auto lo

iface lo inet loopback

allow-hotplug eth0
iface eth0 inet dhcp

allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf

iface <strong>home_static</strong> inet static
address 192.168.1.20
netmask 255.255.255.0
gateway 192.168.1.1

iface default inet dhcp

The Weirdness

For some reason if we hotplug the Ethernet port we disable wlan0 (and it makes a right mess of things as the sshd and other services aren’t bound to the correct interface any more).

So we edit /etc/default/ifplugd

INTERFACES="eth0"
HOTPLUG_INTERFACES="eth0"
ARGS="-q -f -u0 -d10 -w -I"
SUSPEND_ACTION="stop"

And to give the WiFi dongle a kick at startup we add the following to /etc/rc.local.

# Disable the ifplugd eth0
sudo ifplugd eth0 --kill
sudo ifup wlan0

Raspberry Pi as a server

I’m planning on using a Raspberry Pi as a Webserver at some point, but wanted to lock it down a bit more then the default would allow, so here are a few quick notes on how to do that. I’m assuming that you have network connectivity here and can login via ssh.

Update the Pi

sudo apt-get update
sudo apt-get upgrade
sudo rpi-update
reboot

Secure SSH Acess

For starters, lets create a new account, get the privileges correctly, and then delete the default ‘pi’ account – just a little bit too easy.

sudo adduser serverpi

Fill in the information, and set a good password (long, mix of uppercase, lowercase, symbols, etc.)

Once this user exists, we should add them to all the groups as the pi account:

~ $ groups pi
pi : pi adm dialout cdrom sudo audio video plugdev games users netdev input spi gpio

serverpi@my-raspberry-pi ~ $ sudo usermod -a -G sudo serverpi
serverpi@my-raspberry-pi ~ $ sudo usermod -a -G adm serverpi
serverpi@my-raspberry-pi ~ $ sudo usermod -a -G pi serverpi
serverpi@my-raspberry-pi ~ $ sudo usermod -a -G dialout serverpi
serverpi@my-raspberry-pi ~ $ sudo usermod -a -G cdrom serverpi
serverpi@my-raspberry-pi ~ $ sudo usermod -a -G audio serverpi
serverpi@my-raspberry-pi ~ $ sudo usermod -a -G video serverpi
serverpi@my-raspberry-pi ~ $ sudo usermod -a -G plugdev serverpi
serverpi@my-raspberry-pi ~ $ sudo usermod -a -G games serverpi
serverpi@my-raspberry-pi ~ $ sudo usermod -a -G users serverpi
serverpi@my-raspberry-pi ~ $ sudo usermod -a -G netdev serverpi
serverpi@my-raspberry-pi ~ $ sudo usermod -a -G input serverpi
serverpi@my-raspberry-pi ~ $ sudo usermod -a -G spi serverpi
serverpi@my-raspberry-pi ~ $ sudo usermod -a -G gpio serverpi

Ideally, set the server to use PublicKey Authentication, and disable passwords – plenty of guides online to do this (create .ssh directory and add your public key to the authorized_keys file).

Test the login with the new account.

Delete the default user ‘pi’

sudo userdel pi
sudo rm -rf /home/pi

Improving the Performance

Run the configuration utility:

sudo raspi-config
  • Expand the filesystem
  • Set the locale and timezone
  • Set overclock to ‘modest’
  • Use the advanced options to set the hostname to something meaningful, and since we aren’t using a display set the GPU memory to something more modest e.g. 32 or 0

Finish up and reboot

Basic Intrusion Prevention

Something that any linux based box connecting to the internet should install is fail2ban. This is a python based framework that monitors log files and will block IP Addresses that are continually making login attempts. The ‘banned’ IP is locked out for a configurable length of time, and then unblocked.

Standard package can handle sshd, Apache, etc. which suits my purposes nicely.

sudo apt-get install fail2ban

Updating Raspberry Pi

Recently expanded my collection of Raspberry Pi devices to 3 (1 Model B and 2 B+) and had to go ferreting around to find how to fully update them.

First up, make sure there is a network connection. Then update the package list:

sudo apt-get update

Then upgrade all the packages:

sudo apt-get upgrade

Finally upgrade the kernel and firmware:

sudo rpi-update
*** Raspberry Pi firmware updater by Hexxeh, enhanced by AndrewS and Dom
*** Performing self-update
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 7635 100 7635 0 0 21720 0 --:--:-- --:--:-- --:--:-- 26978
*** Relaunching after update
*** Raspberry Pi firmware updater by Hexxeh, enhanced by AndrewS and Dom
*** We're running for the first time
*** Backing up files (this will take a few minutes)
*** Backing up firmware
*** Backing up modules 3.12.28+
*** Downloading specific firmware revision (this will take a few minutes)
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 168 0 168 0 0 267 0 --:--:-- --:--:-- --:--:-- 359
100 23.0M 100 23.0M 0 0 1061k 0 0:00:22 0:00:22 --:--:-- 1412k
*** Updating firmware
*** Updating kernel modules
*** depmod 3.12.33+
*** Updating VideoCore libraries
*** Using HardFP libraries
*** Updating SDK
*** Running ldconfig
*** Storing current firmware revision
*** Deleting downloaded files
*** Syncing changes to disk
*** If no errors appeared, your firmware was successfully updated to 7c60d6b268cbc7a2ac6b652cb0ecb3495c636ad8
*** A reboot is needed to activate the new firmware
pi@raspberry-watcher ~ $

And reboot

sudo reboot

Configuring Q-in-Q (802.1ad) on Arista

Lately I’ve been playing around with some Arista Networks switches (nice switches, not a fan of the Cisco-style CLI) and was having issues with the configuration of Q-in-Q for VLANs (802.1ad or double tagging). There is an interesting little gotcha for the port configuration on those puppies:

interface Ethernet1
switchport access vlan 500
switchport mode dot1q-tunnel

This will tag the packet with an outer VLAN tag of 500, while leaving the inner tag untouched.

UPC Ireland – Tiers of Service and NAT

The 120Mbps Tier

As a long time and very happy UPC customer (120Mb unlimited package) I was quite pleased with the service offered – to local speedtest server 10ms RTT, 118Mbps down, 10Mbps up, generous ‘fair-use’ limits and most importantly a public IP address.

Ideally, I’d like to use my own modem/router but instead I’m stuck with the Thompson TWG870, though to be fair it’s not the worst in the world. Not sure when, if ever, the firmware has ever been updated but all the important settings are at least accessible.

The 60Mbps Tier

With a new job I’m based in Limerick at least some of the time so made the decision to put in the basic package (60Mbps, 30Gb cap) and not bother with TV service. Installation was fine but no self-install so ended out having to sit at home for the scheduled installation window… 09:00 – 18:00 – they do make it easy for themselves.

Once installed and the tech out the door I had a poke at the new box. This one seems to be infamous as the Technicolor 7200 – clearly one of the cheapest cable modem/Wireless APs ever built. Prettier interface but fewer configuration options. Also issues with the WiFi connections to a Mac (not the only router to have this problem to be fair – I blame Apple).

Horizon WiFree

Interestingly the default internal IP range for the network is 192.168.1.0/24. When I tried to switch it to the more conventional 192.168.1.0/24 I was told that that address range is already in use. It seems that Horizon Wi-Free is configured to use the 192.168.1.0/24 subnet and that portion of the configuration is hidden away somewhere with the only options being to turn it on or off.

Public IPs

As I stated above something I love about the service I had was the public IP address. Making full use of the options that gives you I have a number of self-hosted ‘cloud’ services running on a Linux box I keep running – file store, VPN, Media Library, Document backup, etc. For the new gaff I have a RaspberryPi B+ that I use to run RASPBMC and a few other small services, but just by default had intended to make that internet accessible – sadly it was not to be.

It seems that the lowest tier of UPC has you running through a NAT system at some point. So while I have the port forwarding setup on the router, nothing reaches the Pi. It also seems to have some very aggressive ageing of flows running – had to set SSH keepalives to <60 seconds or the connections were constantly dropping. Poking at the IP address my connections seem to be originating from I see that there are two different pools in use (not unexpected in any case e.g. Dublin vs. rest of country).

Lowest Tier (60Mbps)


[colinmac@thor][~]=> dig +answer -x 188.141.a.b

; <<>> DiG 9.8.4-rpz2+rl005.12-P1 <<>> +answer -x 188.141.a.b
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, a.bid: 22797
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;115.82.141.188.in-addr.arpa.   IN      PTR

;; ANSWER SECTION:
115.82.141.188.in-addr.arpa. 86389 IN   PTR     188-141-82-115.dynamic.upc.ie.

;; Query time: 15 msec
;; SERVER: 89.101.160.5#53(89.101.160.5)
;; WHEN: Tue Aug 26 09:04:24 2014
;; MSG SIZE  rcvd: 88

Notice the Pointer Record has the dynamic.upc.ie

Middle Tier (120Mbps)


[colinmac@thor][~]=> dig +answer -x 109.255.x.y

; <<>> DiG 9.8.4-rpz2+rl005.12-P1 <<>> +answer -x 109.255.x.y
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 54912
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0

;; QUESTION SECTION:
;7.123.255.109.in-addr.arpa.    IN      PTR

;; AUTHORITY SECTION:
255.109.in-addr.arpa.   600     IN      SOA     ns1.upc.biz. hostmaster.chello.at. 2010071503 86400 7200 2592000 7200

;; Query time: 33 msec
;; SERVER: 89.101.160.5#53(89.101.160.5)
;; WHEN: Tue Aug 26 09:05:04 2014
;; MSG SIZE  rcvd: 111

Whereas for the higher tier we have the Start Of Authority record pointing back towards the older chello and our nameserver is sitting within a biz domain.

Will add more to this post later 🙂

OpenContrail – Service Chaining

This post is to cover one of the most (to my mind) interesting and powerful features of OpenContrail at the moment which is the service chaining. As part of the NVF approach we are looking to virtualise services (read boxes) that are already part of current networks.

The basic idea is to get away from services as appliances e.g. Firewall, Load Balancer, DPI, etc. are added to the network as boxes/appliances – when more capacity is required you add bigger boxes, and when you hit the largest size of box available from the vendor you either buy more or wait for the ‘next-generation’ platform to be released.

While there are good reasons for the box/appliance approach:

  • Simpler troubleshooting for TAC
  • Tested and verified performance levels – will do X pps for average packet size of Y
  • Easy scoping of scale – we have N Mbps of traffic, what do we need to DPI this at the current levels of growth

if we are going down the SDN/NFV route obviously this approach will not work anymore since you have a virtualised appliance living somewhere in a data center, and ideally there is no contention/undercapacity where that appliance is living. As the demands scale up more appliances are activated to handle the new load, and as demand drops resources can be released back into the pool.

Traditional Service Chains

Standard network deployments consist of service chains, though they are not very flexible or dynamic. Consider the path a typical webserver would take to reach the Internet. From the internet, through a gateway towards a firewall (typically providing NAT services). From there through a Load Balancer and then to the server farm. Typically each link in the chain is a logically separated path e.g. a VLAN.

traditional service chain

Dynamic Service Chaining

The more ideal approach is to have the different services e.g. Firewall, NAT, etc. provided on virtualised appliances that can also be hosted in our data center and scaled as required. These services can be added and removed from the traffic path as required, either by the customer or the hosting provider. Consider the use case of having vCPE [virtualised Customer Premises Equipment] – a simple box is installed on the customer site and all configuration and services and be added and removed in the Data Center.

One potential offer could be of a basic unfiltered connection, with firewall and DPI as a basic services package for €N per month, with other optional services on top of that. A simple web front end could effectively provide an ‘app store’ for network services, with pre-packaged services available for quick and easy deployment.

service chaining - outlineService Chaining in Contrail

Network Policies allow the tenant to define what traffic is allowed to flow between which networks. As part of the policy configuration a set of service instances can also be included, to be applied in the order in which they are configured e.g. svc1, svc2, svc3 will have Network A -> svc1_vm -> svc2_vm -> svc3_vm -> Network B, with the reverse path also created automatically.

This is achieved through manipulation (automatically) of the BGP Next-Hops between the created routing instances (also automatic).

service chaining - using the routing instancesService Instance

The Service Instance is simply a virtual machine that is providing the service. A most basic example would be a linux VM acting as a router between two virtual networks (not required of course since policies can do this for us, but any service that a linux server can provide can be chained). The convention is that there is a Left interface attached to the source network and a right interface attached to the destination network. We typically also include a 3rd interface on a Management interface to allow for the service VMs to be managed out-of-band of the traffic flow.

Configuring Service Chaining

This requires 3 elements:

  1. Service Template
  2. Service Instance
  3. Service Policy

 Service Template

The service templates are defined within the Domain and can be used, and re-used, across Projects as many times as required. Main points for Template configuration are:

Service type – main types are:

  • transparent – used for non-routed L2 services e.g. L2 Firewall
  • In-Network – provides gateway services and the traffic is routed e.g. HTTP Proxy, NAT, LB
  • In-Network NAT – same as In-Network but the return traffic doesn’t need to be routed back to the source network

Image – the GLANCE VM image that is used to provide the service

Service Instance

The service instance is the actual instantiation of the template. The main point is to add the correct virtual networks to the interfaces e.g. VN_source to Left interface and VN_destination to the Right interface.

Service Policy

The service policy allows the traffic between the virtual networks and instructs the system to chain that traffic through the service instances  – in-order.

Signalware Failing to start – nrplinker failure

I did a controlled shutdown of one of my OMNI/Signalware boxes, but when  fired it back up omni was refusing to run. The message indicated was:

+------+  go.omni  /main/sw9/86
| INFO |  Wed Jun  4 09:00:10 XXX 2014
+------+  OMNI_HOME=/PATH/ulcm
SHM=<User ID>
+------+
| INFO |  Starting nrplinker process.
+------+
nrplinker: Wed Jun  4 09:00:11 2014 Service Started.
nrplinker: Wed Jun  4 09:00:11 2014 Write error in load file /PATH/ulcm/tmp/LoadPoint.nrp
+------+
| INFO |  Starting sam_daemon.
+------+

Waiting for sam_daemon start completion../PATH/ulcm/bin/go.omni: line 467: 26194 Bus error               (core dumped) $OMNI_HOM
E/bin/usam_daemon TRACE_FILE usam_trace


+-------+  Script Aborted!
| ERROR |  SAM daemon terminated unexpectedly.
+-------+

It turns out that the / partition was full.

[siguser@hostname ~]$ /PATH/ulcm/bin/nrplinker
nrplinker: Wed Jun 4 09:15:33 2014 Service Started.
nrplinker: Wed Jun 4 09:15:33 2014 Write error in load file /PATH/ulcm/tmp/LoadPoint.nrp
[siguser@hostname ~]$ echo "" > /PATH/ulcm/tmp/LoadPoint.nrp
-bash: echo: write error: No space left on device
[siguser@hostname ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg00-lv_root
9.7G 9.7G 0 100% /

Clear up some space (delete old OMNI logs) and we were back in business.

 

/etc/hosts and Signalware – DFdaemon issues

While doing an install of Signalware’s SIGTRAN stack (SignalWare 9.0 SP6) I had big problems getting it to actually work. The menu install process ran as expected, but the node wasn’t commissioned and therefore the go.omni process wouldn’t start, as the DFconvert step was failing.

It turns out the root cause was a problem with DFdaemon (this is a service that has something to do with maintaining the file system used by Ulticom). The service was running, but when I tried DFdaemon_status it was timing out.

Eventually killed off the service (init kept restarting it) by commenting out the contents of the init file and kill -15 1 a few times, and ran it manually in debug mode:

root@server init]# DFdaemon -d
16:49:11  0 DFdaemon::main           : using port 10600
16:49:11  0 Platform                 : ************* CE_c *************
Name:   server
mCeIndex:       0
mLanCount:      0
Current LAN index:      0
Current status: DOWN
Synchronization status: SYNC_REQD
Pending status request list:
EMPTY

oluCEList:      8
OluCe 0:
OluCe 0:
OluCe 0:
OluCe 0:
OluCe 0:
OluCe 0:
OluCe 0:
OluCe 0:
-------------

16:49:11  0 MessageQueue::MessageQue :
16:49:11  0 MessageQueue::MessageQue :
16:49:11  0 UDPmsgQueue_c::UDPmsgQue : Recv buffer : 524288
16:49:11  0 UDPmsgQueue_c::UDPmsgQue : Send buffer : 524288
16:49:11  0 UDPmsgQueue_c::UDPmsgQue : Send buffer : 524288
16:49:11  0 DFfileList_c::initEntrie : reach the end of /opt/apps/ulcm/sls0479/dffile

16:49:11  0 UDPmsgQueue_c::startComm :
16:49:11  0 UDPmsgQueue_c::MessageQu : begin thread
16:49:11  0 global                   : DFdaemon started
16:49:11  0 DFtaskQueue_c::main      : begin thread
16:49:11  0 UDPmsgQueue_c::MessageQu : begin thread
16:49:11  0 SDFS::main               : begin thread
16:49:11  0 DFfileList_c::main       : begin thread
16:49:11  0 HealthCheck::main        : begin thread
16:49:11  0 HealthCheck::main        : wakeup before sleep
16:49:11  0 SDFS::main               : wakeup before sleep(1000)
16:49:11  0 HealthCheck::main        : wakeup after sleep
16:49:11  0 HealthCheck::main        : wakeup before sleep
16:49:12  0 SDFS::main               : wakeup after sleep
16:49:12  0 HealthCheck::main        : wakeup after sleep
16:49:12  0 HealthCheck::main        : wakeup before sleep
16:49:12  0 SDFS::main               : wakeup before sleep(1000)
16:49:12  0 HealthCheck::main        : wakeup after sleep
16:49:12  0 HealthCheck::main        : wakeup before sleep
16:49:13  0 HealthCheck::main        : wakeup after sleep
16:49:13  0 HealthCheck::main        : wakeup before sleep
16:49:13  0 SDFS::main               : wakeup after sleep
16:49:13  0 SDFS::main               : wakeup before sleep(1000)
16:49:13  0 HealthCheck::main        : wakeup after sleep
...
16:49:40  0 HealthCheck::main        : wakeup after sleep
16:49:40  0 HealthCheck::main        : wakeup before sleep
16:49:40  0 SDFS::main               : wakeup after sleep
16:49:40  0 SDFS::main               : wakeup before sleep(1000)
16:49:40  0 UDPmsgQueue_c::MessageQu : Received message from unknown sender, IP address: ::ffff:127.0.0.1    <<---- DFdaemon_status
16:49:40  0 HealthCheck::main        : wakeup after sleep
16:49:40  0 HealthCheck::main        : wakeup before sleep
16:49:41  0 HealthCheck::main        : wakeup after sleep
16:49:41  0 HealthCheck::main        : wakeup before sleep
16:49:41  0 SDFS::main               : wakeup after sleep
16:49:41  0 SDFS::main               : wakeup before sleep(1000)
16:49:41  0 HealthCheck::main        : wakeup after sleep
16:49:41  0 HealthCheck::main        : wakeup before sleep

It seems that for some reason the localhost entry for IPv6 was causing a problem. The entry that was part of the server build looked like this:

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost

It should be like this:

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

With that DFconvert ran and the rest of the process was fine.