SID-500

Home » PowerShell » PowerShell: Finding neighbors with Get-NetNeighbor

PowerShell: Finding neighbors with Get-NetNeighbor

Do you know your neighbors? I mean the neighbors in the real word. I hope so. But what about the virtual neighbors? The PowerShell module NetTCPIP provides a command called Get-NetNeighbor. In this article i use this command to play with neighbor discovery to find all my cached neighbors sharing the same link. 

Get-NetAdapter

First check out the Interface ID (ifIndex) or name of your network adapter.

Get-NetAdapter

1PNG.PNG

Get-NetNeighbor in Action

IPv4

Get-NetNeighbor -InterfaceAlias "Ethernet 2" -AddressFamily IPv4

Unbenannt.PNG

IPv6

Get-NetNeighbor -InterfaceAlias "Ethernet 2" -AddressFamily IPv6

2PNG.PNG

Show all IPv4 neighbors except broadcast addresses and multicast addresses

Get-NetNeighbor -AddressFamily IPv4 | Where-Object {($_.IPAddress -like "192.168.0.*") -and ($_.IPAddress -ne "192.168.0.255")}

2.PNG

Show all IPv6 neighbors except multicast addresses

For communication on the same link Link-Local Adresses are used. To show all IPv6 neighbors with Link-Local Addresses run

Get-NetNeighbor -IPAddress fe80* -AddressFamily Ipv6

1.PNG

Have fun discovering your neighbors! 😉 Also see my article: The modern version of ping: Test-Connection.


1 Comment

  1. […] Test-Connection is for testing the connectivity to a remote host. For information about your directly connected neighbors on a shared link please read my article PowerShell: Finding neighbors with Get-NetNeighbor. […]

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

Who is the blogger?

My name is Patrick Grünauer (pewa2303). I am from Austria. On sid-500 I write about Windows, Cisco and IT-Security in English and German. Have fun while reading!

Patrick Gruenauer
Follow SID-500 on WordPress.com