| Author |
Message |
![[Post New]](/jforum/templates/default/images/icon_minipost_new.gif) 05/05/2010 20:29:33
|
Carsten Strotmann
Men & Mice Staff
![[Avatar]](/jforum/images/avatar/eccbc87e4b5ce2fe28308fd9f2a7baf3.jpg)
Joined: 26/07/2007 13:08:39
Messages: 159
Location: Germany
Offline
|
The REXX Script converts a DHCP Server dump file created from the "netsh" dump command into an ISC DHCP Server configuration file.
This script can be used as a starting point to migrate a Microsoft DHCP Server from Windows to Unix.
Code:
/* Convert Script MS DHCP Dump to ISC DHCP Configuration */
PARSE ARG infile outfile
IF outfile = "" THEN outfile = "dhcpd.conf"
SAY "Men & Mice MS DHCP -> ISC DHCP Converter"
SAY "(c) 2007 Men & Mice, CAS"
SAY "----------------------------------------"
SAY
SAY "MS DHCP Dump File: " infile
SAY "ISC DHCP Config File:" outfile
rc = Stream(infile, "C", "OPEN READ")
rc = Stream(outfile,"C", "OPEN WRITE REPLACE")
scopes = 0
devices. = ""
devices.0 = 0
/* Output some boilerplate config */
rc = LineOut(outfile, "ddns-updates off;")
rc = LineOut(outfile, "ddns-update-style none;")
rc = LineOut(outfile, 'option domain-name "example.org.";')
rc = LineOut(outfile, "option ntp-servers 1922.0.2.10;")
rc = LineOut(outfile, "default-lease-time 691200;");
rc = LineOut(outfile, "authoritative;");
DO While Lines(infile) > 0
line = LineIn(infile)
IF Pos("add scope", line) > 0 THEN DO
PARSE VALUE line WITH xx "add scope" ipaddress mask '"'name'"' '"'description'"'
IF scopeopen = 1 THEN DO
rc = LineOut(outfile,"}")
scopeopen = 0
END
rc = LineOut(outfile, "# Scope" name "-" description)
rc = LineOut(outfile, "subnet" ipaddress "netmask" mask "{")
scopeopen = 1
scopes = scopes + 1
END
IF Pos("add iprange", line) > 0 THEN DO
PARSE VALUE line WITH xx "add iprange" startip endip
rc = LineOut(outfile, " range" startip endip";")
END
IF Pos("set optionvalue", line) > 0 THEN DO
PARSE VALUE line with xx "set optionvalue" num type options
options = Strip(Translate(options,' ','"'))
IF num = 51 THEN DO
rc = LineOut(outfile, " default-lease-time" options";")
num = 0
END
IF num = 15 THEN DO
rc = LineOut(outfile, ' option domain-name "'options'";')
num = 0
END
IF num = 6 THEN DO
dnsservers = ""
DO u = 1 TO words(options)
IF dnsservers = "" THEN
dnsservers = word(options,u)
ELSE
dnsservers = dnsservers',' word(options,u)
END
rc = LineOut(outfile, " option domain-name-servers" dnsservers";")
num = 0
END
IF num = 3 THEN DO
rc = LineOut(outfile, " option routers" options";")
num = 0
END
IF num > 0 THEN DO
SAY "Unprocessed DHCP Option" num "with paramteters" options
END
END
IF Pos("Add reservedip", line) > 0 THEN DO
PARSE VALUE line WITH xx "Add reservedip" ipaddress mc '"'device'"' '"'description'"' '"'type'"'
device = Strip(Translate(device,"-"," "))
device = Translate(device,"-","'")
IF (devices.mc.ips) > 0 THEN DO /* existing host found */
devices.mc.ips = devices.mc.ips"," ipaddress
devices.mc.nam = Strip(device)
devices.mc.des = Strip(description)
END
ELSE DO /* new host found */
SAY "New Device" device mc
u = devices.0
u = u + 1
devices.u = mc
devices.0 = u
devices.mc.ips = Strip(ipaddress)
devices.mc.nam = Strip(device)
devices.mc.des = Strip(description)
END
END
END
IF scopeopen = 1 THEN DO
rc = LineOut(outfile,"}")
scopeopen = 0
END
/* now we write out all host reservations */
DO u = 1 TO devices.0
mc = devices.u
device = devices.mc.nam
IF Length(device) > 0 THEN DO
mac = SubStr(mc,1,2)
DO i = 1 TO 5
x = i*2;
mac = mac || ":" || SubStr(mc,x+1,2)
END
rc = LineOut(outfile,"host" device "{ #" devices.mc.des)
rc = LineOut(outfile," hardware ethernet" mac";")
rc = LineOut(outfile," fixed-address" devices.mc.ips";")
rc = LineOut(outfile,"}")
rc = LineOut(outfile,"")
END
ELSE DO
SAY "Device without name" device "-" mc /* devices.mc.ips */
END
END
rc = Stream(outfile,"C","CLOSE")
rc = Stream(infile, "C","CLOSE")
SAY scopes "Scopes processed"
SAY devices.0 "Reservations processed"
SAY "Convert finished."
RETURN
This script requires a REXX Script interpreter such as Regina Rexx: http://regina-rexx.sf.net
|
----
Men & Mice Support Team
support@menandmice.com |
|
|
 |
