public inbox for b.a.t.m.a.n@lists.open-mesh.org
 help / color / mirror / Atom feed
* [B.A.T.M.A.N.] Internet gateway or not: dhcp or static ip?
@ 2012-07-19  1:18 Geneviève Bastien
  2012-07-19  1:34 ` HeXiLeD
  2012-07-19  1:35 ` Guido Iribarren
  0 siblings, 2 replies; 5+ messages in thread
From: Geneviève Bastien @ 2012-07-19  1:18 UTC (permalink / raw)
  To: The list for a Better Approach To Mobile Ad-hoc Networking

[-- Attachment #1: Type: text/plain, Size: 1538 bytes --]

Hi!

I had a chat the other day on IRC about how to assign ip addresses 
whether there is an internet gateway available or not.

Here is the problem and the solution I came up with.  Let me know if 
that makes sense or if I'm complicating my life.

* Problem *

Our network is still small, there may or may not be an internet gateway 
available on it, it doesn't matter.  From what I read here 
http://www.open-mesh.org/projects/batman-adv/wiki/Gateways for nodes to 
have access to the internet, the internet gateway has to be a dhcp server.

The node requests an ip by dhcp and then knows what the default route 
is.  But if the gateway disappears, there is no more dhcp server, the 
nodes do not have ip addresses and the mesh network is about useless.

But if I set nodes with static ips, then the mesh is routable all the 
time, but nodes do not know the default route to reach the internet.

Am I right so far?

* Solution *

Someone on irc pointed me out to this page: 
http://www.open-mesh.org/projects/batman-adv/wiki/Uevent
I use this uevent to send a dhcp request if a gateway becomes available 
or go back to a static ip if all gateways are gone.

Attached is the hotplug script I use.  It is in 
/etc/hotplug.d/net/99-batman-adv-gw.  It supposes the interface is 
configured by default with a static ip.

It works perfectly, but I can't believe there is no simpler solution to 
this.  Our problem should be a quite common one.  What is the general 
solution to it?

Thanks,
Geneviève

[-- Attachment #2: 99-batman-adv-gw --]
[-- Type: text/plain, Size: 729 bytes --]

#!/bin/sh

# This is the interface as mentioned in the /etc/config/network file
IMESH="lan"

# This is the interface on which to ask for dhcp.  May not be same as previous if interface is a bridge, like br-lan
IDHCP="br-lan"

hostname=$(uci get system.@system[0].hostname)

case "$ACTION" in
	change)
		if [ "$BATTYPE" == "gw" ]; then
			case "$BATACTION" in
				add)
					logger "Now has a gateway available.  Will request dhcp."
					udhcpc -i $IDHCP -h $hostname
					;;
				del)
					logger "No more gateway available.  Will go back to static ip."
					ifdown $IMESH
					ifup $IMESH
					;;
				change)
					logger "New default gateway.  Will request dhcp"
					udhcpc -i $IDHCP -h $hostname
					;;
			esac
		fi
		;;
esac


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-07-19 21:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-19  1:18 [B.A.T.M.A.N.] Internet gateway or not: dhcp or static ip? Geneviève Bastien
2012-07-19  1:34 ` HeXiLeD
2012-07-19  1:35 ` Guido Iribarren
2012-07-19 13:57   ` Geneviève Bastien
2012-07-19 21:28     ` Guido Iribarren

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox