今天我也碰到这个问题:
[root@localhost ~]# ifconfig eth1 down
[root@localhost ~]#
[root@localhost ~]# ifconfig eth1
eth1 Link encap:Ethernet HWaddr 00:E0:4C:B2:20:60
inet addr:192.168.1.101 Bcast:192.168.1.255 Mask:255.255.255.0
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:1969 errors:0 dropped:0 overruns:0 frame:0
TX packets:2187 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1407415 (1.3 MiB) TX bytes:416898 (407.1 KiB)
Interrupt:177 Base address:0x4000
使用 ifconfig eth1 down 后为什么不能把接口给down掉?
而使用ifup和ifdown却没问题
[root@localhost ~]# ifdown eth1
[root@localhost ~]# ifconfig eth1
eth1 Link encap:Ethernet HWaddr 00:E0:4C:B2:20:60
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:1969 errors:0 dropped:0 overruns:0 frame:0
TX packets:2187 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1407415 (1.3 MiB) TX bytes:416898 (407.1 KiB)
Interrupt:177 Base address:0x4000
[root@localhost ~]# ifup eth1
正在决定 eth1 的 IP 信息...完成。
[root@localhost ~]#
网上很多人说ifconfig eth1 up 和 ifup的作用一样,这话是错误的。很显然他们不一样。
找了很多,最后发现原因是:
ifconfig 是一个命令,来控制网卡是否启用
ifup 是一个脚本,它会根据网络接口配置来判断是使用 ifconfig 读取配置文件配置网络 IP,还是调用 dhcp 客户端去从服务器获取 IP
ifup会作更多的检测,请看:
#!/bin/bash
# Network Interface Configuration System
# Copyright (c) 1996-2001 Red Hat, Inc. all rights reserved.
#
# This software may be freely redistributed under the terms of the GNU
# public license.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
unset WINDOW # defined by screen, conflicts with our usage
. /etc/init.d/functions
cd /etc/sysconfig/network-scripts
. ./network-functions
[ -f ../network ] && . ../network
CONFIG=${1}
[ -z "${CONFIG}" ] && {
echo $"Usage: ifup " >&2
exit 1
}
这是ifup脚本的一部分,其中.network-functions就涉及到N多方面的检查。
阅读(10551) | 评论(0) | 转发(0) |