(1) 修改主机名
临时方法:
hostname newname
退出当前shell重新登录即可生效;
注意:此法只能临时修改生效,重起系统后失效!
永久方法:
vi /etc/sysconfig/network
修改hostname newname后
hostname newname
重新登录即可生效!
(2) DNS配置
vi /etc/hosts
编辑主机节点和ip地址对应关系
x.x.x.x www.domain.com
vi /etc/resolv.conf
nameserver x.x.x.x
/x.x.x.x为DNS SERVER IP
(3) 配置网关
方法1)vi /etc/sysconfig/network
GATEWAY=X.X.X.X
方法2)vi/etc/sysconfig/network-scripts/ifcfg-ethX
GATEWAY=X.X.X.X
此2种方法重启网络服务才可生效!
即/etc/init.d/network restart or service network restart
其中:
/etc/sysconfig/network-scripts/ifcfg-eth0中的网关配置优先于/etc/sysconfig/network中的配置
(4) 查看ip及修改路由
ifconfig /查看所有接口ip
ifconfig ethx /查看具体某个接口ip
route -n /查看路由
netstat -rn
route add default gw x.x.x.x /添加默认网关
route del default gw x.x.x.x /删除默认网关
route add -host x.x.x.x dev ethx /添加主机路由
route add -net x.x.x.x netmask 255.255.x.x dev ethx /基于接口添加网段路由
Route add -net x.x.x.x netmask 255.255.x.x gw x.x.x.x /基于网关添加网段路由
本文出自 “Bruce_tan” 博客,请务必保留此出处http://380281.blog.51cto.com/370281/1752150
原文:http://380281.blog.51cto.com/370281/1752150