Infoblox’s global team of threat hunters uncovers a DNS operation with the ability to bypass traditional security measures and control the Great Firewall of China. Read about “Muddling Meerkat” and the many other threat actors discovered by Infoblox Threat Intel here.

API & Integration, DevOps,NetOps,SecOps

Reply

Powershell: Add Host with MAC and enabled DNS

[ Edited ]
New Member
Posts: 1
2033     0

Hello everyone,

 

I have been working on this problem for several days now and have not yet found a solution. I have looked at all the modules I know of and unfortunately I just can't get any further. I would therefore be extremely grateful for help. Here is my situation:

 

I create a VM using a PowerShell script. I then want to assign it an IP using its MAC address. This works so far, but I need DHCP and DNS to be active in our company. When I create the HostRecord, DHCP is already activated. However, DNS is missing.

 

The final configuration should look like this:

 

infoblox.png

 

I don't know how to activate DNS and also pass the corresponding zone. I am including my previous script. I would really be infinitely grateful if anyone has a solution for this. Thank you very much!

 

Code:

 

$pwd = ConvertTo-SecureString "PW" -AsPlainText -Force
$Credential = New-Object Management.Automation.PSCredential ('ID', $pwd)
$GridServer = "SERVER" 
$network = "REF"
$IPv4Address = Get-IBNextAvailableIP -GridServer $grid -Credential $cred -NetworkRef $network
$HostName = "NAME"
$Comment = "COMMENT"

$apiVersion = "2.10.5"
$uri = "https://$grid/wapi/v$apiVersion/record:host"
$dns = $true

$data = @{

    ipv4addrs = @(
        @{        
            ipv4addr = $IPv4Address
            mac = "00:50:56:88:89:35"
            }
        )
    name = $HostName
    comment = $Comment.Trim()
    configure_for_dns = $dns


}
$json = $data | ConvertTo-Json

Invoke-RestMethod -Uri $uri -Method Post -Body $json -ContentType 'application/json' -Credential $Credential

Re: Powershell: Add Host with MAC and enabled DNS

Superuser
Posts: 65
2034     0

The value of "name" needs to be an FQDN, in an existing zone to configure the host record for DNS. For example, if you want a DNS record in the zone mycompany.com, pass a value of name.mycompany.com.

Showing results for 
Search instead for 
Did you mean: 

Recommended for You