![[Post New]](/jforum/templates/default/images/icon_minipost_new.gif) 25/05/2010 08:24:24
|
Carsten Strotmann
Men & Mice Staff
![[Avatar]](/jforum/images/avatar/eccbc87e4b5ce2fe28308fd9f2a7baf3.jpg)
Joined: 26/07/2007 13:08:39
Messages: 159
Location: Germany
Offline
|
In order to migrate a Microsoft DHCP Server scope onto an ISC DHCP Server on Linux or Solaris, there is an even simpler way using the Men & Mice Suite:
* install the Men & Mice DHCP Server Controller on the ISC DHCP Server
* install (temporary) a Men & Mice DHCP Server Controller for Windows DHCP. This can be done on the DHCP Server itself, or on any server or client machine that is part of the same AD. Make sure the DHCP Server Controller runs under an user account that is part of the "DHCP Administrators" group.
* add both DHCP Server to the Men & Mice Suite
* select the Scope on the Windows DHCP Server, select "Migrate Scope..." and migrate the scope including options and reservations to the ISC DHCP Server
The same trick also works in the opposite direction, from ISC DHCP to Windows DHCP.
|
----
Men & Mice Support Team
support@menandmice.com |
|
|
 |
![[Post New]](/jforum/templates/default/images/icon_minipost_new.gif) 25/05/2010 08:35:22
|
Anonymous
|
A dump of a Microsoft DHCP Server can be done from the commandline with this command (the resulting dump will be in the file dhcp.dump)
Code:
netsh dhcp server \\name_of_server dump > dhcp.dump
Such a dump look similar to this
Code:
# ==============================================================
# Configuration Information for Server 192.168.1.79
# ==============================================================
# =====================================
# Add Classes
# =====================================
Dhcp Server \\192.168.1.79 Add Class "Default Routing and Remote Access Class" "User class for remote access clients" 525241532e4d6963726f736f6674 0 b
Dhcp Server \\192.168.1.79 Add Class "Default Network Access Protection Class" "Default special user class for Restricted Access clients" 4d5346542051756172616e74696e65 0 b
Dhcp Server \\192.168.1.79 Add Class "Default BOOTP Class" "User class for BOOTP Clients" 424f4f54502e4d6963726f736f6674 0 b
Dhcp Server \\192.168.1.79 Add Class "Microsoft Windows 2000 Options" "Microsoft vendor-specific options for Windows 2000 Clients" 4d53465420352e30 1 b
Dhcp Server \\192.168.1.79 Add Class "Microsoft Windows 98 Options" "Microsoft vendor-specific options for Windows 98 Clients" 4d534654203938 1 b
Dhcp Server \\192.168.1.79 Add Class "Microsoft Options" "Microsoft vendor-specific options applicable to Windows 98 and Windows 2000 Clients" 4d534654 1 b
# =====================================
# Add Classes End
# =====================================
# =====================================
# Add Optiondef
# =====================================
Dhcp Server \\192.168.1.79 Add Optiondef 121 "Classless Static Routes" BINARY 0 comment="Destination, mask and router IP addresses in priority order"
Dhcp Server \\192.168.1.79 Add Optiondef 1 "Subnet Mask" IPADDRESS 0 comment="Subnet mask in network byte order" 0.0.0.0
Dhcp Server \\192.168.1.79 Add Optiondef 2 "Time Offset" DWORD 0 comment="UCT offset in seconds" 0
Dhcp Server \\192.168.1.79 Add Optiondef 3 "Router" IPADDRESS 1 comment="Array of router addresses ordered by preference" 0.0.0.0
Dhcp Server \\192.168.1.79 Add Optiondef 4 "Time Server" IPADDRESS 1 comment="Array of time server addresses, by preference" 0.0.0.0
Dhcp Server \\192.168.1.79 Add Optiondef 5 "Name Servers" IPADDRESS 1 comment="Array of name servers [IEN 116], by preference" 0.0.0.0
Dhcp Server \\192.168.1.79 Add Optiondef 6 "DNS Servers" IPADDRESS 1 comment="Array of router addresses ordered by preference" 0.0.0.0
Dhcp Server \\192.168.1.79 Add Optiondef 7 "Log Servers" IPADDRESS 1 comment="Array of MIT_LCS UDP log servers on subnet" 0.0.0.0
Dhcp Server \\192.168.1.79 Add Optiondef 8 "Cookie Servers" IPADDRESS 1 comment="Array of cookie servers, RFC 865" 0.0.0.0
Dhcp Server \\192.168.1.79 Add Optiondef 9 "LPR Servers" IPADDRESS 1 comment="Array of RFC 1179 servers, by preference" 0.0.0.0
Dhcp Server \\192.168.1.79 Add Optiondef 10 "Impress Servers" IPADDRESS 1 comment="Array of Imagen Impress Servers" 0.0.0.0
Dhcp Server \\192.168.1.79 Add Optiondef 11 "Resource Location Servers" IPADDRESS 1 comment="Array of RFC 887 ResLoc Servers on subnet, by preference" 0.0.0.0
Dhcp Server \\192.168.1.79 Add Optiondef 12 "Host Name" STRING 0 comment="Host name for client, RFC 1035 character set" ""
Dhcp Server \\192.168.1.79 Add Optiondef 13 "Boot File Size" WORD 0 comment="Size of boot image file in 512-octet blocks" 0
Dhcp Server \\192.168.1.79 Add Optiondef 14 "Merit Dump File" STRING 0 comment="Path name for crash dump file" ""
Dhcp Server \\192.168.1.79 Add Optiondef 15 "DNS Domain Name" STRING 0 comment="DNS Domain name for client resolutions" ""
Dhcp Server \\192.168.1.79 Add Optiondef 16 "Swap Server" IPADDRESS 0 comment="Address of client's swap server" 0.0.0.0
Dhcp Server \\192.168.1.79 Add Optiondef 17 "Root Path" STRING 0 comment="Path name for client's root disk, char set NVT ASCII" ""
Dhcp Server \\192.168.1.79 Add Optiondef 18 "Extensions Path" STRING 0 comment="tftp file for option extensions" ""
Dhcp Server \\192.168.1.79 Add Optiondef 19 "IP Layer Forwarding" BYTE 0 comment="Disable/enable IP packet forwarding on this client" 0
Dhcp Server \\192.168.1.79 Add Optiondef 20 "Nonlocal Source Routing" BYTE 0 comment="Disable/enable nonlocal datagrams" 0
Dhcp Server \\192.168.1.79 Add Optiondef 21 "Policy Filter Masks" IPADDRESS 1 comment="Destination/mask IP address pairs to filter source routes" 0.0.0.0
Dhcp Server \\192.168.1.79 Add Optiondef 22 "Max DG Reassembly Size" WORD 0 comment="Maximum size datagram for reassembly by client; max 576" 0
Dhcp Server \\192.168.1.79 Add Optiondef 23 "Default IP Time-to-live" BYTE 0 comment="Default TTL for client's use on outgoing DGs" 0
Dhcp Server \\192.168.1.79 Add Optiondef 24 "Path MTU Aging Timeout" DWORD 0 comment="Timeout in seconds for aging Path MTU values; RFC 1191" 0
Dhcp Server \\192.168.1.79 Add Optiondef 25 "Path MTU Plateau Table" WORD 1 comment="MTU discovery sizes, sorted by size, all >= 68" 0
Dhcp Server \\192.168.1.79 Add Optiondef 26 "MTU Option" WORD 0 comment="MTU discovery size, >= 68" 0
Dhcp Server \\192.168.1.79 Add Optiondef 27 "All subnets are local" BYTE 0 comment="The client assumes that all subnets are local" 0
Dhcp Server \\192.168.1.79 Add Optiondef 28 "Broadcast Address" IPADDRESS 0 comment="Broadcast address" 0.0.0.0
Dhcp Server \\192.168.1.79 Add Optiondef 29 "Perform Mask Discovery" BYTE 0 comment="The client should use ICMP for subnet mask discovery." 0
Dhcp Server \\192.168.1.79 Add Optiondef 30 "Mask Supplier Option" BYTE 0 comment="The client should respond to subnet mask requests via ICMP." 0
Dhcp Server \\192.168.1.79 Add Optiondef 31 "Perform Router Discovery" BYTE 0 comment="The client should solicit routers using RFC 1256." 0
Dhcp Server \\192.168.1.79 Add Optiondef 32 "Router Solicitation Address" IPADDRESS 0 comment="Address to use for router solicitation" 0.0.0.0
Dhcp Server \\192.168.1.79 Add Optiondef 33 "Static Route Option" IPADDRESS 1 comment="Destination/router address pairs, in priority order" 0.0.0.0
Dhcp Server \\192.168.1.79 Add Optiondef 34 "Trailer Encapsulation" BYTE 0 comment="The client should negotiate use of trailers (RFC 983)." 0
Dhcp Server \\192.168.1.79 Add Optiondef 35 "ARP Cache Timeout" DWORD 0 comment="Timeout in seconds for ARP cache entries" 0
Dhcp Server \\192.168.1.79 Add Optiondef 36 "Ethernet Encapsulation" BYTE 0 comment="0=>client should use ENet V2; 1=> IEEE 802.3" 0
Dhcp Server \\192.168.1.79 Add Optiondef 37 "TCP Default Time-to-live" BYTE 0 comment="TTL that client uses when sending TCP segments" 0
Dhcp Server \\192.168.1.79 Add Optiondef 38 "Keepalive Interval" DWORD 0 comment="Keepalive timeout in seconds" 0
Dhcp Server \\192.168.1.79 Add Optiondef 39 "Keepalive Garbage" BYTE 0 comment="Send garbage octet" 0
Dhcp Server \\192.168.1.79 Add Optiondef 40 "NIS Domain Name" STRING 0 comment="Name of Network Information Service domain" ""
Dhcp Server \\192.168.1.79 Add Optiondef 41 "NIS Servers" IPADDRESS 1 comment="Addresses of NIS servers on client's subnet" 0.0.0.0
Dhcp Server \\192.168.1.79 Add Optiondef 42 "NTP Servers" IPADDRESS 1 comment="Addresses of Network Time Protocol servers" 0.0.0.0
Dhcp Server \\192.168.1.79 Add Optiondef 43 "Vendor Specific Info" BINARY 0 comment="Embedded vendor-specific options"
Dhcp Server \\192.168.1.79 Add Optiondef 44 "WINS/NBNS Servers" IPADDRESS 1 comment="NBNS Address(es) in priority order" 0.0.0.0
Dhcp Server \\192.168.1.79 Add Optiondef 45 "NetBIOS over TCP/IP NBDD" IPADDRESS 1 comment="NetBIOS over TCP/IP NBDD address(es) in priority order" 0.0.0.0
Dhcp Server \\192.168.1.79 Add Optiondef 46 "WINS/NBT Node Type" BYTE 0 comment="0x1 = B-node, 0x2 = P-node, 0x4 = M-node, 0x8 = H-node" 0
Dhcp Server \\192.168.1.79 Add Optiondef 47 "NetBIOS Scope ID" STRING 0 comment="NetBIOS over TCP/IP Scope ID" ""
Dhcp Server \\192.168.1.79 Add Optiondef 48 "X Window System Font" IPADDRESS 1 comment="Array of X Windows font servers" 0.0.0.0
Dhcp Server \\192.168.1.79 Add Optiondef 49 "X Window System Display" IPADDRESS 1 comment="Array of X Windows Display Mgr servers" 0.0.0.0
Dhcp Server \\192.168.1.79 Add Optiondef 51 "Lease" DWORD 0 comment="Client IP address lease time in seconds" 0
Dhcp Server \\192.168.1.79 Add Optiondef 58 "Renewal (T1) Time Value" DWORD 0 comment="Time between addr assignment to RENEWING state" 0
Dhcp Server \\192.168.1.79 Add Optiondef 59 "Rebinding (T2) Time Value" DWORD 0 comment="Time from addr assignment to REBINDING state" 0
Dhcp Server \\192.168.1.79 Add Optiondef 64 "NIS+ Domain Name" STRING 0 comment="The name of the client's NIS+ domain." ""
Dhcp Server \\192.168.1.79 Add Optiondef 65 "NIS+ Servers" IPADDRESS 1 comment="A list of IP addresses indicating NIS+ servers" 0.0.0.0
Dhcp Server \\192.168.1.79 Add Optiondef 66 "Boot Server Host Name" STRING 0 comment="TFTP boot server host name" ""
Dhcp Server \\192.168.1.79 Add Optiondef 67 "Bootfile Name" STRING 0 comment="Bootfile Name" ""
Dhcp Server \\192.168.1.79 Add Optiondef 68 "Mobile IP Home Agents" IPADDRESS 1 comment="Mobile IP home agents in priority order" 0.0.0.0
Dhcp Server \\192.168.1.79 Add Optiondef 69 "Simple Mail Transport Protocol (SMTP) Servers" IPADDRESS 1 comment="List of SMTP servers available to the client" 0.0.0.0
Dhcp Server \\192.168.1.79 Add Optiondef 70 "Post Office Protocol (POP3) Servers" IPADDRESS 1 comment="List of POP3 servers available to the client" 0.0.0.0
Dhcp Server \\192.168.1.79 Add Optiondef 71 "Network News Transport Protocol (NNTP) Servers" IPADDRESS 1 comment="List of NNTP servers available to the client" 0.0.0.0
Dhcp Server \\192.168.1.79 Add Optiondef 72 "World Wide Web (WWW) Servers" IPADDRESS 1 comment="List of WWW servers available to the client" 0.0.0.0
Dhcp Server \\192.168.1.79 Add Optiondef 73 "Finger Servers" IPADDRESS 1 comment="List of Finger servers available to the client" 0.0.0.0
Dhcp Server \\192.168.1.79 Add Optiondef 74 "Internet Relay Chat (IRC) Servers" IPADDRESS 1 comment="List of IRC servers available to the client" 0.0.0.0
Dhcp Server \\192.168.1.79 Add Optiondef 75 "StreetTalk Servers" IPADDRESS 1 comment="List of StreetTalk servers available to the client" 0.0.0.0
Dhcp Server \\192.168.1.79 Add Optiondef 76 "StreetTalk Directory Assistance (STDA) Servers" IPADDRESS 1 comment="List of STDA servers available to the client" 0.0.0.0
Dhcp Server \\192.168.1.79 Add Optiondef 81 "DnsIntegrationInternal" DWORD 0 comment="" 0
Dhcp Server \\192.168.1.79 Add Optiondef 1 "Microsoft Disable Netbios Option " DWORD 0 vendor="Microsoft Options" comment="Option for enabling or disabling Netbios for Microsoft Windows 2000 Clients" 1
Dhcp Server \\192.168.1.79 Add Optiondef 2 "Microsoft Release DHCP Lease On Shutdown Option" DWORD 0 vendor="Microsoft Options" comment="Option for enabling or disabling Windows 2000 Clients to release DHCP lease on shutdown" 1
Dhcp Server \\192.168.1.79 Add Optiondef 3 "Microsoft Default Router Metric Base" DWORD 0 vendor="Microsoft Options" comment="Default Router Base Metrics for Microsoft Windows 2000 Clients" 1
Dhcp Server \\192.168.1.79 Add Optiondef 1 "Microsoft Disable Netbios Option " DWORD 0 vendor="Microsoft Windows 2000 Options" comment="Option for enabling or disabling Netbios for Microsoft Windows 2000 Clients" 1
Dhcp Server \\192.168.1.79 Add Optiondef 2 "Microsoft Release DHCP Lease On Shutdown Option" DWORD 0 vendor="Microsoft Windows 2000 Options" comment="Option for enabling or disabling Windows 2000 Clients to release DHCP lease on shutdown" 1
Dhcp Server \\192.168.1.79 Add Optiondef 3 "Microsoft Default Router Metric Base" DWORD 0 vendor="Microsoft Windows 2000 Options" comment="Default Router Base Metrics for Microsoft Windows 2000 Clients" 0
# =====================================
# Add Optiondef End
# ====================================
# =====================================
# Set Optionvalue
# =====================================
Dhcp Server \\192.168.1.79 set optionvalue 15 STRING "home.strotmann.de"
Dhcp Server \\192.168.1.79 set optionvalue 6 IPADDRESS "192.168.1.79"
# =====================================
# Set Optionvalue End
# =====================================
Dhcp Server \\192.168.1.79 Set AuditLog path = "C:\Windows\system32\dhcp" maxsize = 70 minsize = 20 interval = 50 mode = ENABLE
Dhcp Server \\192.168.1.79 Set DatabaseBackupInterval 60
Dhcp Server \\192.168.1.79 Set DatabaseBackupPath "C:\Windows\system32\dhcp\backup"
Dhcp Server \\192.168.1.79 Set DatabaseCleanupInterval 60
Dhcp Server \\192.168.1.79 Set DatabaseLoggingFlag 1
Dhcp Server \\192.168.1.79 Set DatabaseName "dhcp.mdb"
Dhcp Server \\192.168.1.79 Set DatabasePath "C:\Windows\system32\dhcp"
Dhcp Server \\192.168.1.79 Set DatabaseRestoreFlag 0
Dhcp Server \\192.168.1.79 Set DetectConflictRetry 0
# =====================================
# Add Scope
# =====================================
Dhcp Server \\192.168.1.79 add scope 130.161.183.0 255.255.255.0 "Tu Delft" ""
Dhcp Server \\192.168.1.79 Scope 130.161.183.0 set state 0
# ======================================================================
# Start Add Ipranges to the Scope 130.161.183.0, Server 192.168.1.79
# ======================================================================
# ======================================================================
# End Add Ipranges to the Scope 130.161.183.0, Server 192.168.1.79
# ======================================================================
# ======================================================================
# Start Add Excluderanges to the Scope : 130.161.183.0, Server : 192.168.1.79
# ======================================================================
# ======================================================================
# End Add Excluderanges to the Scope : 130.161.183.0, Server : 192.168.1.79
# ======================================================================
# ======================================================================
# Start Add OptionValues to the Scope : 130.161.183.0, Server : 192.168.1.79
# ======================================================================
Dhcp Server \\192.168.1.79 Scope 130.161.183.0 set optionvalue 51 DWORD "691200"
# ======================================================================
# End Add OptionValues to the Scope : 130.161.183.0, Server : 192.168.1.79
# ======================================================================
# ======================================================================
# Start Add ReservedIp to the Scope : 130.161.183.0, Server : 192.168.1.79
# ======================================================================
Dhcp Server \\192.168.1.79 Scope 130.161.183.0 Add reservedip 130.161.183.51 112233445566 "importhost1-vlan383" "" "DHCP"
Dhcp Server \\192.168.1.79 Scope 130.161.183.0 Add reservedip 130.161.183.52 112233445567 "importhost2-vlan383" "" "DHCP"
Dhcp Server \\192.168.1.79 Scope 130.161.183.0 Add reservedip 130.161.183.53 112233445568 "importhost3-vlan383" "" "DHCP"
Dhcp Server \\192.168.1.79 Scope 130.161.183.0 Add reservedip 130.161.183.54 112233445569 "importhost4-vlan383" "" "DHCP"
# ======================================================================
# End Add ReservedIp to the Scope : 130.161.183.0, Server : 192.168.1.79
# ======================================================================
Dhcp Server \\192.168.1.79 add scope 172.16.1.0 255.255.255.128 "Office 2" ""
Dhcp Server \\192.168.1.79 Scope 172.16.1.0 set state 0
# ======================================================================
# Start Add Ipranges to the Scope 172.16.1.0, Server 192.168.1.79
# ======================================================================
Dhcp Server \\192.168.1.79 Scope 172.16.1.0 Add iprange 172.16.1.1 172.16.1.126
Dhcp Server \\192.168.1.79 scope 172.16.1.0 set napstate Off
# ======================================================================
# End Add Ipranges to the Scope 172.16.1.0, Server 192.168.1.79
# ======================================================================
# ======================================================================
# Start Add Excluderanges to the Scope : 172.16.1.0, Server : 192.168.1.79
# ======================================================================
# ======================================================================
# End Add Excluderanges to the Scope : 172.16.1.0, Server : 192.168.1.79
# ======================================================================
# ======================================================================
# Start Add OptionValues to the Scope : 172.16.1.0, Server : 192.168.1.79
# ======================================================================
Dhcp Server \\192.168.1.79 Scope 172.16.1.0 set optionvalue 51 DWORD "691200"
# ======================================================================
# End Add OptionValues to the Scope : 172.16.1.0, Server : 192.168.1.79
# ======================================================================
# ======================================================================
# Start Add ReservedIp to the Scope : 172.16.1.0, Server : 192.168.1.79
# ======================================================================
# ======================================================================
# End Add ReservedIp to the Scope : 172.16.1.0, Server : 192.168.1.79
# ======================================================================
Dhcp Server \\192.168.1.79 add scope 172.16.1.128 255.255.255.128 "Office 2" ""
Dhcp Server \\192.168.1.79 Scope 172.16.1.128 set state 0
# ======================================================================
# Start Add Ipranges to the Scope 172.16.1.128, Server 192.168.1.79
# ======================================================================
Dhcp Server \\192.168.1.79 Scope 172.16.1.128 Add iprange 172.16.1.129 172.16.1.254
Dhcp Server \\192.168.1.79 scope 172.16.1.128 set napstate Off
# ======================================================================
# End Add Ipranges to the Scope 172.16.1.128, Server 192.168.1.79
# ======================================================================
# ======================================================================
# Start Add Excluderanges to the Scope : 172.16.1.128, Server : 192.168.1.79
# ======================================================================
# ======================================================================
# End Add Excluderanges to the Scope : 172.16.1.128, Server : 192.168.1.79
# ======================================================================
# ======================================================================
# Start Add OptionValues to the Scope : 172.16.1.128, Server : 192.168.1.79
# ======================================================================
Dhcp Server \\192.168.1.79 Scope 172.16.1.128 set optionvalue 51 DWORD "691200"
# ======================================================================
# End Add OptionValues to the Scope : 172.16.1.128, Server : 192.168.1.79
# ======================================================================
# ======================================================================
# Start Add ReservedIp to the Scope : 172.16.1.128, Server : 192.168.1.79
# ======================================================================
# ======================================================================
# End Add ReservedIp to the Scope : 172.16.1.128, Server : 192.168.1.79
# ======================================================================
Dhcp Server \\192.168.1.79 add scope 172.16.10.0 255.255.255.248 "Test" ""
Dhcp Server \\192.168.1.79 Scope 172.16.10.0 set state 0
# ======================================================================
# Start Add Ipranges to the Scope 172.16.10.0, Server 192.168.1.79
# ======================================================================
Dhcp Server \\192.168.1.79 Scope 172.16.10.0 Add iprange 172.16.10.2 172.16.10.4
Dhcp Server \\192.168.1.79 scope 172.16.10.0 set napstate Off
# ======================================================================
# End Add Ipranges to the Scope 172.16.10.0, Server 192.168.1.79
# ======================================================================
# ======================================================================
# Start Add Excluderanges to the Scope : 172.16.10.0, Server : 192.168.1.79
# ======================================================================
# ======================================================================
# End Add Excluderanges to the Scope : 172.16.10.0, Server : 192.168.1.79
# ======================================================================
# ======================================================================
# Start Add OptionValues to the Scope : 172.16.10.0, Server : 192.168.1.79
# ======================================================================
Dhcp Server \\192.168.1.79 Scope 172.16.10.0 set optionvalue 51 DWORD "691200"
# ======================================================================
# End Add OptionValues to the Scope : 172.16.10.0, Server : 192.168.1.79
# ======================================================================
# ======================================================================
# Start Add ReservedIp to the Scope : 172.16.10.0, Server : 192.168.1.79
# ======================================================================
# ======================================================================
# End Add ReservedIp to the Scope : 172.16.10.0, Server : 192.168.1.79
# ======================================================================
# =====================================
# Add Scope End
# =====================================
# =====================================
# Add Super Scope
# =====================================
# =====================================
# Add Super Scope End
# =====================================
# =====================================
# Add MScope
# =====================================
# =====================================
# Add MScope End
# =====================================
# ==============================================================
# Configuration Information for Server 192.168.1.79 Ends
# ==============================================================
# ==============================================================
# V6 Configuration Information for Server 192.168.1.79
# ==============================================================
# =====================================
# Add Classes
# =====================================
Dhcp Server \\192.168.1.79 v6 Add Class "Microsoft Windows Options" "Microsoft vendor-specific options for Windows Clients" 4d53465420352e30 1 b 311
# =====================================
# Add Classes End
# =====================================
# =====================================
# Add Optiondef
# =====================================
Dhcp Server \\192.168.1.79 v6 Add Optiondef 21 "SIP Server Domain Name List " STRING 1 comment="Domain Name of SIP servers available to the client " ""
Dhcp Server \\192.168.1.79 v6 Add Optiondef 24 "Domain Search List " STRING 1 comment="Domain search list used by clients to resolve hostnames with DNS, by preference " ""
Dhcp Server \\192.168.1.79 v6 Add Optiondef 29 "NIS Domain List " STRING 1 comment="Domain names of NIS servers available to the client " ""
Dhcp Server \\192.168.1.79 v6 Add Optiondef 30 "NIS+ Domain Name List " STRING 1 comment="Domain names of NIS+ servers available to the client " ""
Dhcp Server \\192.168.1.79 v6 Add Optiondef 22 "SIP Servers IPV6 Address List " IPV6ADDRESS 1 comment="IPv6 addresses of SIP servers available to the client " ""
Dhcp Server \\192.168.1.79 v6 Add Optiondef 23 "DNS Recursive Name Server IPV6 Address List " IPV6ADDRESS 1 comment="IPv6 Addresses of DNS recursive name servers available to the client " ""
Dhcp Server \\192.168.1.79 v6 Add Optiondef 27 "NIS IPV6 Address List " IPV6ADDRESS 1 comment="IPV6 Addresses of NIS servers available to the client " ""
Dhcp Server \\192.168.1.79 v6 Add Optiondef 28 "NIS+ IPV6 Address List " IPV6ADDRESS 1 comment="IPV6 Addresses of NIS+ servers available to the client " ""
Dhcp Server \\192.168.1.79 v6 Add Optiondef 31 "SNTP Servers IPV6 Address List " IPV6ADDRESS 1 comment="IPV6 Addresses of SNTP servers available to the client " ""
# =====================================
# Add Optiondef End
# ====================================
# =====================================
# Set Optionvalue
# =====================================
Dhcp Server \\192.168.1.79 v6 set optionvalue 24 STRING "home.strotmann.de"
Dhcp Server \\192.168.1.79 v6 set optionvalue 23 IPV6ADDRESS "fe80::f94d:48cb:a721:c8a"
# =====================================
# Set Optionvalue End
# =====================================
Dhcp Server \\192.168.1.79 v6 Set t1 345600
Dhcp Server \\192.168.1.79 v6 Set t2 552960
Dhcp Server \\192.168.1.79 v6 Set preferredlifetime 691200
Dhcp Server \\192.168.1.79 v6 Set validlifetime 1036800
Dhcp Server \\192.168.1.79 v6 Set preferredlifetime 86400 IATA
Dhcp Server \\192.168.1.79 v6 Set validlifetime 259200 IATA
Dhcp Server \\192.168.1.79 v6 Set rapidcommitflag Off
Dhcp Server \\192.168.1.79 v6 Set unicastflag Off
# =====================================
# Add Scope
# =====================================
# =====================================
# Add Scope End
# =====================================
# ==============================================================
# Configuration Information for Server 192.168.1.79 Ends
# ==============================================================
|
|
|
 |
