DarkMatter in Cyberspace
  • Home
  • Categories
  • Tags
  • Archives

Linux中网络相关的配置文件


/etc/hosts

10.31.1.71 servername1
10.31.1.52 servername2

当本机连接servername1时,通过这个文件将主机名映射为ip地址,相当于本机本部的DNS服务,对该文件的详细说明见Richard Petersen "Linux: The Complete Reference" p723: Identifying Hostnames: /etc/hosts。

/etc/sysconfig/network

用于定义主机的整体网络配置。

# /etc/sysconfig/network-scripts/ifcfg-eth0

专门定义eth0的属性,如果有多个网卡, network-scripts下可能还有ifcfg-eth1,ifcfg-eth2等几个文件。

设置网卡eth0的IP地址

ifconfig <eth0> 10.31.1.251 netmask 255.255.255.0 up

其中eth0是网卡名称,要根据ifconfig中列出的具体的网卡名字确定。

修改主机名

hostname newHostname

查询当前主机名:hostname

参见What is the difference between these two network configuration files?



Published

Sep 28, 2012

Last Updated

Sep 28, 2012

Category

Tech

Tags

  • CentOS 25
  • linux 158
  • 网络 4

Contact

  • Powered by Pelican. Theme: Elegant by Talha Mansoor