如何在 Linux 中为网络计算机添加网络别名

如何在 Linux 中为网络计算机添加网络别名

在 Windows 中,c:\windows\system32\drivers\etc\hosts 文件允许您为 IP 添加别名,以便您可以用熟悉的名称记住那些计算机。

这是 HOSTS 文件的标题,例如
======================

# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server

=======================

Linux 中的等效机制是什么?(具体来说是 RHEL 6.3)?我需要修改/配置哪个文件才能获取 IP 别名?

答案1

等效于/etc/hosts且格式相同:

$ cat /etc/hosts
## '#' denote comments
## host IP       host alias
102.54.94.97     rhino.acme.com

您可以hosts通过 访问该文件的手册页,阅读有关该文件的信息man hosts

相关内容