Receiving static routes through DHCP in Fedora 12

So, today I had this very simple problem – to add static route to a certain network on my laptop 🙂 It really is as simple as:

ip route add network/mask via gateway

But as I’m quite lazy, to add this every time I need access to that network (the laptop is using NetworkManager + DHCP), I’ve decided to push this config through the DHCP server.

Here started the funny part – it seems that at this point this is not so trivial and you need to make modifications to BOTH the server and the client.

The Server

Let’s start with the server as this was the easy part. The only thing that is needed there is to add an DHCP option 121. In my case, as I’m using dnsmasq, this was the relevant option that should be added in /etc/dnsmasq.conf:

dhcp-option=121,10.10.0.0/24,172.16.1.100

This option defines all classless static routes that will be advertised by the DHCP server. If you need more than one route, the above can be changed like this:

dhcp-option=121,10.10.0.0/24,172.16.1.100,192.168.1.0/24,172.16.1.200

The Client

Now let’s go on the client side. There seems to be ALLOT of misunderstandings between NetworkManager and dhclient configurations. I took me quite a lot of time to figure it out, where what should be changed in order the NetworkManager to get the proper configuration from dhclient.

The first thing that should be done is to inform dhclient that you need this DHCP option 121 requested from the server. In order this  configuration to be picked up from NetworkManager also, you’ll have to edit (most probably create) /etc/dhclient-eth0.conf, where eth0 is the interface where the static routes should be added:

option classless-routes code 121 = array of unsigned integer 8;
script "/usr/local/sbin/dhclient-script-networkmanager";
also request classless-routes;

Note, that adding this config to /etc/dhclient.conf didn’t work for me. NM picked the config after the file was moved to /etc/dhclient-eth0.conf.

So now, the server is ready to send static routes, the client is ready and is hopefully at this point receiving these routes. But, but this by itself does not do anything to modify the routing table. You’ll need to add /etc/dhcp/dhcp-exit-hook file for dhclient, that will parse the DHCP option 121. I found how this could be done here on this blog. You can copy the file from there, or below here:

#!/bin/bash
#
# /etc/dhcp/dhclient-exit-hooks
#
# This file is called from /sbin/dhclient-script after a DHCP run.
#
#
# parse_option_121:
# @argv: the array contents of DHCP option 121, separated by spaces.
# @returns: a colon-separated list of arguments to pass to /sbin/ip route
#

function parse_option_121() {
result=""
while [ $# -ne 0 ]; do
mask=$1
shift
# Is the destination a multicast group?

if [ $1 -ge 224 -a $1 -lt 240 ]; then
multicast=1
else
multicast=0
fi

# Parse the arguments into a CIDR net/mask string
if [ $mask -gt 24 ]; then
destination="$1.$2.$3.$4/$mask"
shift; shift; shift; shift
elif [ $mask -gt 16 ]; then
destination="$1.$2.$3.0/$mask"
shift; shift; shift
elif [ $mask -gt 8 ]; then
destination="$1.$2.0.0/$mask"
shift; shift
else
destination="$1.0.0.0/$mask"
shift
fi

# Read the gateway
gateway="$1.$2.$3.$4"
shift; shift; shift; shift
# Multicast routing on Linux
#  - If you set a next-hop address for a multicast group, this breaks with Cisco switches
#  - If you simply leave it link-local and attach it to an interface, it works fine.

if [ $multicast -eq 1 ]; then
temp_result="$destination dev $interface"
else
temp_result="$destination via $gateway dev $interface"
fi

if [ -n "$result" ]; then
result="$result:$temp_result"
else
result="$temp_result"
fi
done
echo "$result"
}

function modify_routes() {
action=$1
route_list="$2"
IFS=:
for route in $route_list; do
unset IFS
/sbin/ip route $action $route
IFS=:
done
unset IFS
}

if [ "$reason" = "BOUND" -o "$reason" = "REBOOT" -o "$reason" = "REBIND" -o "$reason" = "RENEW" ]; then

# Delete old routes, if they exist
if [ -n "$old_classless_routes" ]; then
modify_routes delete "$(parse_option_121 $old_classless_routes)"
fi

# Add new routes, if they exist...
if [ -n "$new_classless_routes" ]; then
modify_routes add "$(parse_option_121 $new_classless_routes)"
fi
fi

Next you’ll need to modify the dhclient dhclient-script, so that the NetworkManager actually executes the hooks defined in /etc/dhcp/dhclient-exit-hooks. The information was found on this blog. I’ve modified the script found on that blog so that it would work on Fedora 12. Put this file in /usr/local/sbin/dhclient-script-networkmanager (If you’ve noticed we’ve already modified the dhclient-eth0.conf file and instructed the dhclient to use this script instead of the default one located in /sbin/dhclient-script):

#!/bin/bash
NM_DHCLIENT_SCRIPT=/usr/libexec/nm-dhcp-client.action


# dhclient-script for Linux. Dan Halbert, March, 1997.
# Updated for Linux 2.[12] by Brian J. Murrell, January 1999.
# Modified for Debian.  Matt Zimmerman and Eloy Paris, December 2003
# Modified to remove useless tests for antiquated kernel versions that
# this doesn't even work with anyway, and introduces a dependency on /usr
# being mounted, which causes cosmetic errors on hosts that NFS mount /usr
# Andrew Pollock, February 2005
# Modified to work on point-to-point links. Andrew Pollock, June 2005
# Modified to support passing the parameters called with to the hooks. Andrew Pollock, November 2005
# The alias handling in here probably still sucks. -mdz


run_hook() {
local script="$1"
local exit_status
shift       # discard the first argument, then the rest are the script's


if [ -f $script ]; then
. $script "$@"
fi


if [ -n "$exit_status" ] && [ "$exit_status" -ne 0 ]; then
logger -p daemon.err "$script returned non-zero exit status $exit_status"
save_exit_status=$exit_status
fi
}


run_hookdir() {
local dir="$1"
local exit_status
shift       # See run_hook


if [ -d "$dir" ]; then
for script in $(ls -1 $dir); do
run_hook $script "$@" || true
exit_status=$?
done
fi


return $exit_status
}


# Must be used on exit.   Invokes the local dhcp client exit hooks, if any.
exit_with_hooks() {
exit_status=$1


# Source the documented exit-hook script, if it exists
if ! run_hook /etc/dhcp/dhclient-exit-hooks "$@"; then
exit_status=$?
fi


# Now run scripts in the Debian-specific directory.
if ! run_hookdir /etc/dhcp/dhclient-exit-hooks.d "$@"; then
exit_status=$?
fi


exit $exit_status
}


# The action starts here
# Invoke the local dhcp client enter hooks, if they exist.
run_hook /etc/dhcp/dhclient-enter-hooks
run_hookdir /etc/dhcp/dhclient-enter-hooks.d


$NM_DHCLIENT_SCRIPT
exit_with_hooks 0
return $exit_status

Finally, if you are running SELinux like me, you’ll need to change the security context of the file, so that the dhclient could execute it:

chcon -t dhcpc_exec_t /usr/local/sbin/dhclient-script-networkmanager

And thats all – you done and good go to 🙂

Advertisements
Tagged , , , ,

Bulgarian localization for Maemo5 Fremantle: Part2

Здравейте,

най-накрая ми остана малко свободно време за да напиша какво се случва около проекта който започнах, свързан с локализацията на интефейса на Nokia N900 на български.

Първо и може би най-важно – успях с помощта на firstfan, да прехвърля проекта в един по-общ проект свързан с превода на Maemo, който се казва n900-extra-translations. Така че вече не се чувствам сам :-), а освен това и вече няма да ми се налага да се занимавам с изграждането на пакети. Което не означава, че не се налага да се занимавам с отстраняване на бъгове свързани с тези пакети. В този ред на мисли вече няма да публикувам нови пакети на сайта на проекта който първоначално стартирах в garage.maemo.org, но ще продължа да поддържам актуално git хранилището с преводите които правя във връзка с проекта.

Новите пакети могат да бъдат намерени в extras-devel (още едно предимство) под името N900-l18n-bg_BG.

Алтернативен вариант е просто да свалите някой от публикуваните .deb файлове, препоръчително е последната актуална версия, и да я инсталирате наръка през X Terminal.

В момента работя над превода на пощенския клиент (aka Modest) и въобще приложенията които ползвам най-често.

