【小白教程】Windows常用网络命令大全-ipconfig命令
ipconfig命令
ipconfig命令查看和维护本机的IP地址。
用法
ipconfig 可选参数
常用参数
/all:显示所有网络适配器的完整的TCP/IP配置。
/release:释放当前获取到的动态ip。
/release6:释放当前获取到的动态ip(ipv6专用)。
/renew:重新向dhcp服务器申请IP。
/renew6:重新向dhcp服务器申请IP(ipv6专用)。
/flushdns:刷新当前的dns缓存。。
/displaydns:显示dns缓存的内容,包括从本地Hosts文件预装载的记录以及由域名解析服务器解析的所有资源记录。
例子
我想查看当前网卡的ip,直接输入ipconfig即可,无需任何参数,如下:
C:\>>ipconfig Windows IP Configuration Ethernet adapter 以太网: Media State . . . . . . . . . . . : Media disconnected Connection-specific DNS Suffix . : Wireless LAN adapter WLAN: Connection-specific DNS Suffix . : lan Link-local IPv6 Address . . . . . : fe80::49ab:a4f4:a3f4:6707%7 IPv4 Address. . . . . . . . . . . : 192.168.199.123 Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . : 192.168.199.1
输入ipconfig命令后,会显示当前所有的网卡以及分配的ip地址(包含ipv4和ipv6)、子网掩码以及网关地址.
如果想查看更多信息,则可以输入ipconfig /all,如下:
C:\>ipconfig /all Windows IP Configuration Host Name . . . . . . . . . . . . : DESKTOP-GO4UQ3I Primary Dns Suffix . . . . . . . : Node Type . . . . . . . . . . . . : Hybrid IP Routing Enabled. . . . . . . . : No WINS Proxy Enabled. . . . . . . . : No DNS Suffix Search List. . . . . . : lan Ethernet adapter 以太网: Media State . . . . . . . . . . . : Media disconnected Connection-specific DNS Suffix . : Description . . . . . . . . . . . : Realtek PCIe GBE Family Controller Physical Address. . . . . . . . . : 80-FA-5B-4B-F3-BA DHCP Enabled. . . . . . . . . . . : Yes Autoconfiguration Enabled . . . . : Yes Wireless LAN adapter WLAN: Connection-specific DNS Suffix . : lan Description . . . . . . . . . . . : Intel(R) Dual Band Wireless-AC 3168 Physical Address. . . . . . . . . : F4-96-34-D2-8D-77 DHCP Enabled. . . . . . . . . . . : Yes Autoconfiguration Enabled . . . . : Yes Link-local IPv6 Address . . . . . : fe80::49ab:a4f4:a3f4:6707%7(Preferred) IPv4 Address. . . . . . . . . . . : 192.168.199.123(Preferred) Subnet Mask . . . . . . . . . . . : 255.255.255.0 Lease Obtained. . . . . . . . . . : Tuesday, October 16, 2018 11:12:37 Lease Expires . . . . . . . . . . : Tuesday, October 16, 2018 23:12:37 Default Gateway . . . . . . . . . : 192.168.199.1 DHCP Server . . . . . . . . . . . : 192.168.199.1 DHCPv6 IAID . . . . . . . . . . . : 66360884 DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-21-FC-CB-36-80-FA-5B-4B-F3-BA DNS Servers . . . . . . . . . . . : 192.168.199.1 NetBIOS over Tcpip. . . . . . . . : Enabled
上述命令执行完毕后,会显示更多信息,比如网卡的型号、mac地址、dhcp服务器信息、ip期限、dns等一系列信息。
另外日常网络管理中,其他几个参数用到的也很多,比如/flushdns参数,用于更新dns缓存,一般购买域名第一次解析ip的时候或者域名更换dns服务器的时候用到,使用方法也很简单,直接输入命令即可清除dns缓存记录,如下:
C:\>ipconfig /flushdns Windows IP Configuration Successfully flushed the DNS Resolver Cache. C:\>
另外的2个命令需要配合使用,即release和renew参数,release为释放掉当前获取的ip,renew为重新申请ip,一般在网络不是很稳定的时候或者网络环境比较复杂的情况下使用,当你的电脑无法上网不妨尝试一下,有时候可以解决不少问题。下面是实例:
C:\>ipconfig /release Windows IP Configuration No operation can be performed on 以太网 while it has its media disconnected. Ethernet adapter 以太网: Media State . . . . . . . . . . . : Media disconnected Connection-specific DNS Suffix . : Wireless LAN adapter WLAN: Connection-specific DNS Suffix . : Link-local IPv6 Address . . . . . : fe80::49ab:a4f4:a3f4:6707%7 Default Gateway . . . . . . . . . : C:\>ipconfig /renew Windows IP Configuration No operation can be performed on 以太网 while it has its media disconnected. Ethernet adapter 以太网: Media State . . . . . . . . . . . : Media disconnected Connection-specific DNS Suffix . : Wireless LAN adapter WLAN: Connection-specific DNS Suffix . : lan Link-local IPv6 Address . . . . . : fe80::49ab:a4f4:a3f4:6707%7 IPv4 Address. . . . . . . . . . . : 192.168.199.123 Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . : 192.168.199.1
renew参数能否获取到全新的ip取决于DHCP服务器的策略,如果网络环境稳定并且整个网络只有一台DHCP服务器,那么很可能renew参数获取到的ip跟释放之前的完全一样。