Configure Windows IPv4 Networking with Netsh

Configuring Windows IPv4 Networking with Netsh or Network Shell. Netsh is a command-line utility included in Microsoft’s Windows NT line of operating systems beginning with Windows 2000. It allows local or remote configuration of network devices such as the NICs.

Configure IPv4 Networking with Netsh

Now I’m going to show you how to set IPv4-TCP/IP protocol with Netsh command-line tool in Windows Server 2012 R2 or Windows 10 Operating system.
In the GUI environment, we can easily set or change IP to a NIC.

Internet Protocol version 4 (TCP-IP) Properties
Internet Protocol version 4 (TCP/IP) Properties

Ok, run cmd or Powershell as administrator, Netsh work in both command prompt and Power Shell. I’m using Windows Powershell.
To show or list the interface cards, just type: Netsh interface ipv4 show interface

Network Interface Cards
Network Interface Cards

Now you see tow interface cards. Ethernet0 with index id 3 is the physical interface we should set IP and configure it.
Type: Netsh interface ipv4 show config Ethernet0. You can set index IP instead of the interface name.

Automatic pricate ip address
Automatic private IP address

It gets IP address from APIPA (automatic private IP address).
To set new IP address type: Netsh interface ipv4 set address name=Ethernet0 static 192.168.10.15 mask=255.255.255.0 gateway=192.168.10.1 and press enter and type: netsh interface ipv4 show config 3. to see if it work correctly.

Set IP address and default gateway
Set IP address and default gateway

You can adjust the default gateway separately by typing: Netsh interface ipv4 set address name=3 gateway=192.168.10.1 and press enter. It can set default gateway but may reset the IP address to APIPA like below screenshot.

Set default gateway
Set default gateway

Now try to set DNS Server IP address with: Netsh interface ipv4 set dns name=3 static 192.168.10.10 primary and press enter.

Set DNS Server address - Pv4 Networking with Netsh
Set DNS Server address –  Configure IPv4 Networking with Netsh

It shows an error but works correctly. The error is the lack of DNS Server, if there is a DNS server, we will not face with any errors.

By default ICMPv4 (echo request) is disabled and you can’t ping to the system. To enable it by command line just type: netsh advfirewall firewall add rule name=ICMPV4 protocol=icmpv4 dir=in action=allow.

Enable echo request with netsh
Enable echo request with netsh

To see if it is enabled or not yet type Netsh advfirewall firewall show rule name=icmpv4 and press enter.

ICMPv4 configuration
ICMPv4 configuration

Ok. That’s all you must know to configure IPv4 IP address of Windows Server 2012 R2, Windows 7,8,8.1 and Windows 10. So good luck.

You might also like

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.