免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1958 | 回复: 0
打印 上一主题 下一主题

对ifconfig eth0 up对DHCP无效问题的回答 [复制链接]

论坛徽章:
2
IT运维版块每日发帖之星
日期:2015-06-26 22:20:00IT运维版块每日发帖之星
日期:2015-06-29 22:20:00
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-08-30 17:06 |只看该作者 |倒序浏览

                今天我也碰到这个问题:
[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多方面的检查。
               
               
               
               
               

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u3/103607/showart_2041527.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP