红联Linux门户
Linux帮助

Linux设置IP、DNS、Hostname方法

发布时间:2015-02-08 10:41:27来源:linux网站作者:puwenhui

设置Hostname:
修改/etc/hostname文件
127.0.0.1  localhost.localdomain   localhost
192.168.1.100  CentOS

#hostname ha01  #设置

#uname -n  #查看


设置网关:
修改/etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=ha01

GATEWAY=10.95.136.1


设置IP:

#ifconfig eth0 192.168.1.100 netmask 255.255.255.0 up


修改/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=static
IPADDR=192.168.1.100

NETMASK=255.255.255.0
BROADCAST=255.255.255.255
HWADDR=00:0C:29:A9:70:C3
TYPE=Ethernet
ONBOOT=yes
NETWORK=192.168.1.2

#service network restart #设置生效


设置DNS:
修改/etc/resolv.conf
nameserver   202.103.24.68

#service network restart  #设置生效