简体   繁体   中英

How to make an alias for localhost that has a tld?

I was wondering how I would make an alias for localhost that has a tld. For example, foo.test wold connect to 127.0.0.1. I tried just adding a second line to /etc/hosts that also pointed to 127.0.0.1, but that didn't seem to work. Although, I didn't reboot, so that might be why.

The end goal is to have it so that I can test that a request is being sent to a specific subdomain in the Rocket framework for Rust. IE: foo.bar.test instead of baz.bar.test or just bar.test.

The man page for /etc/hosts says:

IP CANONICAL ALIAS ...
127.0.0.1 foo.test localhost

Should be good

But is the host really handling traffic from this IP address ?

Alternatively, the interface specific line can include the aliases

10.0.0.1 foo.bar.test foo
10.0.0.2 baz.bar.test baz

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM