1.查看ip地址
ifconfig(已经过时)
ip addr show
2.指定ip地址
vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
HWADDR=00:0C:29:8E:0B:00
TYPE=Ethernet
UUID=f23f083d-89af-4951-a33d-496d4534beb1
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
IPADDR=192.168.111.111 #ip
NETMASK=255.255.255.0 #子网掩码
GATEWAY=192.168.111.2 #网关
3.配置DNS解析
vim /etc/resolv.conf
options timeout:2 attempts:3 rotate single-request-reopen
; generated by /usr/sbin/dhclient-script
nameserver 100.100.2.138 #DNS地址
nameserver 100.100.2.136 #DNS地址
search localdomain
4.设置主机名称
vi /etc/sysconfig/network
设置:
HOSTNAME=主机名
5.设置域名映射
vi /ect/hosts
添加域名映射
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
6.重启服务
service network restart
7.测试网络
ping ip地址
如
ping www.baidu.com