Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Powershell- acquires IP information corresponding to MAC address

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Because the business needs to bind the device MAC on the DHCP server, it is prompted that "the specified IP address or hardware address is being used by other clients". The device has reserved the address before communicating with business colleagues, and the corresponding address has been forgotten.

Problem description:

a. Add address reservation according to user needs:

b. Tip: the specified IP address or hardware address is being used by another client; add failed.

Environment description: Windows DHCP Server 2016

Procedure:

1. View DHCP related commands on the Powershell command line:

Help Get-DhcpServerv

Help Get-DhcpServerv4Lease obtains one or more lease records from the dynamic Host configuration Protocol (DHCP) server service.

Help GET-DhcpServerv4Scope returns the IPv4 range configuration for the specified range. If the ScopeId parameter is not specified, all ranges configured on the dynamic Host configuration Protocol (DHCP) server service are returned.

Syntax:

Get-DhcpServerv4Lease [- ComputerName]-IPAddress [- CimSession] [- ThrottleLimit] [- AsJob] []

Get-DhcpServerv4Lease [- ComputerName] [- ScopeId] [- ClientId] [- CimSession] [- ThrottleLimit] [- AsJob] []

Get-DhcpServerv4Lease [- ComputerName] [- BadLeases] [[- ScopeId]] [- CimSession] [- ThrottleLimit] [- AsJob] []

two。 Query the lease information under all scopes and confirm that the attribute related to the MAC address is ClientId:

Get-DhcpServerv4Scope | Get-DhcpServerv4Lease

3. Filter the IP address information corresponding to the above MAC address:

Get-DhcpServerv4Scope | Get-DhcpServerv4Lease | where {$_. ClientId-like "b4-b6-86 Mustang b4 Mustang *"}

4. Delete existing binding information.

5. Re-add address reservation to complete the operation.

Add address reservation on the netsh command line:

Netsh dhcp server 10.17.1.220 scope 10.17.2.0 add reservedip 10.17.2.221 b4035ad6f189 Print

Server 10.17.1.220 DHCP server IP address

Scope 10.17.2.0 specifies the area and the network number where the area is located

Addreservedip 10.17.2.221 b4035ad6f189 Print adds a reserved address (addreservedip), MAC address assigns a reserved ip address to the computer of b4035ad6f189, and retains the name Print

Powershell add address reservation:

Add-DhcpServerv4Reservation-ScopeId 10.18.66.0-IPAddress 10.18.66.223-ClientId 00155D36C907-Description "POC_Test1"-Name "POC02"-Type Dhcp

Get-Dhcp* added:

Get- Dhcp Serverv4Binding gets the IPv4 interface on the computer that is bound to the DHCP server service.

Get- Dhcp Serverv4Class retrieves the IPv4 vendor or user category from the DHCP server service.

Get- Dhcp Serverv4DnsSetting gets the DNS settings configured for a specific scope, reservation, or server level on the DHCP server service.

Get- Dhcp Serverv4ExclusionRange returns a range of IPv4 addresses excluded from the specified range ID.

Get- Dhcp Serverv4Failover gets the failover relationship that the specific failover relationship name configures on the DHCP server service.

Get- Dhcp Serverv4Filter gets the MAC address in the allow list or the deny list on the DHCP server service.

Get- Dhcp Serverv4FilterList gets the enabled status of the allowed filter list and rejects the filter list set on the DHCP server service.

Get- Dhcp Serverv4FreeIPAddress gets a free IPv4 address from a specified range.

Get- Dhcp Serverv4Lease obtains one or more lease records from the DHCP server service.

Get- Dhcp Serverv4MulticastExclusionRange retrieves the exclusion scope of the specified multicast scope.

Get- Dhcp Serverv4MulticastLease retrieves the multicast lease for the specified scope name.

Get- Dhcp Serverv4MulticastScope gets the multicast scope object.

Get- Dhcp Serverv4MulticastScopeStatistics gets multicast scope statistics.

Get- Dhcp Serverv4OptionDefinition gets the DHCPv4 option definition for the specified option ID.

Get- Dhcp Serverv4OptionValue returns the IPv4 option value of the IPv4 option at the server, scope, or reservation level.

Get- Dhcp Serverv4Policy gets the policy at the server level or scope level.

Get- Dhcp Serverv4PolicyIPRange obtains the IP address range from the specified range of policies.

Get- Dhcp Serverv4Reservation gets the IP address or the IPv4 reservation of the client ID.

Get- Dhcp Serverv4Scope returns the IPv4 scope configuration for the specified scope.

Get- Dhcp Serverv4ScopeStatistics gets the IPv4 range statistics corresponding to the IPv4 range ID specified for the DHCP server service.

Get- Dhcp Serverv4Statistics gets the DHCP server service statistics for IPv4.

Get- Dhcp Serverv4Superscope gets the configuration of the specified superclass.

Get- Dhcp Serverv4SuperscopeStatistics returns statistics for the superuser.

Welcome to the official account of Wechat: Xiao Wen study Society.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 226

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report