![[Post New]](/jforum/templates/default/images/icon_minipost_new.gif) 26/05/2010 15:42:56
|
Carsten Strotmann
Men & Mice Staff
![[Avatar]](/jforum/images/avatar/eccbc87e4b5ce2fe28308fd9f2a7baf3.jpg)
Joined: 26/07/2007 13:08:39
Messages: 159
Location: Germany
Offline
|
Here is a variation of the script that reads a Microsoft DHCP Server dump file and converts it into a command file for the Men & Mice CLI (mmcmd).
Using the mmcmd, the configuration can then be imported to any of the supported DHCP Server types in a Men & Mice System (Windows DHCP, ISC DHCP and Cisco IOS DHCP).
This script requires a REXX Script interpreter such as Regina Rexx: http://regina-rexx.sf.net
Code:
/* Convert Script MS DHCP Dump to Men & Mice DHCP Configuration Script */
PARSE ARG server infile outfile servertype
useroptions = " 60 137 161 162 176 201 252 "
dhcpproduct = "ISCDHCP"
IF Strip(servertype) = "MSDHCP" then dhcpproduct = "MSDHCP"
IF outfile = "" THEN outfile = "dhcpimport.mmc"
SAY "Men & Mice MS DHCP -> mmcmd script Converter"
SAY "(c) 2010 Men & Mice, CAS, Version 1.3"
SAY "--------------------------------------------"
SAY
SAY "DHCP Server : " server
SAY "MS DHCP Dump File: " infile
SAY "mmcmd Script File: " outfile
NUMERIC DIGITS 32
rc = Stream(infile, "C", "OPEN READ")
rc = Stream(outfile,"C", "OPEN WRITE REPLACE")
scopes = 0
devices. = ""
devices.0 = 0
scopeaddress = ""
DO While Lines(infile) > 0
line = LineIn(infile)
PARSE VALUE line WITH "Dhcp Server \\"serverip proto xx
IF proto="v6" THEN line = "" /* we currently do only IPv4 here */
IF Pos("add scope", line) > 0 THEN DO
PARSE VALUE line WITH xx "add scope" ipaddress mask '"'title'"' '"'description'"'
PARSE VALUE mask WITH o1'.'o2'.'o3'.'o4
val = o1 * (256*256*256) + o2 * (256*256) + o3 * 256 + o4
netmask = 0
max = 2 ** 32
DO u = 1 to 32
v = max - (2 ** u)
if (v = val) THEN netmask = 32 - u
END
scopeaddress = ipaddress
desc = ""
if Length(description) > 0 THEN desc = "Description="description
rc = LineOut(outfile, "addScope" scopeaddress'/'netmask server '"'title'"' '"'desc'"')
scopes = scopes + 1
END
IF Pos("Add iprange", line) > 0 THEN DO
PARSE VALUE line WITH xx "Add iprange" startip endip
rc = LineOut(outfile, "scope" scopeaddress server "add iprange" startip endip)
END
IF Pos("set optionvalue", line) > 0 THEN DO
PARSE VALUE line with xx "set optionvalue" num type options
options = Strip(Translate(options,' ','"'))
opt = ""
DO w = 1 TO Words(options)
opt = opt || Word(options,w)
if (w < Words(options)) THEN opt = opt || ','
END
optid = num
IF Pos(" "num" ", useroptions) > 0 THEN DO
optid = '":User defined options:'num'"'
END
IF Length(scopeaddress) > 0 THEN DO
rc = LineOut(outfile, "scope" scopeaddress "set optionvalue" optid"="opt)
END
ELSE DO
rc = LineOut(outfile, "dhcpserver" server "set optionvalue" optid"="opt)
END
END
IF Pos("Add reservedip", line) > 0 THEN DO
PARSE VALUE line WITH xx "Add reservedip" ipaddress mac '"'name'"' '"'description'"' '"'type'"'
type = Strip(type)
IF Length(type)=0 THEN type='BOTH'
IF dhcpproduct="MSDHCP" THEN DO
rc = LineOut(outfile, "scope" scopeaddress "add reservedip" ipaddress mac 'n="'name'"' "t="type)
END
ELSE DO
rc = LineOut(outfile, "scope" scopeaddress "add reservedip" ipaddress mac 'n="'name'"')
END
devices.0 = devices.0 + 1
END
END
rc = LineOut(outfile, "quit")
rc = Stream(outfile,"C","CLOSE")
rc = Stream(infile, "C","CLOSE")
SAY scopes "Scopes processed"
SAY devices.0 "Reservations processed"
SAY "Convert finished."
RETURN
Example use of the script:
Code:
C:\Users\Administrator\Desktop\DHCPmigrate>rexx msdhcp2isc win2k8v6.home.strotmann.de dhcp.dump
Men & Mice MS DHCP -> mmcmd script Converter
(c) 2010 Men & Mice, CAS
--------------------------------------------
DHCP Server : win2k8v6.home.strotmann.de
MS DHCP Dump File: dhcp.dump
mmcmd Script File: dhcpimport.mmc
4 Scopes processed
4 Reservations processed
Convert finished.
And then
Code:
C:\Users\Administrator\Desktop\DHCPmigrate>mmcmd -s <mmcentral> -u administrator -p <password> -f dhcpimport.mmc
|
----
Men & Mice Support Team
support@menandmice.com |
|
|
 |
|
|
|
|