Controlling Windows networking from command line
Listing all interfaces (IPv4):
1 2 3 4 5 6 7 8 9 10 |
C:\Users\Mads>netsh interface ipv4 show interfaces Idx Met MTU State Name --- ---------- ---------- ------------ --------------------------- 1 50 4294967295 connected Loopback Pseudo-Interface 1 29 25 1500 disconnected WiFi 33 5 1500 disconnected Ethernet 30 5 1500 disconnected Local Area Connection* 14 32 5 1500 connected vEthernet (Internal - Shared) 25 10 1500 connected Local Area Connection 2 |
Setting a static IP adresse:
1 |
C:\Users\Mads>netsh interface ipv4 set address name="Ethernet" source=static address=192.168.137.1 mask=255.255.255.0 gateway=192.168.137.1 |
Setting to DHCP:
1 |
C:\Users\Mads>netsh interface ipv4 set address name="Ethernet" source=dhcp |
Add additional IP adresses:
1 |
C:\Users\Mads>netsh interface ipv4 add address “Ethernet” 192.168.137.2 255.255.255.0 |
Add DNS servers:
1 2 |
C:\Users\Mads>netsh interface ipv4 add dnsservers "Ethernet" 8.8.8.8 C:\Users\Mads>netsh interface ipv4 add dnsservers "Ethernet" 8.8.4.4 index=2 |
Reply