Skip to main content

Posts

Showing posts with the label Subnetting

PowerShell Test Port Forwarding

Port forwarding is necessary if the device is that needs to connect to the unsecured world of the Internet.
Of course, before opening port or doing any port forwarding make sure that security is in place. Firewall rules, software configuration are properly set, up-to-date anti-virus and other settings that needs to be done to secure the system.
PowerShell can test whether a remote port is open or a Port Forwarding rules on either on the Firewall or router is set correctly.
Here’s a one liner code, to check whether the Port is open or not.
Both one line code below does the same thing, check whether the Port is open or not.
1 . New-Object System.Net.Sockets.TCPClient -ArgumentList "Remote.Public.IP.Address", 3389
2. Test-NetConnection -Port 80 -InformationLevel Detailed

Replace the port number, with any port number to be tested.
If the connected property on the displayed output is true, then the port is open.

More details on the link below: https://technet.microsoft.com/en-us/lib…

Get network interfaces description in Windows

Netsh is a command line tool that is very useful provided of course you know exactly on how to use it.
Below is an example on how to display the GUID and the description of the network interface card.
   netsh trace show interfaces
Sample output: Ethernet adapter Ethernet: Description:Intel(R) I350 Gigabit Network Connection Interface GUID:{1C8DC74A-0BCD-48FF-F3B7-26B1FF4D5650} Interface Index: 12 Interface Luid:0x8000008000000

Tunnel adapter isatap.{BCF65C9D-CB58-49F7-8BA1-88DBF2A6FBCE}: Description:Microsoft ISATAP Adapter #3 Interface GUID:{F8BB0A84-D5A4-CA93-BA100-27EF2898CC82} Interface Index: 19 Interface Luid:0x12000005000000
The GUID (globally unique identifier) is used to identify objects in Windows registry. The above command shows the description and the interface GUID, but the above command also can be used to sniff or capture traffic.
netsh trace start capture=YES report=YES persistent=YES
Netsh packet sniffing is quite handy because it's already built-in on the system and no …

PowerShell Get IP Address and Subnet mask

Get IP Address, MAC Address and Subnet mask.

It also displays the CIDR (Classless InterDomain Routing) notation.

Here's the script:
 ======================================

$nic_configuration = gwmi -computer .  -class "win32_networkadapterconfiguration" | Where-Object {$_.defaultIPGateway -ne $null}
$IP = $nic_configuration.ipaddress
write-output " IP Address : $IP"

$MAC_Address = $nic_configuration.MACAddress
write-output " MAC Address :  $MAC_Address"

$SubnetMask = $nic_configuration.ipsubnet


switch ($SubnetMask) {
255.255.255.255   {" Subnet mask is: 255.255.255.255 or /32 "}
255.255.255.254   {" Subnet mask is: 255.255.255.254  or   /31 "}
255.255.255.252   {" Subnet mask is:  255.255.255.252 or   /30 "}
255.255.255.248   {" Subnet mask is: 255.255.255.248 or  /29 "}
255.255.255.240   {" Subnet mask is:   255.255.255.240   or   /28"}
255.255.255.224   {" Subnet mask is:   255.255.255.224   or   /27&q…