In order to facilitate reading, or write in the form of questions and answers ~

What parts does the URL contain, and what does each part do

What’s the URL?

A: Uniform Resource Locator

What content does the URL mainly include?

A: URL= Protocol + domain name or IP+ port number + path + query string + anchor point

  • Note: ports do not normally display: HTTP defaults to 80; HTTPS by default, 443

What is IP?

A: Internet Protocol

What is IP for

A: There are two main things:

  1. How do I locate a device
  2. How to disassemble data packets for communication with other devices

IP Indicates the external network and internal network

A:

How to Query IP addresses (why police can catch online scams)

A:

  • Terminal input ipconfig (external address will not be displayed if connected to router)
  • You can query the external IP address of the device from IP138.com

Special IP address:

A:

  • 127.0.0.1 indicates itself
  • Localhost is specified as itself through hosts
  • 0.0.0.0 does not indicate any device

Where can I find hosts

A: In Windows, hosts is located at C:\Windows\System32\drivers\etc\hosts. On macOS/Linux, hosts is located in /etc/hosts

How do I specify myself with hosts

A:

  • Hosts can be edited only with administrator permission
  • Comments starting with # in the hosts file indicate comments
  • You can add a line 127.0.0.1 frank to hosts to make frank an alternate name for 127.0.0.1 (frank can be changed to whatever you want)
  • Type frank:8080/index.html into your browser to open the local index.html

port

A: A machine can provide many services. Each service has a number, which is called the port number

Ports corresponding to different services

A:

  • Port 80 is recommended for the HTTP service
  • Port 443 is recommended for HTTPS services
  • Port 21 is recommended for the FTP service
  • A device has a total of 65535 ports (currently almost sufficient)
  • How do I know what port to use for Wikipedia

Port usage rules

A:

  • Ports 0 to 1023 (210-1) are reserved for the system. (Only administrators can use these ports. Do not use these ports.)
  • The http-server uses port 8080 by default (for example, hs-c-1 -p 1234 can be set to port 1234 instead of the default 8080).
  • If a port is occupied, only another port can be used
  • To sum up: both IP and port are indispensable

The domain name

A: A domain name is an alternate name for IP

How to View domain names

A:

  • Check the IP address of the domain name.
  • Ping + domain name (e.g. Ping baidu.com)
  • One domain name corresponds to different IP addresses – load balancing – in case one machine fails
  • Multiple domain names for one IP – shared host – poor developers practice

How does a Domain Name correspond to an IP address?

A:

  • When you enter a domain name such as Baidu.com, the browser will ask the DNS server provided by China Telecom/Unicom what IP address does Baidu.com correspond to
  • The browser then sends the request to port 80/443 of the corresponding IP address
  • The requested content is baidu’s home page

How to use the nslookup command

A:

Go to Developer Tools >Network to see the whole process

Why port 80 or 443

A:

  • The server defaults to these two ports
  • The default Https port is 443

Classifies domain names by level

A:

  • Com is a top-level domain name
  • Xiedaimala.com is a level 2 domain name.
  • www.xiedaimala.com is a level 3 domain name (commonly known as level 2 domain name)
  • Second – level domain name and third – level domain name are the parent – child relationship
  • So xiedaimala.com and www.xiedaimala.com are not the same domain, so it doesn’t really matter

Who is a man who became a millionaire by selling domain names?

Answer: CAI Wensheng – the father of domain name

How to request different pages (using paths)

A:

  • Developer.mozilla.org/zh-CN/docs/…
  • Developer.mozilla.org/zh-CN/docs/…
  • The Network panel can see that only the last path has changed
  • Paths can have no suffix

How to request different content on the same page (query parameters can be done)

A:

  • www.baidu.com/s?wd=hi
  • www.baidu.com/s?wd=hello
  • /s– refers to Baidu search (single /– refers to the path as the root directory,)
  • ? Wd =xx– query parameters (wd= word)

Different locations of the same content (with anchor points)

A: developer.mozilla.org/zh-CN/docs/…

  • The anchor appears to have Chinese characters, but actually it does not support Chinese characters. As shown above, # is a string of characters after the original reference book
  • Anchor points cannot be seen in the Network panel because they are not passed to the server

Tool: curl command line

  • curl -v baidu.com

  • curl -s -v — www.baidu.com

  1. The url will be rewritten by the curl tool, which will request DNS to obtain the IP address
  2. The TCP connection is established first. After the TCP connection is successful, HTTP requests are sent
  3. Request content + response content
  4. End Close the TCP connection
  5. The end of the