Pokazywanie postów oznaczonych etykietą netsh. Pokaż wszystkie posty
Pokazywanie postów oznaczonych etykietą netsh. Pokaż wszystkie posty

2018-10-19

no communication - arp cache and netsh

Very strange - according to my new knowledge from Internet arp cache can be configured in two ways:
- arp command
- netsh interface ipv4 ... neighbors

I found a problem with arp cache - and It was new to me - that netsh interface ipv4 creating static values that will remain after restart and can't be removed by arp command, for example:
netsh interface ipv4 show neighbors

Interface 3: Ethernet

Internet Address                              Physical Address   Type
--------------------------------------------  -----------------  -----------
224.0.0.22                                    01-00-5e-00-00-16  Permanent

Interface 1: Loopback Pseudo-Interface 1


Internet Address                              Physical Address   Type
--------------------------------------------  -----------------  -----------
224.0.0.22                                                       Permanent
239.255.255.250                                                  Permanent

Interface 6: Network connection Bluetooth


Internet Address                              Physical Address   Type
--------------------------------------------  -----------------  -----------
224.0.0.22                                    01-00-5e-00-00-16  Permanent

Interface 7: LAN connection* 3


Internet Address                              Physical Address   Type
--------------------------------------------  -----------------  -----------
224.0.0.22                                    01-00-5e-00-00-16  Permanent

Interface 22: vEthernet (xxxx)


Internet Address                              Physical Address   Type
--------------------------------------------  -----------------  -----------
192.168.137.1                                 48-50-73-02-8f-22  Reachable
192.168.137.255                               ff-ff-ff-ff-ff-ff  Permanent
224.0.0.22                                    01-00-5e-00-00-16  Permanent
224.0.0.252                                   01-00-5e-00-00-fc  Permanent
239.255.255.250                               01-00-5e-7f-ff-fa  Permanent
255.255.255.255                               ff-ff-ff-ff-ff-ff  Permanent
multicast and broadcast addresses created by operating system - by default.

The same table from arp -a command:
arp -a

Interface: 192.168.137.177 --- 0x16
  Internet Address      Physical Address      Type
  192.168.137.1         48-50-73-02-8f-22     dynamic
  192.168.137.255       ff-ff-ff-ff-ff-ff     static
  224.0.0.22            01-00-5e-00-00-16     static
  224.0.0.252           01-00-5e-00-00-fc     static
  239.255.255.250       01-00-5e-7f-ff-fa     static
  255.255.255.255       ff-ff-ff-ff-ff-ff     static
If I'll create new entry by netsh:

netsh interface ipv4 ipv4 add neighbors 22 "192.168.137.219" "12-34-56-78-9a-bc"

Interface 22: vEthernet (xxxx)


Internet Address                              Physical Address   Type
--------------------------------------------  -----------------  -----------
192.168.137.1                                 48-50-73-02-8f-22  Reachable
192.168.137.219                               12-34-56-78-9a-bc  Permanent
192.168.137.255                               ff-ff-ff-ff-ff-ff  Permanent
224.0.0.22                                    01-00-5e-00-00-16  Permanent
224.0.0.252                                   01-00-5e-00-00-fc  Permanent
239.255.255.250                               01-00-5e-7f-ff-fa  Permanent
255.255.255.255                               ff-ff-ff-ff-ff-ff  Permanent

from arp -a:
Interface: 192.168.137.177 --- 0x16
  Internet Address      Physical Address      Type
  192.168.137.1         48-50-73-02-8f-22     dynamic
  192.168.137.219       12-34-56-78-9a-bc     static
  192.168.137.255       ff-ff-ff-ff-ff-ff     static
  224.0.0.22            01-00-5e-00-00-16     static
  224.0.0.252           01-00-5e-00-00-fc     static
  239.255.255.250       01-00-5e-7f-ff-fa     static
  255.255.255.255       ff-ff-ff-ff-ff-ff     static

It looks like the same, but If I remove it from arp command it will return after restart - I must remove it from netsh command. What is very dangerous, that I can remove all static entries by single stuipid command:
netsh interface ipv4 delete neighbors
without any warning, just like throw to a black hole or null (*nix).
For Windows 2008/Vista arp cache managed by netsh was a dangerous way - without a fix it wasn't possible to remove this static entry.

2018-08-09

netsh dhcp create scope

How to create dhcp scopes in older system - without dhcp module:
#create-DHCPScopes

$fileData = Get-Content c:\temp\scripts\some-file.txt

$fileData | %{
    # header of my file - tab is separator
    #  SHORT_SUBNET SUBNET_MASK  DHCP-LO      DHCP-HI      GW     NAME
    $line = $_
    $tabline = $line.Split("`t")
 

    $name = $tabLine[5]
    $dhcpName = """$name"""
    $description = "some descritpion"

    if ($tabline[0] -ne "SHORT_SUBNET") {
        netsh dhcp server add scope $tabLine[0] $tabline[1] $dhcpName $description
        netsh dhcp server scope $tabLine[0] set state 1
        netsh dhcp server scope $tabLine[0] set name $dhcpName
        netsh dhcp server scope $tabLine[0] set optionvalue 003 IPADDRESS $tabLine[4]
        netsh dhcp server scope $tabLine[0] set optionvalue 051 DWORD 2592000
        netsh dhcp server scope $tabLine[0] add iprange $tabLine[2] $tabLine[3]
    }
}