Syed Jahanzaib Personal Blog to Share Knowledge !

February 25, 2014

Mikrotik Script to Export PPP users to USER MANAGER

Filed under: Mikrotik Related — Tags: , , — Syed Jahanzaib / Pinochio~:) @ 10:46 AM

As requested Following is a quick and dirty way to export Mikrotik Local PPP (pppoe) users to USER MANAGER with same profile assigned as LOCAL profile section . I used the word dirty because there is no officially supported method that we can use by single CLI command or one window GUI.

Consider the following scenario:

Mikrotik is configured with PPPoE Server , and have two profiles with the name of 512k and 1mb and 6 users in ppp section …
As showed in the image below …

2-mt-profile

3-users-mt.

Our task is to migrate all local ppp users to USERMAN with minimum overhead management of manual workout.

First Open User Manager, and configure /add the NAS , so that Mikrotik can communicate with the UserMAN and wise-verse.

Now add same profiles in User Manager as present in the local Mikrotik PPP Section.
[This task can be done via CLI too, example is in the end]
As showed in the image below …

1b-userman-profiles.

.

Now as far as my dumb mind goes, I couldn’t found a way to assign profile to user using /tool userman menu, so to overcome this issue, I first created two users with same profile name and id.

Example if profile name is 512k, then create a user with name”512k” , it will be used as a master copy for cloning 😀
As showed in the image below …

1-userman.

.

Userman section is done , moving to Mikrotik Section…

Goto System > Scripts and add new script, use the following code…

# PPP Export to USERMAN SCRIPT START
:log error "Make sure you have usermanager configured properly and created same profile names with same user name (master users for cloning) in USERMAN / Jz"

# Applying Loop for ppp secret section to fetch all user details
/ppp secret
:foreach i in=[find] do={
:local username [get $i username]
:local pass [get $i password]
:local profile [get $i profile]
:local comment [get $i comment]

#Printing User names and other details for record purpose ...
:log warning "Fetching USER details from /ppp secret section , Found $name $pass $profile $comment for EXPORT"

#Creating Users in User Manager with ID / Password / Profile and Comments ...
/tool user-manager user add name=$name password=$pass customer=admin copy-from=$profile comment=$comment
}
:log error "DONE. Script END. Now logout from USERMAN and RE login and check users section"

# Script End.

the result would be something like …
As showed in the image below …

4-log.

.

Now log-out from the User-manager, and re login , and check USERS Section again 🙂
the result would be something like …
As showed in the image below …

5- user-end.

.

This is just an example, you can do much more by adding various functions or variables/constrains to the script 🙂

Example for CLI base profile addition.

/tool user-manager profile
 add name=512k name-for-users="512k Package" override-shared-users=off owner=admin \
 price=500 starts-at=logon validity=4w2d
 add name=1mb name-for-users=1mb override-shared-users=off owner=admin price=500 \
 starts-at=logon validity=4w2d

/tool user-manager profile limitation
 add address-list="" download-limit=0B group-name="" ip-pool="" name=512k \
 rate-limit-min-rx=524288B rate-limit-min-tx=524288B rate-limit-rx=524288B \
 rate-limit-tx=524288B transfer-limit=0B upload-limit=0B uptime-limit=0s
 add address-list="" download-limit=0B group-name="" ip-pool="" name=1mb \
 rate-limit-min-rx=1048576B rate-limit-min-tx=1048576B rate-limit-rx=1048576B \
 rate-limit-tx=1048576B transfer-limit=0B upload-limit=0B uptime-limit=0s
 /tool user-manager profile profile-limitation
 add from-time=0s limitation=512k profile=512k till-time=23h59m59s weekdays=\
 sunday,monday,tuesday,wednesday,thursday,friday,saturday
 add from-time=0s limitation=1mb profile=1mb till-time=23h59m59s weekdays=\
 sunday,monday,tuesday,wednesday,thursday,friday,saturday

.

Remember ….

Sky is the only limit …

.

.

Regard’s
Syed Jahanzaib

