Any system administrator is faced with configuring network interfaces. Most of them use graphical interface Windows for this purpose, which is not always convenient. In this article, I will explain how to configure the network using the cmd command line interface using the built-in utility netsh.
On Windows operating systems, there is a special netsh utility for configuring a network adapter from the cmd command line.
Configuring network parameters (ip-addresses, netmask and gateway)
Setting the ip-address, mask and gateway:
netsh interface ip set address name="Local Area Connection" static 192.168.1.15 255.255.255.0 192.168.1.1
where
Local Area Connection - the name of your network interface.
192.168.1.15 - network address (ip address).
255.255.255.0 - network mask.
192.168.1.1 - default gateway.
Setting an additional ip-address:
netsh interface ip add address name="Local Area Connection" 192.168.1.20 255.255.255.0
Enable the automatic acquisition of ip-address, netmask and gateway from the DHCP server:
netsh interface ip set address "Local Area Connection" dhcp
Configuring DNS and WINS servers
Add a preferred DNS server:
netsh interface ip set dns "Local Area Connection" static 8.8.8.8
Add an alternate DNS server:
netsh interface ip add dns "Local Area Connection" 8.8.4.4
Add 3rd DNS server:
netsh interface ip add dns "Local Area Connection" 192.168.1.30 index=3
Setting the automatic retrieval of a preferred and alternate DNS server from a DHCP server:
netsh interface ip set dns "Local Area Connection" dhcp
Installing WINS server:
netsh interface ip set wins "Local Area Connection" static 192.168.1.240
Enable and disable network interfaces
Disable network interface:
netsh interface set interface name="Local Area Connection" admin=DISABLED
Enable interface:
netsh interface set interface name="Local Area Connection" admin=ENABLED
View network settings
Advanced network interface configuration output:
netsh interface ip show config
View interface status (connected/disconnected):
C:\Windows\System32>netsh interface ip show interface Инд Мет MTU Состояние Имя --- ---------- ---------- ------------ --------------------------- 1 50 4294967295 connected Loopback Pseudo-Interface 1 12 10 1300 disconnected Local Area Connection
View the routing table:
netsh interface ip show route
View IP addresses configuration:
netsh interface ip show addresses
View DNS server addresses:
netsh interface ip show dnsservers
Просмотр адресов WINS-сервера:
netsh interface ip show winsservers
Save and restore network interface configurations
Well, now the fun part. Let's talk about how to save the network settings as a configuration file and restore from the configuration file. This can be useful to those who are constantly changing network settings.
Save network settings as a file:
C:\Windows\System32>netsh -c interface dump > C:\my-config.txt
Restore network settings from file from configuration:
C:\Windows\System32>netsh -f C:\my-config.txt
That's all. We have considered far from all the features of the Netsh.exe utility, but only the most frequently used ones. Comment, subscribe. Bye everyone.
Comments powered by CComment