ā¦as it just so happens, Iāve been working on an Analysis and Dashboard to bulk-import my BES Clients as Bare Metal Targets for āBigFix OS Deployment and Bare Metal Imagingā. Iām pulling the full network config for both Windows and Linux in the following query, probably much more than you need, but here you goā¦
q: if windows of operating system then (((friendly name of it, mac addresses of it, (if dhcp enabled of it then "dhcp" else "static") , addresses of it, subnet masks of it, gateways of it, concatenation ";" of (addresses of dns servers of it as string) , dns suffix of it) of adapters whose (exists addresses whose (it!="0.0.0.0") of it) of network)) else if name of operating system as lowercase starts with "linux" then ((names of it, mac addresses of it, (if not exists file ("/etc/sysconfig/network-scripts/ifcfg-" & name of it) then "" else if exists key "BOOTPROTO" whose (it as string as lowercase contains "dhcp") of file ("/etc/sysconfig/network-scripts/ifcfg-" & name of it) then "dhcp" else "static") , addresses of it,subnet masks of it, (if exists property "routing table" then (if exists gateways of routes whose (destination of it = "0.0.0.0") of routing table then (gateways of routes whose (destination of it = "0.0.0.0") of routing table as string) else "") else (if exists key "GATEWAY" of files ("/etc/sysconfig/network-scripts/ifcfg-" & name of it) then concatenation of substrings separated by "%22" of key "GATEWAY" of file ("/etc/sysconfig/network-scripts/ifcfg-" & name of it) else "")) , (if not exists line starting with "nameserver" of file "/etc/resolv.conf" then "" else concatenation ";" of first matches (regex "[^\ ]+") of following texts of firsts "nameserver" of lines starting with "nameserver" of file "/etc/resolv.conf") , (if not exists line starting with "domain" of file "/etc/resolv.conf" then "" else /* Some nsswitch.conf files are malformed, containing two "domain" lines; handle that case via tuple string items 0*/ tuple string items 0 of concatenation ", " of first matches (regex "[^\ ]+") of following texts of firsts "domain" of lines starting with "domain" of file "/etc/resolv.conf")) of ip interfaces whose (not loopback of it AND exists mac address of it) of network) else nothing
A: Local Area Connection 2, 88-51-fb-6b-c8-2f, dhcp, XXX.XXX.XXX.XXX, 255.255.255.0, XXX.XXX.XXX.1, XXX.DNS.SRV.XXX;XXX.DNS.SRV.2;XXX.DNS.SRV.3, mydomain.myagency.gov
T: 19.393 ms
I: plural ( string, string, string, ipv4 address, ipv4 address, ipv4 address, string, string )
You should be able to trim that to just the parts you need. To configure DHCP (on Windows I assume?), youād use the ānetsh.exeā command:
C:\Program Files\Java>netsh int ipv4 set address
One or more essential parameters were not entered.
Verify the required parameters, and reenter them.
The syntax supplied for this command is not valid. Check help for the correct syntax.
Usage: set address [name=]<string>
[[source=]dhcp|static]
[[address=]<IPv4 address>[/<integer>] [[mask=]<IPv4 mask>]
[[gateway=]<IPv4 address>|none [gwmetric=]<integer>]
[[type=]unicast|anycast]
[[subinterface=]<string>]
[[store=]active|persistent]
Parameters:
Tag Value
name - Interface name or index.
source - One of the following values:
dhcp: Enables DHCP for configuring IP addresses for
the specified interface.
static: Disables DHCP for configuring IP addresses for
the specified interface. This value must be
specified if an address or a gateway is being
configured.
address - IPv4 address to add or modify, optionally followed by
the subnet prefix length.
mask - The IP subnet mask for the specified IP address.
gateway - One of the following values:
<IPv4 address>: A specific default gateway for the
static IP address you are setting.
none: No default gateways are set. This is the default.
gwmetric - The metric for the default gateway. This field should
be set only if gateway is specified.
type - One of the following values:
unicast: Marks the address as a unicast address.
This is the default.
anycast: Marks the address as an anycast address.
subinterface - LUID of the subinterface on which the default gateway
exists. This parameter is only needed on interfaces
with multiple subinterfaces.
store - One of the following values:
active: Set only lasts until next boot.
persistent: Set is persistent. This is the default.
Remarks: Used to enable or disable DHCP for IP address configuration.
Also removes any previous static IP addresses and default gateways,
and can add a new static IP address and default gateway.
Examples:
set address name="Local Area Connection" source=dhcp
set address "Local Area connection" static 10.0.0.9 255.0.0.0 10.0.0.1 1
Edit: This Relevance can be expensive, so when you put it into an Analysis ensure that you donāt evaluate it too frequently. Iām only pulling this weekly in my system.