Import IP ranges for Network Segments

bbergstein
New Contributor III

Hey all-

I am trying to set up network segments and I was wondering if any of you know of a way to mass-import all of these ranges. I have a spreadsheet (aka easily made CSV) with all of the ranges in it. Is there a way to basically just import this entire list into the JSS without having to go through and manually set it up for each store? We have ~200 locations that need to be added, so I would rather not do this manually...

Thanks,

--benji

Benji Bergstein
Client Strategies
Giant Eagle, Inc.

12 REPLIES 12

Not applicable

I would find a way to script a conversion from the CSV to an SQL query (like I'm doing with our printers).

John_Wetter
Release Candidate Programs Tester

I'd say contact support. They can usually help with mass imports of things into the Db.

John
--
John Wetter
Technical Services Manager
Educational Technology, Media & Information Services
Hopkins Public Schools

donmontalvo
Esteemed Contributor III

I'll see your 200 and raise you 638.

I was just handed a list of 833 subnets to target for a push.

Beer...beer...I need a beer....

Don

--
https://donmontalvo.com

donmontalvo
Esteemed Contributor III

JAMF just rocked my world.....

https://yourJSSname:8443/apiResource.rest?resource=networksegments&method=POST

Off to test in our LAB...

Don

--
https://donmontalvo.com

jescala
Contributor II

Don, That is an awesome find! I was thinking about how the data could be imported and I came up with the following info that should give you a big boost in the lab. I would try it myself but I don't have a test environment for JSS and unfortunately I don't have the time right now.

I figured out that the list of subnets can be exported from AD as a CSV file using the "Sites and Services" MMC. That file lists subnets using CIDR notation (i.e.: 192.168.10.0/24). You can use the cidr_to_glob and glob_to_iprange functions from the Python netaddr package to convert CIDR to a starting and ending IP address:

http://packages.python.org/netaddr/

And you can probably modify this snippet of code to convert the CSV to XML that the JSS API can understand:

https://help.ubuntu.com/community/Converting%20CSV%20to%20XML#Python

Thanks and happy hacking!!

rcuza
New Contributor

If you don't know what the XML needs to look like, you can export an example from your JSS server. Additional details can be found at https://yourJSSname:8443/apiResource.rest?resource=networksegments&method=GET , but the short answer is

View all network segments: https://yourJSSname:8443/JSSResource/networksegments

rcuza
New Contributor

And if you prefer to collect the data via JSON:

curl -H "Accept: application/json" -u JSS_ADMIN https://yourJSSname:8443/JSSResource/networksegments -X GET

Unfortunately, JSON does not seem to be an option for making changes with POST and PUT.

mm2270
Legendary Contributor III

Not sure there's a need for any of this now that JAMF has built a special tool exactly for the purpose of importing IP subnets. YMMV in using it, but I would give that a try rather than attempting to write to the db manually with the API commands. The importer tool does the same thing, but in a more mass import way.

https://jamfnation.jamfsoftware.com/viewProduct.html?id=181

gabester
Contributor III

200? 833? Try 3246! My problem is I can't seem to get the network segments to apply their override values for the departments/buildings those network segments they're assigned.

I wish someone had told me about the tool there, I borrowed this guy's script and improved it a little for my needs to upload all those segments and apply meaningful names to them as parsed from the known location, department and building values. Also used to load in the buildings, departments, and distribution points:

http://bashscripts.org/forum/viewtopic.php?f=8&t=1330

gabester
Contributor III

My problem was:

https://jamfnation.jamfsoftware.com/discussion.html?id=8874#responseChild48049

Followed up with JAMF support. While most of the network segments I'd put in place via a bash script from a csv were /20 or /21, someone had put in place an "All external IPs" address which was defined as 1.1.1.1 to 255.255.255.255. Apparently this uncovered a bug because the most restrictive network segment should apply to the device (i.e. all my intranet IPs should have had their settings including overrides apply.)

So if you're on JSS 9.2 and your network segments don't seem to be doing what they should, try changing the scope in any larger all-inclusive networks to see if their subnets will begin to work as they should! Defect ID D-005656 was filed last week in regards to the specific behavior exhibited when an all encompassing Network Segment was included.

sumit_batra
New Contributor

I tried using the JSS Subnet Importer tool, but unfortunately nothing shows up in network segments. The log file says import was success. Using JSS Subnet Importer & JSS 9.2.2. Any suggestions would be highly appreciated. https://jamfnation.jamfsoftware.com/viewProduct.html?id=181

bchapman_mattel
New Contributor

The JSS Subnet Importer tool is helpful, but the documentation is lacking. For one, the included subnet.csv example file doesn't explain what should go in the other fields like "distribution_point" or "netboot_server" . It makes sense to enter a raw number corresponding to the JSS ID value of that particular attribute, but it would be nice to have some verification from JAMF on that.

An earlier suggestion to export the existing configuration as an XML is helpful.