21 Comments »

  1. Which Mikrotikboard is good solution to handled total 200 users billing?? which u recomend??

    Comment by kashif khan — February 25, 2014 @ 11:17 AM

    • I was looking for same thing and in the end went for custom x86 mashine pentium g3420 !

      Comment by makoto — February 25, 2014 @ 11:36 PM

    • RB450G would be enough for simple routing/natting with basic level of filtering.
      You can also try RB1100ahx2 which can handle more then 400-500 users.

      Comment by Syed Jahanzaib / Pinochio~:) — February 27, 2014 @ 10:44 AM

  2. Great Effort sir (y)

    Comment by aamirwaseemrana — February 25, 2014 @ 1:56 PM

  3. Hi Syed
    Is there any script which can stop access to MAC cloned customers.

    Best Regards,
    Team Weblink
    5,Bhima Mhatre Bldg,
    Manpada Road,
    Dombivli – E ,421201
    India.
    Ph : 91-0251-6455950,
    Cell : 91- 8976017880

    Comment by Team Weblink — February 25, 2014 @ 2:28 PM

  4. Dear Syed
    Sorry for this comment it land it here I would like to configure 3 or 4 USB modem (3G) with USB hub but I am confused to do it if passable guide us to configured I hope is step by step.

    Comment by rashedix — February 25, 2014 @ 3:26 PM

    • hmmm I have not tried usb hub with Mikrotik before so no idea, and also since i m not in mikrotik base environment with required accessories , so I cant do any test on it.

      Comment by Syed Jahanzaib / Pinochio~:) — February 27, 2014 @ 10:41 AM

  5. Wqq q we eweřťýüí pooĺàş@’@v On 25-Feb-2014 10:46 AM, “Syed Jahanzaib Personnel Blog to Share Knowledge !” wrote:

    > Syed Jahanzaib / Pinochio~:) posted: “As requested Following is a > quick and dirty way to export Mikrotik Local PPP (pppoe) users to USER > MANAGER with same profile assigned as LOCAL profile section . I used the > word dirty because there is no officially supported method that we can use > by singl”

    Comment by ABN NETWORKS — February 27, 2014 @ 3:33 PM

  6. nice job

    Comment by amir442014 — February 27, 2014 @ 3:36 PM

  7. i love mikrotik

    Comment by mctnetwork — March 5, 2014 @ 6:07 PM

  8. I can’t add user ppp1 to userman by scrip.

    Comment by game — March 17, 2014 @ 11:24 AM

  9. How to add nat userman?

    Comment by game — March 17, 2014 @ 5:46 PM

  10. bro, tell me could u configure my RM server centralized and DMZ along with some extended services like, mails n sms to users.
    and if any services charges or any other charges, plz reply me to pavankatepalli1905@live.com

    Comment by Pavan — May 10, 2014 @ 8:23 PM

  11. expot all user from hotsopt user to ppp and i need make user in usermanager withe script and give him profile

    sory my English is no’t good

    Comment by hany — January 13, 2015 @ 2:25 PM

  12. Dear pori Scrip copy kr ky scrip me lagani ha or kia local ki jaga apny lan ka name likhna ha like ether1 is ky ilawa kia changing krni hon ge

    Comment by Naseer Ahmad — January 22, 2015 @ 10:45 PM

    • Follow the guide and read it again.

      Comment by Syed Jahanzaib / Pinochio~:) — January 23, 2015 @ 8:43 AM

      • dear janzib bahi mujy aap ye baty ke scrept me khuch changing krni kia ya khuch be ni mery paass ye error aata ha log me “make sure user manager probably configure and creat same profile with same names (master user for cloning) in userman /jz “DONE. Script END. Now logout from USERMAN and RE login and check users section”

        Comment by Naseer Ahmad — February 5, 2015 @ 8:39 AM

      • brother what if we want reverse action?

        Comment by nomi — August 10, 2015 @ 8:31 AM

  13. How to make vice versa action, export from userman to ppp secret?

    Comment by Nick — October 28, 2015 @ 11:36 PM

  14. As I can import from the static DHCP leases server?It has tested some script?
    Thank you

    Comment by Arielo — February 2, 2016 @ 5:00 PM


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: