HTTP

IP and port numbers make up your network address

A, IP (Internet Protocal)

  • Two main things were agreed:
    1. How do I locate a device
    2. How to encapsulate data packets and communicate with other devices. I don’t care about the content.
  • IP features (Intranet and Extranet) :
    1. As long as you are on the Internet, you have at least one separate IP(in this case, extranet IP).
    2. Generally, the External IP address refers to the IP address outside the router, and the internal IP address refers to the IP address inside the router.
    3. Extranet IP can be understood as your address on the Internet. You can query your Extranet IP at ip138.com.
    4. An Intranet IP address is usually created by a router. An Intranet device uses an Intranet IP address. Routers usually assign themselves an IP address of 192.168.0.1(not always the same). Then the IP address 192.168.1.2 is assigned to other devices on the same Intranet, and so on.

Functions of the router

  • Today’s routers have two IP addresses, an extranet IP and an internal IP
  • Devices on the Intranet can access each other, but cannot directly access the Internet.
  • If an Intranet device wants to access the Internet, it must pass through the router.
  • Devices on the Internet can access each other, but they cannot access your Intranet.
  • Extranet devices that want to deliver content to the Intranet must also go through routers.
  • The Intranet and the extranet are like two isolated Spaces, unable to communicate, the only point of connection is the router.
  • So a router is also called a gateway.
  • If two routers are installed in a home, the two routers are also isolated.

A few special IP’s

  • 127.0.0.1 indicates itself
  • locallhostSpecify as yourself through hosts. Other names can also be specified. Set this parameter after the administrator is assigned.
  • 0.0.0.0 does not indicate any device.

Second, the port

  • A machine can provide many services, each service a number, this number is called the port number
  • Metaphor: McDonald’s provides two Windows, one is selling fried chicken hamburgers, the other is selling desserts. Different types of Windows can only order related types of food, or they will be rejected. Ports are the equivalent of these Windows.
  • Each machine can provide a number of different services:
    1. If the HTTP service is provided, port 80 is recommended
    2. Port 443 is recommended for the HTTPS service
    3. Port 21 is recommended if the FTP service is provided
    4. A total of 65535 ports (almost enough)
  • Click here for a list of ports to see which ones to use.

Port rules

  • Ports 0 through 1023(2 ^ 10 minus 1) are reserved for system use
  • You can only use 1024 ports if you have administrator rights.
  • Other ports can be used by common users.
  • For example, http-server uses port 8080 by default
  • If one port is occupied, you have to switch to another.

To sum up, the bottom line is: you can’t do without both IP and port.

Three, domain name,

  • Domain name is another name for IP
  • throughping xxxxxx.com You can view the IP address corresponding to the url.
  • Knowledge:
    1. One domain name can correspond to different IP addresses (there are too many people accessing one IP address, so one IP address needs to be divided into multiple IP addresses). This is called load balancing to prevent one machine from failing.
    2. One IP can correspond to different domain names. This is called shared hosting, and it’s usually done by poor developers. (Everyone shares a machine)
  • Domain names and IP addresses are mapped by DNS:
    • Process :(take baidu.com as an example)
      1. Your browser will ask the DNS server provided by telecom/Unicom for the IP address of Baidu.com.
      2. Telecom/Unicom will answer with an IP
      3. The browser sends a request to port 80/443 of the IP address.
      4. The requested content is to check the baidu.com homepage
    • Why is the port 80 or 443?
      • By default, the server uses 80 to provide the HTTP service
      • The server uses 443 to provide THE HTTPS service by default
      • You can see the specific ports in the developer tools
  • WWW
    • www.xxxxxx.com and xxxxx.com are not the same domain name
    • The relationship between the two:
      • Com is a top-level domain name
      • Xxxxxx.com is a level-2 domain name.
      • www.xxxxxx.com is a level 3 domain name
      • The two are father and son, and the beginning of WWW is son.
      • For example, github. IO gives you the subdomain xxx.github. IO for free
      • So you should know that www.xxxxxx.com and xxxxxx.com may or may not be the same company.
    • How do I request different pages?
      • You can do this by changing the path:
        • For example: developer.mozilla.org/zh-CN/docs/… And developer.mozilla.org/zh-CN/docs/…
      • You can see the difference using the Chrome Developer Tools Network panel
    • The same page can present different content
      • This is primarily determined by the query parameters
      • For example: www.baidu.com/s?wd=hi and www.baidu.com/s?wd=hello
    • Same content, different location
      • This can be done through the anchor point (#)
      • Note: The anchor points appear to have Chinese, but in fact they do not support Chinese.
      • The corresponding Chinese will become the corresponding string information.
      • Anchors cannot be seen in the Network panel because they are not passed to the server.
  • URL
    • URL consists of protocol + domain name or IP+ port number + path + query string + anchor point

    Part of the content comes from:xiedaimala.com