Web Fundamentals
约 477 字大约 2 分钟
Web
2025-09-09
URLs, Domains, and DNS
1. Domain names
A domain name is a human-friendly identifier used on the Internet in place of an IP address such as 192.168.1.1 or 2001:db8::1.
Take www.example.com as an example:
.comis the top-level domain (TLD);exampleis the second-level domain;wwwis a subdomain.
One domain name can map to one or more IP addresses. That mapping is handled by DNS.
2. DNS
DNS (Domain Name System) translates domain names into IP addresses. You can think of it as the Internet's phone book.
When you visit www.baidu.com, the browser roughly goes through this process:
- check whether the IP is already in the local cache;
- if not, ask the local DNS resolver;
- the resolver walks up the hierarchy: root server, TLD server, authoritative server;
- finally, it returns the IP address of the target server.
Only after this step can the browser communicate with the server.
3. URL
A URL (Uniform Resource Locator) tells the browser where and how to access a resource.
For example:
https://www.example.com:443/path/page.html?user=abc#section1This URL contains:
- protocol:
https - host:
www.example.com - port:
443 - path:
/path/page.html - query string:
?user=abc - fragment:
#section1
Protocols and ports
1. HTTP and HTTPS
HTTP is the protocol used for transferring web pages and related resources.
HTTPS is HTTP over TLS/SSL. In practice, it adds encryption, identity verification, and integrity protection.
2. Common ports
Some common default ports:
80: HTTP443: HTTPS22: SSH3306: MySQL5432: PostgreSQL
A port is not a website. It is a communication endpoint on a machine.
From browser input to page rendering
When you type a URL into the browser and press Enter, the process is roughly:
- parse the URL;
- resolve the domain with DNS;
- establish a connection with the server;
- send the HTTP request;
- receive the HTTP response;
- render the HTML and request additional assets such as CSS, JavaScript, and images.
Request and response
An HTTP request usually contains:
- request line, such as
GET /index.html HTTP/1.1 - headers
- optional request body
An HTTP response usually contains:
- status line, such as
HTTP/1.1 200 OK - headers
- response body
Common status codes:
200 OK301/302404 Not Found500 Internal Server Error
TCP and the three-way handshake
Underneath HTTP, the browser usually relies on TCP.
Before data transmission starts, TCP establishes the connection through the classic three-way handshake:
- client sends
SYN - server replies
SYN-ACK - client sends
ACK
Final remarks
These concepts are basic, but they form the foundation of all web development:
- domains make addresses human-readable;
- DNS maps names to IPs;
- URLs describe where a resource is;
- HTTP defines how browsers and servers talk;
- TCP provides the transport layer beneath that communication.
