centos修改网卡ip地址

操作系统CentOs_5_5_64_server

修改网卡

1.修改network配置

写道
[root@test-db-100 ~]# vim /etc/sysconfig/network

  

写道
//vim 编辑 修改HOSTNAME,添加GATEWAY
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=test-db-100
GATEWAY=192.168.2.1

 :wq 写入退出

2.修改默认的网卡eth0

写道
[root@test-db-100 ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
写道
#BOOTPROTO如何指派IP(dhcp由路由器动态的分配IP,static手动设置静态的IP) ;添加#IPADDR,NETMASK,NETWORK,BROADCAST
DEVICE=eth0
BOOTPROTO=static
ONBOOT=yes
HWADDR=00:9a:34:e5:22:c5
IPADDR=192.168.2.100
NETMASK=255.255.255.0
NETWORK=192.168.2.0
BROADCAST=192.168.2.255

 :wq 写入退出

3.重启网卡服务

  重启服务之后,才能使更改的配置生效

写道
[root@test-db-100 ~]# service network restart

 4.检查配置好的网卡

写道
[root@test-db-100 ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:9A:34:E5:22:C5
       inet addr:192.168.2.100 Bcast:192.168.2.255 Mask:255.255.255.0
       inet6 addr: ef80::16c:18af:fcb1:29b1/64 Scope:Link
       UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
       RX packets:600207 errors:0 dropped:0 overruns:0 frame:0
       TX packets:78529 errors:0 dropped:0 overruns:0 carrier:0
       collisions:0 txqueuelen:1000
       RX bytes:157243339 (149.9 MiB) TX bytes:6477664 (6.1 MiB)

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:83 errors:0 dropped:0 overruns:0 frame:0 
       TX packets:83 errors:0 dropped:0 overruns:0 carrier:0 
       collisions:0 txqueuelen:0 
       RX bytes:13419 (13.1 KiB) TX bytes:13419 (13.1 KiB)

 OK ,完成~

其他:

【如遇到错误chomd: command not found】解决办法

修改/etc/profile文件,注释掉if语句即可
把下面的if语句注释掉:
# Path manipulation
if [ "$EUID" = "0" ]; then
pathmunge /sbin
pathmunge /usr/sbin
pathmunge /usr/local/sbin
fi
修改为
# Path manipulation
# if [ "$EUID" = "0" ]; then
pathmunge /sbin
pathmunge /usr/sbin
pathmunge /usr/local/sbin
#fi

猜你喜欢

转载自wxb-j2ee.iteye.com/blog/809737