В следващите дни когато имам отново време, ще се опитам накратко да опиша какво трябва да се има превид когато се прави превод (поне моята гледна точка 🙂 и как може лесно да се включите в превеждането на останата част на интерфейса.

За финал няколко снимки с локализираната версия на Maemo.

Tagged , , ,

Bulgarian localization for Maemo5 Fremantle

Със стартирането на тази тема искам да обявя, че започнах проект за превода (неофициален) на интерфейса на Maemo5 на български, както и да дам малко информация докъде успях да придвижа за момента проекта (в момента е близо до националното дърво:-). Не знам дали някой друг в момента също не се тормози със същата задача, затова прецених, че е по-добре да обявя какво смятам да правя още в началото, така че ако има и други мераклии, да обединим усилия 

Преди да стартирам превода се консултирах с хора които имат опит в превода на приложения, така че ще направя всичко възможно превода да бъде максимално точен и коректен. Което не означава че няма да има грешки – отворен съм към конструктивна критика.

СТАТУС
За момента са преведени следните приложения:

  • адресна книга
  • телефонно приложение ( phone )
  • приложение за разговори ( conversations )
  • браузър

Всичко останало използва езика по подразбиране (en_GB).

ИНФОРМАЦИЯ ЗА ПРОЕКТА
Страница:
https://garage.maemo.org/projects/bulgarian-l10n

Изпращане на грешки (трябва да имате регистрация):
https://garage.maemo.org/tracker/?group_id=1264

Пакети:
https://garage.maemo.org/frs/?group_id=1264

Още веднъж ще наблегна че за момента превода е в МНОГО НЕЗАВЪРШЕНО състояние. Така че инсталирате пакета на своя отговорност. Нарочно не слагам описание как може да се инсталира локализацията, защото ако не знаете – най-вероятно не трябва да го правите.
На по-късен етап когато имаме пълен превод, ще се опитам да кача нещата поне в extras-devel.

Май това е засега. Когато имам някакъв напредък – ще публикувам промените тук.

Tagged , , ,

KDE needs your help (Kmail icon test)

I would like to invite everyone who has spare 5minutes to take this survey which will help polish the KMail UI.

Be KDE!

Tagged , ,

VCP4 Exam preparation

For all of you eager to become VCP4, today I’ve stumbled upon a nice practice exam which you can try before actually going to the actual VCP410 test. There you’ll find a couple of tests with both general questions and configuration maximum values (the latest can be found in the Configuration Maximums PDF). The most useful thing about that tests is that in the end you are given the chance to see where are your mistakes and which answers are the correct ones.

With that said – wish you all success with your VCP4 exam 🙂

Tagged , ,

ESX 4.0 Update 1 issue identified (update: and fixed)

For all early adopters of the latest update of the VMware hypervisor – please be aware that yesterday VMware identified a problem that could lead to a Purple Screen of Death. For more information read the full KB article

Update: Today VMware released an updated version of the vSphere ESX maked as 4.0. Update1a, which resolves the issue. You can check the same KB article for an updated information.

Tagged ,

GTD notebook calculator

Today I’ve stumbled upon a great post on The Art of Manliness site: How to make a moleskine PDA. Not that there are not other great posts on the subject, but this one has two things that grabbed my attention.

First – this is the idea of having blank stamps in front/on the back of the notebook for writing notes/ideas without even having to open the notebook! – I think this is pretty neat idea and I’m going to try it.

The second interesting thing that is mentioned in the article is about a GTD notebook calculator. This is a flash application that can help you deciding how to split the notebook for the different contexts that you need. It has a saving option, so you can update the notebook layout later if you find out that certain sections are oversized or does not fit in the current allocated pages. That way the next notebook that you start using will be better divided and that way will be better utilized 🙂

Have fun!

Tagged , , ,

VMware Workstation 6.5.3 on Fedora 11/Fedora 12

Most probably if you were trying to install the latest (6.5.3) version of VMware workstation on Fedora 11 you’ve got troubles – like me. I finally (by chance) found a workaround, not a solution, to the problem.

As the installer fails during the modules compilation/installation, the only thing that you need to do is:

  • remove the gcc package – that way effectively disabling the installer from trying to install/compile modules 🙂

Edir (Thanks to Gerard Braad – see comments bellow): alternatively you can only move the gcc binary, so that the installer would not find it:

mv $(which gcc) $(which gcc).disabled

  • install VMware-Workstation package – bare in mind that you’ll need at least 1.2GB of free space on your root volume, during that operation
  • reinstall back gcc ( and kernel-devel if you don’t have it) or (see above) move back the gcc binary

mv $(which gcc.disabled) $(echo $(which gcc.disabled) | sed ‘s/\.disabled$//’)

  • run VMware Workstation and let it compile/install the new modules

That’s all

Tagged , ,

File indexing on Fedora 11 for KDE4.3

Today I’ve got really frustrated that I cannot search through my documents quickly and made a quick research to see why Strigi (which is an file indexing service) cannot be integrated with Nepomuk under my KDE 4.3 installation. I won’t go in details why it was not working but if you would like to make that integration you can read first that blog post which I found very useful:

Nepomuk + Strigi –> Resolving the mystery

With two words – there is a missing part which is responsible for the nepomuk->strigi integration and this is the soprano backend. Reading the instructions in the above blogpost I’ve just recompiled the rpm for the current 4.3 version of KDE.

So what you need to do is grab and install this package

#yum localinstall –nogpgcheck soprano-backend-sesame2-2.3.0-3.fc11.i386.rpm

#yum install strigi

nepomik-strigi

After this – its up to you – Either reboot or relogin to your KDE session and you should see something like this:

So – fire up dolphin and start your search now! 🙂

Tagged , , , ,

GTD and mail filters

I was cleaning my INBOX some weeks ago when I’ve decided to give the GTD idea a try and I found an interesting fact – you do not need mail filters.

Why? I use filters in general to move different messages depending on sender or subject to certain folders upon receiving, but given the GTD idea that EVERY mail message must be processed, these filters seems to contradict with it.

How can one be certain that a message will be processed if it is delivered within a folder “Customers -> Very Important Customer” ? If it is in the INBOX I will definitely notice it, decide what to do with it and just after that move it to the respective folder. That is why I decided to remove all my mail filters after the initial INBOX cleaning and now nothing can escape from my eyes 🙂 That way you also pro actively delete all non important/not needed emails that otherwise just end up in some folder and you never read them.

Now that is the way I like my email – an empty INBOX folder with not a single message left behind.

P.S. It took me a total of 1 hour to clean up the INBOX initially with 8 months of emails in it – so don’t be scared it is not that hard – DO IT NOW!

Tagged , ,