Announcement

Collapse
No announcement yet.
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Creating manual reservations via script

    Here's the deal. A customer wanted the phones to use a certain set of IP addresses on a Class B network. Obviously, you can not use Vendor Class as a DHCP reservation option. So, there are only 2 other options (considering that computers are plugged into the phones).

    Option 1: Manually assign the phones, one phone at a time (NO THANK YOU!)

    Option 2: Work on a script to create manual reservations within the DHCP scope.

    A few things to consider. We addressed the phones within the 'DHCP' scope, but outside of the address pool, so items accidently getting a reserved IP will not be a problem.

    The first part of the script, creates a Manual reservation, while the second part of the script sets the gateway to a different address for the IP's within the reservations...(the phones pointed to a dedicated T1 Point-to-point, while the computers pointed to a Cable 2 meg pipe). This "reservedoptionvalue" could be used to add option 156 to phones only as well.

    for /f "tokens=1-4 delims=;" %%a in (c:\MacList.txt) do (netsh dhcp server 192.168.1.100 scope 192.168.1.0 add reservedip %%a %%b %%c %%d dhcp)

    for /f %%a in (c:\Gatewayip.txt) do (netsh dhcp server 192.168.1.100 scope 192.168.1.0 set reservedoptionvalue %%a 003 IPADDRESS 192.168.1.254)
    sample of MacList.txt
    192.168.1.101;00104903c930;Shoretel;ShoreGearT1
    192.168.1.102;00104903c666;Shoretel;ShoreGear60
    192.168.1.103;00104903c692;Shoretel;ShoreGear60
    192.168.1.104;00104903c074;Shoretel;ShoreGear120
    192.168.1.105;0010490491c4;Shoretel;ShoreGear120
    192.168.1.106;001049042a79;Shoretel;ShoreTel560G
    192.168.1.107;001049042a7a;Shoretel;ShoreTel560G
    192.168.1.108;001049042a7b;Shoretel;ShoreTel560G
    192.168.1.109;001049042a7c;Shoretel;ShoreTel560G
    Sample of Gatewayip.txt
    192.168.1.101
    192.168.1.102
    192.168.1.103
    192.168.1.104
    192.168.1.105
    192.168.1.106
    192.168.1.107
    192.168.1.108
    192.168.1.109
    to speed things up, you could use a BarCode scanner to scan the MAC addresses into a text file.

    Of course, I hate it when nobody breaks down code, so I will share the sources too.

    Batch File Commands:
    http://labmice.techtarget.com/articles/batchcmds.htm

    The DHCP Commands:
    http://technet2.microsoft.com/Window....mspx?mfr=true

    Let me know if this helps!!!
    Charles

  • #2
    Stole my idea did ya
    Sergio Valles
    [email protected]
    # 909-972-0398 Direct
    Certified ShoreTel Engineer
    http://www.intelesysone.com

    Comment


    • #3
      Originally posted by svalles
      Stole my idea did ya
      Yep...we ran across the same situation that you encountered....except I didn't have your utility... What a pain in the butt it was to find a way to do it.

      Comment


      • #4
        Could you not use VLANs?

        Comment


        • #5
          Here is my tool you need to run it from a Windows Server Machine with admin rights to the DHCP server
          Sergio Valles
          [email protected]
          # 909-972-0398 Direct
          Certified ShoreTel Engineer
          http://www.intelesysone.com

          Comment


          • #6
            Will your Mac tool create reservations for a separate scope? I have 2 different scopes, one for my data network and another for just phones. I cannot get option 156 to work and now thinking about the Mac option. I would like to create the reservations under my second scope, it this possible?

            Comment


            • #7
              Here is how I have done this in the past. Set up DHCP and let all the phones get an address. Or create the CSV file using the MAC's off the box.

              Open DHCP management console
              Right click on address leases select export
              Save the document as a csv (the default is tab delimited)
              Open the saved file in excel.
              Delete the column lease expiration. Cut and paste the name column after the description. Make a new Column after name called type, put in "DHCP" with quotes and copy it all the way down to the last entry. The name and description need to be in quotes as well
              Fix any MAC addresses that are not correct. They will show up not justified to the left of the cell. Delete any entries for RAS. Now is the time to assign new addresses.
              Put in the starting address in the top box and fill the cells down as far as needed the address should increment by 1 for each cell.
              Save the file as a csv.
              Open the file in notepad
              The first line looks like this
              Client IP Address Unique ID Description Name type
              Delete it.
              The rest of the document should be in this format
              192.168.1.30,001049052b88,"phone","phone","DHCP"
              Click on edit select replace
              In the find box .put a , in the replace box put a "space" ( one stroke of the space bar)
              Click replace all.
              Now your document should look like this.
              192.168.1.30 001049052b88 """phone""" """phone""" """DHCP"""
              Click on edit select replace
              In the find box put """ in the replace box put "
              Click replace all.
              Now your document should look like this.
              192.168.1.30 001049052b88 "phone" "phone" "DHCP"
              Click on edit select replace
              In the find box put in the first part of the client IP address in this case 192. in the replace box put
              Dhcp Server Your DHCP server IP Scope Your DHCP scope Add reservedip 192. Replace the DHCP server and the scope with your information. Click replace all.
              Your document should look like this
              Dhcp Server 192.168.1.2 Scope 192.168.1.0 Add reservedip 192.168.1.31 0010490a7145 “Phone” “Phone” “both”
              Save the document as a text file. Where ever you want just remember the name and path.
              Open a command prompt and run the following command
              NETSH exec c:\path to saved file\file name.txt

              A little more involved but the MAC tool was not available at the time I figured this out and if you have two scopes you can just duplicate the data and change the scope address and IP's.

              Comment

              Working...
              X