why? why? Why enter in a browser www.baidu.com
to access Baidu search, and enter pan.baidu.com
to access Baidu network disk, it is how to achieve?
Principle Introduction
In Internet
passing between the computer ip
access address. When we PC
connect to the Internet, the upstream DHCP
server will give PC
an ip
address, it will also tell DNS
the server ip
address when accessing www.baidu.com
the time, PC
will www.baidu.com
send the URL to the DNS
server, then DNS
the server will query it to the web
server ip
returns the address to PC
the last by accessing the ip
access to the address web
server to obtain the site content.
Introduction experiment
By using VMware Workstation
simulated environment above, build three servers, respectively DHCP
, DNS
, Web
server, system Windows Server 2016
, and then use a Win10
client to verify results.
He began to experiment
Virtual Machine Information
It is set to all network host only mode and closed
DHCP
.
Setting the host name and IP address
DHCP-SERVER
:192.168.100.11DNS-SERVER
:192.168.100.12WEB-SERVER
:192.168.100.13WIN-CLIENT
: Automatically obtain ip address
Service Configuration
First add roles and features required within Server Manager, and then open the corresponding service manager perform service configuration.
Web server configuration
- Server Manager → Management → Add Roles and Features → installation
Web
service
- Create a site required documents
C:\Users\Administrator>cd ..\..
C:\>mkdir web\baidu\search web\baidu\pan
C:\>echo "<h1>This is baidu search !</h1>" > web\baidu\search\index.html
C:\>echo "<h1>This is baidu pan !</h1>" > web\baidu\pan\index.html
- Start →
Windows
Administrative Tools →IIS 管理器
→ Add Website
- Add site information
Web
Service configuration
Configuring DNS server
- Server Manager → Management → Add Roles and Features → installation
DNS
service
- Start →
Windows
Administrative Tools →DNS 管理器
→ New forward lookup zone
- New Zone Wizard
- In the region New Host
- New host record completion
DNS
Service configuration
DHCP server configuration
- Server Manager → Management → Add Roles and Features → installation
DHCP
service
- Start →
Windows
Administrative Tools →DHCP
→ NewIPv4
Scope
- New Scope Wizard
DHCP
Service configuration
Results show
Open WIN-CLIENT
Client to automatically obtain ip
the address, and then visit the site.
- Automatically get
ip
address
- View all
ip
information
ipconfig /renew #重新获取ip地址
ipcomfig /all #查看所有ip信息
- Access results
www.baidu.com
- Access results
pan.baidu.com
Implementation uses a different host name to access different websites.
some thoughts
This is based on Windows Server
, and later perhaps even write a Linux
version.