Python script to generate RADIUS users

22 12 2015

Just for future reference, I wrote this quick script using python to generate RADIUS users in the Freeradius /etc/raddb/users file.  Makes light work of what I used to do rather painfully in Excel:

 

__author__ = 'amulheirn'

# Create lots of radius users for /etc/raddb/users file

interface = 'ge-0/2/0'        # Local source interface
ipaddr = '89.20.80.'          # First three octets of IP addr
startuser = 1                 # Start of the user range
enduser   = 20                # End of the user

for i in range (startuser, enduser):
    print 'user%d@customer.com     Cleartext-Password := \"password\"' % (i)
    print '                        Service-Type := \"Framed-User\",'
    print '                        Framed-Protocol := \"PPP\",'
    print '                        Framed-IP-Address := \"%s%d\",' % (ipaddr, i)
    print '                        Context-Name := \"tuk_llu\",'

    
print "======[END]====="
Advertisements




First steps with Python and Junos

27 04 2015

I’m just spending the day trying to get my head around some very basic automation, so I thought I would install Python 2.7 and work through some of the tutorials on the Techwiki to see how I get on.

Read the rest of this entry »