灯火互联
管理员
管理员
  • 注册日期2011-07-27
  • 发帖数41778
  • QQ
  • 火币41290枚
  • 粉丝1086
  • 关注100
  • 终身成就奖
  • 最爱沙发
  • 忠实会员
  • 灌水天才奖
  • 贴图大师奖
  • 原创先锋奖
  • 特殊贡献奖
  • 宣传大使奖
  • 优秀斑竹奖
  • 社区明星
阅读:1910回复:0

一次痛苦的Linux网关重启经历

楼主#
更多 发布于:2012-01-18 13:47
环境:
 两台网关gw1 / gw2
 [root@gw1 coolwinds]# uname -a
 Linux gw1.xkit.net 2.6.5-1.358smp #1 SMP Sat May 8 09:25:36 EDT 2004
 i686 i686 i386 GNU/Linux
  
 |-----eth0:ADSL拨号FIX_IP:web_IP
 |
 |---eth1:1 192.0.1.1/24
 | |
 | |
 GW1----eth1:192.168.0.3/24 LanIP划分为---- |----eth1:2 10.18.144.1/24
 | |
 | |
 |-----eth2:192.168.1.2/24 ADSL拨号2 |----eth1:3 10.18.146.11/24
 |
 |-----eth3:192.168.100.3/24 ADSL拨号3
  
 GW2 一条ADSL 主要用于公司连接到香港的VPN (此次不作说明了)
  
 当星期天晚来电后重新启动GW1服务器时,发现如下错误:
 device eth0 ..........................................................OK
 device eth1 ..........................................................OK
 device eth2 ..........................................................OK
 8139too device eth3 does not seem to be present, delaying initialization.
  
 eth3启动不了了,根据已往经验,有可能eth3网卡驱动模块损坏. 但我通过startx 进入GUI
 界面查看了GW1上面的四块网卡,其中三块为8139芯片的,也就排除了网卡驱动模块损坏的原因,同时也排除了该网卡模块没有加载的可能,否则其他两块网卡也不可能正常UP.
 于是我在GUI 界面下简单的删除了该网卡,然后重新启动了机器,结果就此一步导致了严重的后果. 机器重新启动过程中出现了类似:(事后整理的)
 8139too device eth0 does not seem to be present, delaying initialization.
 8139too device eth1 does not seem to be present, delaying initialization.
 8139too device eth2 does not seem to be present, delaying initialization.
 8139too device eth3 does not seem to be present, delaying initialization.
 Jun 27 06:33:26 gw1 kernel: 8139too: Unknown parameter `irq'
 Jun 27 06:33:26 gw1 kernel: 8139too: Unknown parameter `irq'
 Jun 27 06:50:44 gw1 kernel: 8139too: Unknown parameter `irq'
 Jun 27 06:50:44 gw1 kernel: via-rhine: Unknown parameter `irq'
 此时四块网卡全部OVER !!!
  
 此时通过GW2上google,终于在
 
https://listman.redhat.com/archives/k12osn/2003-October/msg00564.html上找到如下两段解决方法:
  
 > Just guessing, but poke around in the bios setup to see if it
 > had a setting for 'PNP OS' and set it to 'no' if there is. Also
 > make sure the motherboard NIC is enabled.
  
 [root@gw1 coolwinds]lspci -n //依此了修改网卡IRQ中段
  
 仔细按照上面方法检查了系统,没有问题.此时想到可能是网卡模块没有加载?
 [root@gw1 coolwinds]lsmod //查找相应模块
  
 mii 7552 2 8139too,via_rhine //已经加载
  
 [root@gw1 coolwinds]rmmod 8139too
 [root@gw1 coolwinds]rmmod via_rhine
 [root@gw1 coolwinds]insmod 8139too
 Jun 27 07:26:37 gw1 modprobe: FATAL: Error inserting 8139too
 (/lib/modules/2.6.5-1.358/kernel/drivers/net/8139too.ko): Unknown
 symbol in module, or unknown parameter (see dmesg)
 [root@gw1 coolwinds]insmod via_rhine
 Jun 27 07:26:37 gw1 modprobe: FATAL: Error inserting via_rhine
 (/lib/modules/2.6.5-1.358/kernel/drivers/net/via_rhine.ko): Unknown
 symbol in module, or unknown parameter (see dmesg)
  
 [root@gw1 coolwinds]dmesg |tail -n 100
  
 显示类似下面东东
  
 via-rhine.c:v1.10-LK1.1.19-2.5 July-12-2003 Written by Donald Becker
 
http://www.scyld.com/network/via-rhine.html
divert: allocating divert_blk for eth0
 eth0: VIA VT6102 Rhine-II at 0xfe5ff400, 00:50:ba:2c:c6:0a, IRQ 217.
 eth0: MII PHY found at address 8, status 0x782d advertising 01e1 Link 45e1.
 eth0: Setting full-duplex based on MII #8 link partner capability of 45e1.
 8139too Fast Ethernet driver 0.9.27
 divert: allocating divert_blk for eth1
 eth1: RealTek RTL8139 at 0xd800, 00:e0:4c:77:27:e5, IRQ 177
 eth1: Identified 8139 chip type 'RTL-8100B/8139D'
 divert: allocating divert_blk for eth2
 eth2: RealTek RTL8139 at 0xd400, 00:0a:eb:83:59:e4, IRQ 209
 eth2: Identified 8139 chip type 'RTL-8100B/8139D'
 divert: allocating divert_blk for eth3
 eth3: RealTek RTL8139 at 0xde00, 00:11:2f:c1:eb:5d, IRQ 201
  
 从以上内容可以看出 每块网卡对应的芯片型号
 eth0: VIA VT6102 Rhine-II
 eth1: RealTek RTL8139
 eth2: RealTek RTL8139
 eth3: RealTek RTL8139
 修改/etc/modporbe.conf如下:
 ################################################################################################
 install snd-intel8x0 /sbin/modprobe --ignore-install snd-intel8x0 ;;
 /usr/sbin/alsactl restore >/dev/null 2>;1 ||:
 remove snd-intel8x0 {/usr/sbin/alsactl store >/dev/null 2>;1 ||:;};
 /sbin/modprobe -r --ignore-remove snd-intel8x0
 alias usb-controller ehci-hcd
 alias usb-controller1 uhci-hcd
 #options loop max_loop=128
 #options 8139too
 #options via-rhine
 #options rtl8129
 alias eth0 via-rhine
 alias eth1 8139too
 alias eth2 8139too
 alias eth3 8139too
 ################################################################################################
  
 重新
 [root@gw1 coolwinds]insmod 8139too //OK ! PASS !
 [root@gw1 coolwinds]insmod via-rhine //OK ! PASS !
 [root@gw1 coolwinds]service network restart
 设置网络参数:[ 确定]
 弹出环回接口:[ 确定]
 弹出界面eth0:[ 确定]
 弹出界面eth1:[ 确定]
 弹出界面eth2:[ 确定]
 弹出界面eth3:[ 确定]
 [root@gw1 coolwinds]ifconfig -a //网卡地址全部UPlink
 !但发现所有网卡只发包不收包,断定对端网线接入地址肯定有误(所有网线,网卡都打过标签,理论上不可能有误!!)将四条网线全部拔掉,在没个网卡上ping对端网关地址,然后一条条试着接上网线,果然原先的网卡顺序完全混乱了,重新打标.
 启动iptables
 [root@gw1 coolwinds]service iptables restart
 设置路由策略:
 [root@gw1 coolwinds]./gw1_iproute.sh
  
 至此,所有网络完全导通!!
 附上路由策略scripts:
 ==============================gw1_iproute.sh=================================
 #!/bin/bash
 # set route on gw1 Create by
Xcoolwinds@hotmail.com 2005-06-15
 # /etc/iproute2/rt_tables
 # 100 dialup
 # 101 dialup2
  
 #############################################table
 main#####################################################
 ip route del internet_GW/25 dev eth0 proto kernel scope link src WEB_IP
 ip route del 192.168.100.0/24 dev eth3 proto kernel scope link src
 192.168.100.3
 ip route del 192.168.1.0/24 dev eth2 proto kernel scope link src 192.168.1.2
 ip route del 192.168.0.0/24 dev eth1 proto kernel scope link src 192.168.0.3
 ip route del 192.0.1.0/24 dev eth1 proto kernel scope link src 192.0.1.1
 ip route del 10.18.144.0/22 dev eth1 proto kernel scope link src 10.18.144.1
 ip route del 169.254.0.0/16 dev eth3
 ip route del default via TELECOM_GW dev eth0
  
 ip rule del from 192.168.0.3/29 table main
 ip rule del from 192.168.0.253 table main
 ip rule del from fwmark 0x2 table main
  
 #############################################table
 dialup#####################################################
 ip route del 192.168.100.0/24 dev eth3 table dialup
 ip route del 192.168.1.0/24 dev eth2 table dialup
 ip route del 192.168.0.0/24 dev eth1 table dialup
 ip route del 192.0.1.0/24 dev eth1 table dialup
 ip route del 10.18.144.0/22 dev eth1 table dialup
 ip route del default via 192.168.1.1 dev eth2 table dialup
  
 ip rule del from 192.168.0.0/24 table dialup
 ip rule del from 192.168.1.0/24 table dialup
 ip rule del to 192.138.151.104 table dialup
 ip rule del fwmark 0x1 table dialup
  
 ip rule del pref 15000 table dialup iif eth2
  
 #############################################table
 dialup2#########################################
 ip route del 192.168.100.0/24 dev eth3 table dialup2
 ip route del 192.168.1.0/24 dev eth2 table dialup2
 ip route del 192.168.0.0/24 dev eth1 table dialup2
 ip route del 192.0.1.0/24 dev eth1 table dialup2
 ip route del 10.18.144.0/22 dev eth1 table dialup2
 ip route del default via 192.168.100.2 dev eth3 table dialup2
  
 ip rule del from 192.168.0.0/24 table dialup2
 ip rule del from 192.168.100.0/24 table dialup2
 ip rule del from 192.0.1.0/24 table dialup2
 ip rule del from 10.18.144.0/22 table dialup2
  
 ip rule del to 65.54.239.141 table dialup2
 ip rule del to 207.68.171.245 table dialup2
 ip rule del to 207.46.5.1 table dialup2
 ip rule del to 65.54.239.20 table dialup2
 ip rule del to 130.239.18.151 table dialup2
 ip rule del to 202.64.33.137 table dialup2
 ip rule del to 202.14.67.92 table dialup2
 ip rule del to 207.46.248.16 table dialup2
  
 ip rule del pref 15001 table dialup2 iif eth3
  
 #############################################table
 main#####################################################
 ip route add Internet_GW/25 dev eth0 proto kernel scope link src WEB_IP
 ip route add 192.168.100.0/24 dev eth3 proto kernel scope link src
 192.168.100.3
 ip route add 192.168.1.0/24 dev eth2 proto kernel scope link src 192.168.1.2
 ip route add 192.168.0.0/24 dev eth1 proto kernel scope link src 192.168.0.3
 ip route add 192.0.1.0/24 dev eth1 proto kernel scope link src 192.0.1.1
 ip route add 10.18.144.0/22 dev eth1 proto kernel scope link src 10.18.144.1
 ip route add default via TELECOM_GW dev eth0
  
 ip rule add from 192.168.0.3/29 table main
 ip rule add from 192.168.0.253 table main
 ip rule add from fwmark 0x2 table main
  
 #############################################table
 dialup#####################################################
 ip route add 192.168.100.0/24 dev eth3 table dialup
 ip route add 192.168.1.0/24 dev eth2 table dialup
 ip route add 192.168.0.0/24 dev eth1 table dialup
 ip route add 192.0.1.0/24 dev eth1 table dialup
 ip route add 10.18.144.0/22 dev eth1 table dialup
 ip route add default via 192.168.1.1 dev eth2 table dialup
  
 ip rule add from 192.168.0.0/24 table dialup
 ip rule add from 192.168.1.0/24 table dialup
 ip rule add to 192.138.151.104 table dialup
 ip rule add fwmark 0x1 table dialup
  
 ip rule add pref 15000 table dialup iif eth2
  
 #############################################table
 dialup2#########################################
 ip route add 192.168.100.0/24 dev eth3 table dialup2
 ip route add 192.168.1.0/24 dev eth2 table dialup2
 ip route add 192.168.0.0/24 dev eth1 table dialup2
 ip route add 192.0.1.0/24 dev eth1 table dialup2
 ip route add 10.18.144.0/22 dev eth1 table dialup2
 ip route add default via 192.168.100.2 dev eth3 table dialup2
  
 ip rule add from 192.168.0.0/24 table dialup2
 ip rule add from 192.168.100.0/24 table dialup2
 ip rule add from 192.0.1.0/24 table dialup2
 ip rule add from 10.18.144.0/22 table dialup2
  
 ip rule add to 64.233.189.104 table dialup2
 ip rule add to 207.46.110.35 table dialup2
 ip rule add to 207.46.110.249 table dialup2
 ip rule add to 65.54.239.80 table dialup2
 ip rule add to 130.239.18.151 table dialup2
 ip rule add to 202.64.33.137 table dialup2
 ip rule add to 202.14.67.92 table dialup2
 ip rule add to 207.46.248.16 table dialup2
  
 ip rule add pref 15001 table dialup2 iif eth3
  
 ip route flush cache
  
 ================================================================================================
 总结:强烈建议不要通过GUI 来更改网络配置,特别是比较复杂的linux 网络环境. 修改网络配置之前最好先备份
 /etc/sysconfig/network-scripts/* 文件.此次linux
 网卡混乱是由于删除了其中的一块网卡最终导致,不过后来查明,linux
 多网卡容易启动混乱本身就是一个BUG.希望此文能给以后碰到类似问题的XDJM
 一定帮助!!当然欢迎交流讨论linux下其他方面(路由策略,iptables,IDS...)

喜欢0 评分0
游客

返回顶部