Можно ли создать правило для хостов etc (Правило: 10.0.0. * Ip. Использование: ping ip. 10)?

Если у меня есть несколько хостов, для которых я хочу добавить псевдонимы, например,

10.0.0.10 ip_10
10.0.0.11 ip_11
10.0.0.12 ip_12

Есть ли способ объединить их в одну строку?

Я попытался

10.0.0. ip

и затем попытался пропинговать его с помощью ping ip.10 , но это дало ping: неизвестный хост ip.10 .

Я также попытался 10.0.0. * ip. *

0
задан 15 July 2020 в 10:00

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, очевидно, поддерживает что-то вроде этого , на случай, если вы захотите попробовать это.

2
ответ дан 30 July 2020 в 22:07

Другие вопросы по тегам:

Похожие вопросы: