centos6.5设置静态IP

前端之家收集整理的这篇文章主要介绍了centos6.5设置静态IP前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

静态IP设置

ifconfig 查看当前IP

[root@localhost ~]# ifconfig eth0 Link encap:Ethernet HWaddr 00:0C:29:D9:F0:52 inet addr:10.72.137.85 Bcast:10.72.137.255 Mask:255.255.255.0 inet6 addr: fe80::20c:29ff:fed9:f052/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:27135 errors:0 dropped:0 overruns:0 frame:0 TX packets:53 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:3488498 (3.3 MiB) TX bytes:7550 (7.3 KiB) Interrupt:18 Base address:0x1080 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)

route 查看当前网关,子网掩码

[root@lijian-centos6 ~]# route

Kernel IP routing table

Destination Gateway Genmask Flags Metric Ref Use Iface

192.168.63.0 * 255.255.255.0 U 0 0 0 eth0

link-local * 255.255.0.0 U 1002 0 0 eth0

default 192.168.63.2 0.0.0.0 UG 0 0 0 eth0

dhclient 自动获取IP

dhclient命令使用动态主机配置协议动态的配置网络接口的网络参数。

修改配置文件

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

添加语句

IPADDR=10.72.137.85

NETMASK=255.255.255.0

GATEWAY=10.72.137.1

修改

ONBOOT=no yes

BOOTPROTO=dhcp static

esc :wq 保存并退出

service network restart 重启network服务

ping www.baidu.com 测试网络

设置DNS地址

运行命令 vi /etc/resolv.conf 内容如下:

nameserver 192.168.205.2

猜你在找的CentOS相关文章