Windows and Networking Basics: Basic Windows Commands - Network-Related Operations

1. Configure TCP/IP parameters

insert image description here

IP address

Identifies a host in the network

Question: Why is the IP address found by the command IPCONFIG different from the IP address I checked online?

Answer: ipconfig checks your intranet ip address, while online ip check is the public network ip assigned to you by the service provider (that is, China Netcom or China Telecom). The public network ip is used to connect to the Internet, while the intranet ip only distinguishes the addresses of the local area network, a local area network can have 100 computers, you can use a public network ip (through the router) to access the Internet, but the local area network must be distinguished, all have intranet ip

Example: Query the IP address of www.baidu.com and
insert image description here
insert image description here
find that it is in Nanjing

subnet mask

It is used to identify the range of the network where your ip is located. The larger the subnet mask, the smaller the network range.

default gateway

The IP address that identifies the address of the router that is directly connected to the host

DNS server

for domain name resolution

command line related commands

Statically configure IP address, subdomain mask, default gateway

netsh interface ip set address "Ethernet0" static 192.168.100.100 255.255.255.0  192.168.100.254

insert image description here

Get TCP/IP parameters automatically

netsh interface ip set address "Ethernet0" dhcp

insert image description here

Statically configure DNS server

netsh interface ip set dnsserver "Ethernet0" static 12.12.12.12

insert image description here

Add alternate DNS server

netsh interface ip add dnsserver "Ethernet0" 222.66.66.66 index=2 //index是索引,表示备用

insert image description here

Obtain DNS server automatically

netsh interface ip set dnsserver "Ethernet0" dhcp

2. View TCP/IP parameters, use ipconfig

View TCP/IP parameters of all network cards (IP address, subnet mask, default gateway)

ipconfig

insert image description here

ipconfig /all

View TCP/IP parameters of all network cards (ip address, subnet mask, default gateway, mac address, dhcp address, dns address, hostname)

ipconfig /all

insert image description here

ipconfig /release

Release TCP/IP parameters

ipconfig /release

insert image description here

ipconfig /renew

Reacquire TCP/IP parameters

ipconfig /renew

insert image description here

ipconfig /flushdns

flush dns cache

ipconfig /flushdns

insert image description here

3.ping command

Function: used to test whether the TCP/IP configuration is correct

insert image description here

ping -n 10 www.baidu.com

Used to send 10 messages
insert image description here

ping -l 1000 www.baidu.com

A single message of 10000 bytes
insert image description here
insert image description here

ping -t www.baidu.com

keep pinging
insert image description here

ping -a

Returns the hostname of the IP (multiple for LANs)

4.tracert

Function: trace route
insert image description here

5.route

print routing table

insert image description here

Add route entry

Example:

route add 112.53.42.52/32 192.168.33.1

112.53.42.52 is the destination address or network /32 stands for subdomain mask or 112.53.42.0
or 112.53.12.0 destination network, /24 subdomain mask
192.168.33.1 gateway address

insert image description here

delete route entry

Example:

route delete 0.0.0.0 //0.0.0.0是网络目标

insert image description here

6.netstat

View all TCP connections, including processes, displayed numerically

Example:

netstat -anop tcp

insert image description here

View routing table

Example:

netstat -r  //等于与 route  print

insert image description here

Guess you like

Origin blog.csdn.net/m0_51456787/article/details/124369258