1.-------------------------------------------------------------------
设置IP地址:
方法1:配置文件写入方法
[root@localhost 3]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
[root@localhost 3]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
DEVICE=eth0
BOOTPROTO=dhcp
HWADDR=00:0C:29:6C:7F:B6
ONBOOT=yes
这样的设置时是自动DHCP获取IP地址
如果想手动设置:
[root@localhost 3]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
DEVICE=eth0
BOOTPROTO=static
HWADDR=00:0C:29:6C:7F:B6
ONBOOT=yes
NETWORK=192.168.5.0
BROADCAST=192.168.5.255
NETMASK=255.255.255.0
IPADDR=192.168.5.110
[root@localhost 3]# service network restart
Shutting down interface eth0: [ OK ]
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth0:
Determining IP information for eth0... done.
[ OK ]
[root@localhost 3]#
查看IP地址:
[root@localhost 3]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:6C:7F:B6
inet addr:192.168.5.110 Bcast:192.168.5.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe6c:7fb6/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:40304 errors:0 dropped:0 overruns:0 frame:0
TX packets:42033 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:8300045 (7.9 MiB) TX bytes:13211424 (12.5 MiB)
Interrupt:59 Base address:0x2000
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:1596 errors:0 dropped:0 overruns:0 frame:0
TX packets:1596 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:3222233 (3.0 MiB) TX bytes:3222233 (3.0 MiB)
[root@localhost 3]#
方法2:启动自动设置IP地址的方法
[root@localhost 3]# echo "ifconfig eth0 192.168.5.110" >> /etc/rc.d/rc.local
这样就可以设置IP地址了
然后局域网可以ping通了应该
想让我们的系统上网还要设置gateway网关和dns