RcTools

From Bubble
Jump to: navigation, search

mac2ip

#! /bin/sh
#
# $Id: mac2ip,v 1.1 2004/03/21 21:49:39 pvanhaes Exp $
#
# Mac2IP
#	Generates an IP address based on the interface mac address
#	10.mac.mac.mac
#
INTERFACE=${1:-"eth0"}
		
MAC=`/sbin/ifconfig $INTERFACE | /bin/sed -n 's/.*HWaddr\(.*\)/\1/p'`
B4=`echo $MAC | /usr/bin/cut  -f6 -d ':'`
B3=`echo $MAC | /usr/bin/cut  -f5 -d ':'`
B2=`echo $MAC | /usr/bin/cut  -f4 -d ':'`
/usr/bin/printf "10.%d.%d.%d\n" 0x$B2 0x$B3 0x$B4

mac2ip-ng

il faut maintenant rajouter des option en fonctiond range sachant que le deux premier nombre de l ip final sont statiques les règles sont.


Name, Network block, Sub-network size, Use.

ReseauCitoyen 10.91.0.0/16 /27 Peerings (Routing)

ReseauCitoyen 10.93.0.0/16 /27 Omnis (Usage)

ReseauCitoyen 10.94.0.0/16 /27 Omnis (Usage)

ReseauCitoyen 10.95.0.0/16 /27 Omnis (Usage)

Detached 10.97.0.0/16 /? http://www.detached.be joris@linux.be

WirelessAntwerpen 10.98.0.0/16 /24 http://www.wirelessantwerpen.be info@wirelessantwerpen.be

WirelessCity 10.99.0.0/16 /? http://www.wireless-city.be info@wireless-city.be

mac2ip not /8

#! /bin/sh
#
# $Id: mac2ip,v 1.1 2004/03/21 21:49:39 pvanhaes Exp $
# toute petite modification de dako
# (Mac2IP)mac2ipinfrach.ch149
# les regles d atribution des range sont a jour et en evolution constante
#	Generates an IP address based on the interface mac address
#	10.n.mac.mac
#
INTERFACE=${1:-"eth0"}
MAC=`/sbin/ifconfig $INTERFACE | /bin/sed -n 's/.*HWaddr\(.*\)/\1/p'`
B4=`echo $MAC | /usr/bin/cut  -f6 -d ':'`
B3=`echo $MAC | /usr/bin/cut  -f5 -d ':'`
/usr/bin/printf "10.94.%d.%d\n" 0x$B3 0x$B4

=web mac2ip

by gaets

<html>
<body>
<form action="" method="post">
yo mec donne ta mac : <input type="text" name="mac" value="<?=$_POST['mac']?>"/> <input type="submit" value="go!"/>
</form>
<? if(isset($_POST['mac']))
{
$mac=explode(':',$_POST['mac']);?>
<?printf("voici  ton ip:  10.%d.%d.%d ",hexdec($mac[3]),hexdec($mac[4]),hex
(19:47:40) gaetan: dec($mac[5]));?>
<?printf("voici  ton ip:  10.%d.%d.%d ",hexdec($mac[3]),hexdec($mac[4]),hexdec($mac[5]));?>
<?printf("Peering, voici  ton ip:  10.91.%d.%d ",hexdec($mac[4]),hexdec($mac[5]));?>
<?printf("Omnis1,  ton ip:  10.93.%d.%d ",hexdec($mac[4]),hexdec($mac[5]));?>
<?printf("Omnis2,  ton ip:  10.94.%d.%d ",hexdec($ma
(19:47:40) gaetan: c[4]),hexdec($mac[5]));?>
<?printf("Omnis3,  ton ip:  10.95.%d.%d ",hexdec($mac[4]),hexdec($mac[5]));?>
<?
}
?>
</body>
</html>


dev

- l aspect final devrait donner mac2ip -i interface -t type (type= rcomnié' wa rc5g rclan detached freifunk....)


#! /bin/sh
#
# $Id: mac2iprc-ng,v 0.1 2007/03/28 21:49:39 dako Exp $
#
# Mac2IP
#	Generates an IP address based on the interface mac address
#	10.n.mac.mac
#n=type of range determined by type of interfaces
usage() {
 cat <<-EOF
       Usage: $0 [options]
       Options:
         -t|--typeofinfra <typeofinfra>          set good range
         
EOF
}
# Parse options
read_opt() {
 while [ $# -gt 0 ]
   do
   case "$1" in
     -t|--type)
       usage
       exit 0
       ;;
esac
   shift
 done
}
INTERFACE=${1:-"eth0"}
TYPE=${1:-"rcomni"}
		
MAC=`/sbin/ifconfig $INTERFACE | /bin/sed -n 's/.*HWaddr\(.*\)/\1/p'`
B4=`echo $MAC | /usr/bin/cut  -f6 -d ':'`
B3=`echo $MAC | /usr/bin/cut  -f5 -d ':'`
B2=`echo $type`
/usr/bin/printf "10.%d.%d.%d\n" 0x$B2 0x$B3 0x$B4