[Bug 1406] document how to extend the range of static IP addresses
http://bugs.skolelinux.org/show_bug.cgi?id=1406
Joakim Seeberg Ravnskjær <kontakt@seebergit.dk> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |kontakt@seebergit.dk
--- Comment #2 from Joakim Seeberg Ravnskjær <kontakt@seebergit.dk> 2010-01-26 09:35:16 ---
I got this from the gathering in Oslo. As I remember it is used to
extend/shrink dhcp ranges in lenny. If someone can confirm then documenting
should be strait forward.
#!/usr/bin/python
# Author: John S. Skogtvedt <jss@bzz.no>
# Generates a LDIF based on the ranges variable.
ranges = '''
ltspserver00-19 10.0.2.10
printer00-19 10.0.2.30
static00-49 10.0.2.50
dhcp000-155 10.0.2.100
dhcp156-399 10.0.3.0 # ends at 10.0.3.243
ltsp001-253 192.168.0.1 # ltsp200-253 are dynamic
misc00-49 10.0.4.0
'''
a_template = \
'''dn: dc=%(hostname)s,dc=intern,ou=hosts,dc=skole,dc=skolelinux,dc=no
objectclass: top
objectclass: dnsdomain
objectclass: domainrelatedobject
dc: %(hostname)s
arecord: %(hostip)s
associateddomain: %(hostname)s.intern
'''
ptr_template = \
'''dn: %(ip_rev_dn)s,dc=in-addr,dc=arpa,ou=hosts,dc=skole,dc=skolelinux,dc=no
objectclass: top
objectclass: dnsdomain2
objectclass: domainrelatedobject
dc: %(ip_last_part)s
ptrrecord: %(hostname)s.intern
associateddomain: %(ip_rev)s.in-addr.arpa
'''
import re, sys
re_range = re.compile('^(.*?)(\d+)-(\d+)\s+([\d.]+)')
for line in ranges.splitlines():
m = re_range.search(line)
if not m:
continue
base, begin, end, ip = m.groups() # ('ltspserver', '00', '19', '10.0.2.10')
begin_l = len(begin)
begin = int(begin)
end = int(end)
ip_begin = int(ip.split('.')[-1]) # 10
ip_base = ip[0:ip.rindex('.')+1] # 10.0.2.
#print >>sys.stderr, m.groups(), ip_begin
for i in xrange( (end-begin)+1 ):
formatstr = '%s%0' + str(begin_l) + 'd' # '%s%02d'
hostname = formatstr % (base, i + begin) # 'ltspserver00'
hostip = '%s%d' % (ip_base, i + ip_begin)
ip_rev = hostip.split('.')[::-1] # ['10', '2', '0', '10']
ip_rev_dn = ''.join(['dc=%s,' % x for x in ip_rev])[:-1] #
'dc=10,dc=2,dc=0,dc=10'
ip_last_part = ip_rev[0] # '10'
ip_rev = '.'.join(ip_rev) # '10.2.0.10'
#print >>sys.stderr, hostname, hostip
print a_template % locals()
print ptr_template % locals()
--
Configure bugmail: http://bugs.skolelinux.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
You are watching all bug changes.
Reply to: