Replacing strings inside a specific filetype

Recently I made some spelling mistake (due to lack of knowledge) in a php project. Until I realized I had around 40 files with the typo in various places like table & function names, comments and so on.

To search for the affected files is pretty easy:

find . -type f -name "*.php" | xargs -l10 grep "tyrpo

To replace the typo as usual sed comes to the rescue:

find -type f -name "*.php" -exec sed -i 's/tyrpo/typo/' {} \;

Squeeze: Virtualbox – routing on vboxnet0

I Installed Virtualbox recently on my Thinkpad to setup 3 Linux guests for a lab environment.
The guests are configured with the Host-Only adapter. The Host-Only adapter adds a virtual network interface vboxnet0 to the host system (default ip: 192.168.56.1) and provides dhcp for the guests.
NAT mode was no option since I need to access the guests from the host network. Bridge-Mode was also no option since my thinkpad is configured for dhcp (office and home use). In bridge mode my guests would get a different IP depending on if I’m at work or at home. I’d have to reconfigure my external tools everytime I switch networks or go for static IPs which would led to routing problems.
Host-network seemed to be the most viable option here.

While the guest can communicate through the host-only adapter there’s the problem that they have no internet access because vboxnet0 is not routed.
To get this working, enable ip_forwarding and proxy-arp.

echo 1 > /proc/sys/net/ipv4/ip_forward
echo 1 > /proc/sys/net/ipv4/conf/all/proxy_arp

Now add add default route in your guests pointing to the vboxnet0 iface:

route add default gw 192.168.56.1

And finally enable NAT on the host:

iptables -A POSTROUTING -t nat -s 192.168.56.0/24 -j MASQUERADE

You now have a working DHCP guest network even if your not connected to the LAN and you additionally have internet when your connected to the lan.

Krishan goes LPI

Horray \o/
Finally made my first LPIC!

670 of 800 points in Exam 101
700 of 800 points in Exam 102

40% in User Interface and Desktops… pffff… who needs that anyway?
100% Security & 100% System essentials that`s the stuff that matters 🙂

That whole localization stuff nearly broke my neck… I hope LPIC-2 will feature some more essential and usefull stuff (just my opinion)

PXE booting an installed debian system

In our networks lab some students have the task to build a compact linux cluster system. The cluster consists of 10 low-power boards we have lying around which serve as the cluster nodes and one board with a harddisk which serves as the master node. The whole cluster is meant to be a rendering farm for blender utilizing farmerjoe.

The 10 cluster nodes are diskless and need to boot via PXE from the master node’s harddisk.

Tutorials on the net are mostly for PXE booting an installation of some linux distro or for booting a prebuild live system like Knoppix.

What we need is to boot a customized linux environment with some modified scripts and some packages already installed (blender) – all this without messing around too much with initrds and init-scripts (time is short).

Continue reading

I spy with my little eye…

You may have noticed the screenshots in yesterdays post showing a map of corfu (greece) with an overlay which obviously represents some recorded gps track.

For reference, here’s the screenshot:

This shot is from a project I recently revived after it’s been dormant on my harddisk for a few month.

Initially I planned to write an application where I could upload my bicycle tours and create some per-month statistics with some fancy graphs (hence the project-name  ‘bike’ in the screenshot)

Continue reading