日期:2014-05-16 浏览次数:20910 次
ifconfig命令用来配置网络接口。
1. ifconfig默认会显示已经active的网络接口,
sh-# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:E7:06:00:00
UP BROADCAST MULTICAST MTU:1500 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:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Interrupt:40 Base address:0x2000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:1244 errors:0 dropped:0 overruns:0 frame:0
TX packets:1244 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:94792 (92.5 Kb) TX bytes:94792 (92.5 Kb)
sh-#
2. ifconfig也可以查看指定网卡的信息,
sh-# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:0C:E7:06:00:00
UP BROADCAST MULTICAST MTU:1500 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:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Interrupt:40 Base address:0x2000
sh-#
3. 使用ifconfig命令修改IP地址,
sh-# ifconfig eth0 192.168.0.111 netmask 255.255.255.0
sh-#
sh-# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:0C:E7:06:00:00
inet addr:192.168.0.111 Bcast:192.168.0.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:92 errors:0 dropped:59 overruns:0 frame:0
TX packets:42 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:11155 (10.8 Kb) TX bytes:5318 (5.1 Kb)
Interrupt:40 Base address:0x2000
sh-#
sh-# ifconfig eth0:0 192.168.0.112 netmask 255.255.255.0
sh-#
4. 使用ifconfig配置一块新的网卡eth0:0,但是发现配置之后ping不通了,
sh-#
sh-# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:E7:06:00:00
inet addr:192.168.0.111 Bcast:192.168.0.255 Mask:255.255.255.0