Category Archives: Technology

Everything related to IT, coding and technology in general

Port Channel between two (Cisco Catalyst) switches

Connecting switches with two or more Ethernet cables is a piece of cake :)
All you need to do is create/configure a port-channel on both switches and plug in the cables.

The following setup should work on Cisco Catalyst switches. Three different VLANs are used:
Access ports for clients (vlan2) and server/admin network (vlan1) and voip (vlan3).

Step 1:
Define port-channel (Switch A)

interface Port-channel2
description ### Uplink-Channel to switch B ###
switchport trunk allowed vlan 1,2,3
switchport mode trunk
switchport nonegotiate

Step 2:
Assign port-channel to physical interfaces (Switch A)

interface GigabitEthernet0/1
description ### Uplink-Channel to switch B ###
switchport trunk allowed vlan 1,2,3
switchport mode trunk
switchport nonegotiate
channel-group 2 mode active

interface GigabitEthernet0/2
description ### Uplink-Channel to switch B ###
switchport trunk allowed vlan 1,2,3
switchport mode trunk
switchport nonegotiate
channel-group 2 mode active

Please note that [id] in “channel-group [id] mode active” must match [id] in “interface Port-channel[id]”

Step 3:
Create a port-channel and assign it to physical interfaces the same way as on Switch A now on Switch B

interface Port-channel2
description ### Uplink-Channel to switch A ###
switchport trunk allowed vlan 1,2,3
switchport mode trunk
switchport nonegotiate

interface GigabitEthernet0/1
description ### Uplink-Channel to switch A ###
switchport trunk allowed vlan 1,2,3
switchport mode trunk
switchport nonegotiate
channel-group 2 mode active

interface GigabitEthernet0/2
description ### Uplink-Channel to switch a ###
switchport trunk allowed vlan 1,2,3
switchport mode trunk
switchport nonegotiate
channel-group 2 mode active

Step 4:
Get yourself two Ethernet cables and plug them in

psql – return multiple results in bash

Lets say you want to run a “select” statement against your PostgreSQL database with the tool “psql” in your shell and the query returns values from different columns (like “select A,B,C,D from abc;”) you might do it like this:

psql -A -t -q -c "select A,B,C,D from abc;" -U user -d db

The result looks like this:

18|13.5|3|9

You definitely want to have the values in different variables so it is easier to work with them.
I prefer to do it like this

DATA=$(psql -A -t -q -c "select A,B,C,D from abc;" -U user -d db)
ONE=$(echo $DATA | awk -F'|' '{print $1}')
TWO=$(echo $DATA | awk -F'|' '{print $2}')
THREE=$(echo $DATA | awk -F'|' '{print $3}')
FOUR=$(echo $DATA | awk -F'|' '{print $4}')

After this the variables ONE, TWO, THREE and FOUR contain the values from the query.

docuwiki on QNAP

Since a lot of people recommended docuwiki for setting up a quick and easy way to document stuff I wanted to give it a try!
As I own a recent QNAP home storage (which supports vhosts, php, … and all other required things) why not combine them :)

First, enable the webserver (Network Services -> Web Server) and then switch on vhost support.
Create a new vhost for your new docuwiki installation with port 80 and /Web/docuwiki as path.
Since the folder “docuwiki” is not created automatically, log into your QNAP with SSH and create the folder.

Find your way to the docuwiki website (https://www.dokuwiki.org/) and download the most recent version as tar.gz. You might want to use wget to download it directly onto you QNAP.

wget http://www.splitbrain.org/_media/projects/dokuwiki/dokuwiki-2012-10-13.tgz -O /share/Web/docuwiki/dokuwiki-2012-10-13.tgz

Extract the tgz file into /Web/docuwiki and point your browser to http:///docuwiki
The build-in installer should come up and ask you some simple things.
If docuwiki is not happy with some of your folder permissions, add write permission to the listed folders with chmod

Have fun!