如果我有多个主机,我想添加别名,例如
10.0.0.10 ip_10
10.0.0.11 ip_11
10.0.0.12 ip_12
有没有办法将它们组合成一行?
我试过
10.0.0. ip
然后尝试用 ping 它,ping ip.10
但是却失败了ping: unknown host ip.10
。
我也试过10.0.0.* ip.*
答案1
不。格式/etc/hosts
非常简单并且不允许复杂的模式匹配:
This manual page describes the format of the /etc/hosts file. This file is a simple text
file that associates IP addresses with hostnames, one line per IP address. For each host
a single line should be present with the following information:
IP_address canonical_hostname [aliases...]
Fields of the entry are separated by any number of blanks and/or tab characters. Text
from a "#" character until the end of the line is a comment, and is ignored. Host names
may contain only alphanumeric characters, minus signs ("-"), and periods ("."). They must
begin with an alphabetic character and end with an alphanumeric character. Optional
aliases provide for name changes, alternate spellings, shorter hostnames, or generic
hostnames (for example, localhost).
BIND 显然支持类似这样的,如果你想尝试一下。