Netsh, or Network Shell, 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 network interface controllers (NICs).
To configure Windows IPv4 networking with Netsh, you can use the following commands:
Netsh interface ipv4 show to display the current IPv4 configuration.
Netsh interface ipv4 set address to set the IPv4 address, subnet mask, and default gateway.
Netsh interface ipv4 set dns to set the DNS servers.
Netsh interface ipv4 set Winsock to reset the Windows Sockets (Winsock) catalog.
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 Server or Windows clinets such as Windows 11.
In the GUI environment, we can easily set or change IP to a NIC.
- Open a Command Prompt window with administrative privileges. Netsh work in both command prompt and PowerShell. I’m using Windows Powershell.
- Type the following command to display the current IP configuration:
netsh interface ipv4 show addresses
3. To show or list the interface cards, just type:
Netsh interface ipv4 show interface
Now you see two network interfaces. Ethernet0 with index ID 3 is the physical interface that we should set IP and configure.
Netsh interface ipv4 show config Ethernet0. to see the configuration of a interface. You can set the index IP instead of the interface name.
It got an IP address from APIPA (automatic private IP address).
5. To set a 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.
Let’s see the result by typing:
netsh interface ipv4 show config 3 to see if it works correctly.
Note: You can set the default gateway separately by typing:
Netsh interface ipv4 set address name=3 gateway=192.168.10.1 and press enter. It can set the default gateway but may reset the IP address to APIPA like in the below screenshot.
6. Now try to set the DNS Server IP address with:
Netsh interface ipv4 set dns name=3 static 192.168.10.10 primary and press enter.
It shows an error, but it works correctly. The error is due to the lack of a DNS server. If there were a DNS server, we would not encounter any errors.
Enable ICMPv4 to make machine pingable via network
Internet Control Message Protocol version 4 (ICMPv4) is a network layer protocol that is used to send control messages between hosts and routers on an IP network. ICMPv4 messages are used for a variety of purposes, including:
- Error reporting: ICMPv4 messages can be used to report errors that occur during the transmission of IP datagrams. For example, if a router is unable to route a datagram to its destination, it will send an ICMPv4 error message back to the source host.
- Troubleshooting: ICMPv4 messages can be used to troubleshoot network problems. For example, if a host is unable to reach another host on the network, it can send an ICMPv4 echo request message to the destination host. If the destination host receives the echo request message, it will send an echo reply message back to the source host. This can help to determine if there is a problem with the network between the two hosts.
- Informational messages: ICMPv4 messages can also be used to send informational messages, such as router advertisements and neighbor solicitation messages. These messages are used to keep track of the topology of an IP network.
ICMPv4 is a very important protocol for the operation of IP networks. It is used to report errors, troubleshoot problems, and keep track of the topology of an IP network.
Here are some of the most common ICMPv4 messages:
- Echo request: This message is used to request a response from a destination host.
- Echo reply: This message is sent in response to an echo request message.
- Destination unreachable: This message is sent to the source host when a datagram cannot be delivered to its destination.
- Time exceeded: This message is sent to the source host when a datagram’s Time to Live (TTL) expires.
- Redirect: This message is sent to the source host to suggest an alternate route to its destination.
ICMPv4 is a part of the Internet Protocol suite (TCP/IP) and is defined in RFC 792. It is used by all IP-based networks, including the Internet.
1. By default ICMPv4 (echo request) is disabled and you can’t ping the system via network. To enable it by command line just type:
netsh advfirewall firewall add rule name=ICMPV4 protocol=icmpv4 dir=in action=allow.
2. To see if it is enabled or not yet type
Netsh advfirewall firewall show rule name=icmpv4 and press enter.
Alright, that’s all you need to know to configure the IPv4 IP address of Windows Server 2012 to Windows Server 2022, Windows 7, 8, 10, and Windows 11.
The following commands are just some examples of netsh for showing:
Commands in this context:
show addresses – Shows IP address configurations.
– Shows compartment parameters.
– Displays IP address and additional information.
– Shows destination cache entries.
– Displays the DNS server addresses.
– Shows dynamic port range configuration parameters.
– Shows all excluded port ranges.
– Shows global configuration parameters.
– Displays ICMP statistics.
– Shows interface parameters.
– Shows current IP addresses.
– Displays IP net-to-media mappings.
– Displays IP statistics.
– Displays multicast groups joined.
– Shows neighbor cache entries.
– Displays the offload information.
– Shows route table entries.
– Shows subinterface parameters.
– Displays TCP connections.
– Displays TCP statistics.
– Displays UDP connections.
– Displays UDP statistics.
– Displays the WINS server addresses.