CN104407899A - Method for restoring boot of network card after MAC (Media Access Control) address change under REDHAT operation system - Google Patents

Method for restoring boot of network card after MAC (Media Access Control) address change under REDHAT operation system Download PDF

Info

Publication number
CN104407899A
CN104407899A CN201410725087.9A CN201410725087A CN104407899A CN 104407899 A CN104407899 A CN 104407899A CN 201410725087 A CN201410725087 A CN 201410725087A CN 104407899 A CN104407899 A CN 104407899A
Authority
CN
China
Prior art keywords
network interface
interface card
mac address
file
operating system
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201410725087.9A
Other languages
Chinese (zh)
Inventor
张儒强
任华进
赵贺
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Inspur Electronic Information Industry Co Ltd
Original Assignee
Inspur Electronic Information Industry Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Inspur Electronic Information Industry Co Ltd filed Critical Inspur Electronic Information Industry Co Ltd
Priority to CN201410725087.9A priority Critical patent/CN104407899A/en
Publication of CN104407899A publication Critical patent/CN104407899A/en
Pending legal-status Critical Current

Links

Abstract

The invention discloses a method for restoring boot of a network card after MAC (Media Access Control) address change under a REDHAT operation system. Under the redhat operation system, statements required for restoring boot of the network card are integrated in an executable script, wherein the operations of configuration file modification, temporary file clearing and system restart are included. According to the method, a fasted solution is provided; after the script is edited, the network card can be booted successfully with only one command to finish failure recovery at one time.

Description

After changing MAC Address under a kind of REDHAT operating system, network interface card recovers the method started
Technical field
The present invention relates to field of computer technology, be specifically related to a kind of method changing rear network interface card recovery startup for MAC Address of Network Card under REDHAT operating system.
Background technology
In actual application environment, when the fault such as the machine of delaying, deadlock appears in Linux system server, often need to change server master board and solve problem, or when there is network failure, the extrapolation network interface card of correspondence changed by needs.But replacing mainboard completes, network interface card, after starting the operating system, can find that network interface card service starts unsuccessfully, network is obstructed, so business can not continue, just can not successfully repair a fault at last.This just needs to expend the configuration file that the long period revises network interface card at the scene, for the slip-stick artist being unfamiliar with linux statement, extremely difficult especially.So we will provide solution the most fast, after compile script, only need an order, successfully can start network interface card, complete primary fault and recover.
Linux system can go to read network interface card information after loading trawl performance, then all network card equipments recognized are write this file :/etc/udev/rules.d/70-persistent-net.rules, and do not delete former content, so wherein contain existing content and newly recognize the mac address of network interface card.Such as, change the mainboard of a double netcard in maintenance server process, the mac address of network interface card changes thereupon, 4 network interface card information of new and old two pieces of mainboards will be comprised in this file, what still preserve in another configuration file ifcfg-ethx is original MAC Address simultaneously, so when system starts, due to mac address error, identification network card equipment that can not be correct, causes and starts network interface card failure.
Summary of the invention
The technical problem to be solved in the present invention is: the object of this invention is to provide a kind of under redhat operating system, and after network interface card mac address changes, network interface card recovers the method started
The technical solution adopted in the present invention is:
After changing MAC Address under a kind of REDHAT operating system, network interface card recovers the method started, under redhat operating system, can perform in script by the statement required for instauration net card start-up is integrated in one, wherein contain amendment configuration file, empty temporary file, restart the operations such as system.The time of fault recovery significantly can be reduced by this method.
In order to avoid server network interface card quantity differs, improve the accuracy judged, first need to judge network interface card quantity, coupling corresponding relation that could be correct.
In addition, if the extrapolation net card failure of a station server, only changed an extrapolation network interface card, so still all network interface card files have been modified after having judged, so the present invention is not by the restriction of fault network interface card quantity.
Described shell script mainly revises two files:
Ifcfg-eth [0-9]: [0-9] is general reference.MAC Address in these network card configuration files all will be revised as the MAC of current machine card of surfing Internet.
70-persistent-net.rules is the file that system generates automatically, the network interface card detected when comprising startup, determines network interface card order, can directly empty.
First check startup file/etc/sysconfig/network-scripts/ifup, comparison has been done to the MAC Address in configuration file.Comparison result is inconsistent, then start failure
Described method operation steps is as follows:
1) draw by num=$ (ifconfig-a | grep eth | wc-l) statement the network interface card number that system recognizes, decide to revise corresponding ifcfg-ethx file;
2) current all correct network interface card information is listed by ifconfig – a, and by key word " HWaddr " value MAC Address;
3) first judge whether the configuration file of this network interface card exists, then step 2 by if condition before amendment) in recognize MAC Address and write this file for standby, and add # annotation;
4) draw corresponding relation according to network interface card quantity before, the ifcfg-ethx file that amendment is corresponding, write correct MAC Address;
5) empty 70-persistent-net.rules file, and restart.Just can see network interface card full recovery startup.
Write rear increase and can perform authority: chmod 755 mac.sh;
Perform script: ./mac.sh;
Ifconfig test after wait autoboot completes.
Beneficial effect of the present invention: the invention provides solution the most fast, after compile script, only needs an order, successfully can start network interface card, completes primary fault and recovers.
Accompanying drawing explanation
Fig. 1 is script process flow diagram of the present invention.
Embodiment
Below according to Figure of description, in conjunction with specific embodiments, the present invention is further described:
As shown in Figure 1, after changing MAC Address under a kind of REDHAT operating system, network interface card recovers the method started, under redhat operating system, can perform in script by the statement required for instauration net card start-up is integrated in one, wherein contain amendment configuration file, empty temporary file, restart the operations such as system.The time of fault recovery significantly can be reduced by this method.
In order to avoid server network interface card quantity differs, improve the accuracy judged, first need to judge network interface card quantity, coupling corresponding relation that could be correct.
In addition, if the extrapolation net card failure of a station server, only changed an extrapolation network interface card, so still all network interface card files have been modified after having judged, so the present invention is not by the restriction of fault network interface card quantity.
Described shell script mainly revises two files:
Ifcfg-eth [0-9]: [0-9] is general reference.MAC Address in these network card configuration files all will be revised as the MAC of current machine card of surfing Internet.
70-persistent-net.rules is the file that system generates automatically, the network interface card detected when comprising startup, determines network interface card order, can directly empty.
First check startup file/etc/sysconfig/network-scripts/ifup, comparison has been done to the MAC Address in configuration file.Comparison result is inconsistent, then start failure.
The content of described script, such as script name is: mac.sh
#!/bin/bash
cdate=$(date '+%Y%m%d')
num=$(ifconfig -a | grep eth | wc -l)
for ((n=0;n<${num};n++))
do
j=$((n+1))
if [ -e /etc/sysconfig/network-scripts/ifcfg-eth${n} ] ; then
[ -e ifcfg-eth${n}_${cdate} ] || cp -fa /etc/sysconfig/network-scripts/ifcfg-eth${n} ./ifcfg-eth${n}_${cdate}
cat ifcfg-eth${n}_${cdate} | sed '/^#eth.*$/d' > ifcfg-eth${n}_temp
ifconfig -a | grep "HWaddr" | awk '{print "#"$1" : "$5}' >> ifcfg-eth${n}_temp
newmac=$(ifconfig -a | grep "eth" | sort | awk '{print $5}' | nl -n ln | grep "^${j}" | awk '{print $2}')
sed "s/HWADDR.*$/HWADDR=$newmac/g" ifcfg-eth${n}_temp > ifcfg-eth${n}_vi
cp -fa ifcfg-eth${n}_vi /etc/sysconfig/network-scripts/ifcfg-eth${n} && rm –f ifcfg-eth${n}_temp
else
newmac=$(ifconfig -a | grep "eth" | sort | awk '{print $5}' | nl -n ln | grep "^${j}" | awk '{print $2}')
continue
fi
done
echo > /etc/udev/rules.d/70-persistent-net.rules
reboot
Described method operation steps is as follows:
1) draw by num=$ (ifconfig-a | grep eth | wc-l) statement the network interface card number that system recognizes, decide to revise corresponding ifcfg-ethx file;
2) current all correct network interface card information is listed by ifconfig – a, and by key word " HWaddr " value MAC Address;
3) first judge whether the configuration file of this network interface card exists, then step 2 by if condition before amendment) in recognize MAC Address and write this file for standby, and add # annotation;
4) draw corresponding relation according to network interface card quantity before, the ifcfg-ethx file that amendment is corresponding, write correct MAC Address;
5) empty 70-persistent-net.rules file, and restart.Just can see network interface card full recovery startup.
Write rear increase and can perform authority: chmod 755 mac.sh;
Perform script: ./mac.sh;
Ifconfig test after wait autoboot completes.

Claims (6)

1. after changing MAC Address under a REDHAT operating system, network interface card recovers the method started, it is characterized in that: under redhat operating system, can perform in script by the statement required for instauration net card start-up is integrated in one, the operation wherein contain amendment configuration file, emptying temporary file, restart system.
2. after changing MAC Address under a kind of REDHAT operating system according to claim 1, network interface card recovers the method started, and it is characterized in that: first described method judges network interface card quantity, correct coupling corresponding relation.
3. after changing MAC Address under a kind of REDHAT operating system according to claim 2, network interface card recovers the method started, and it is characterized in that: still modify to all network interface card files after having judged.
4. after changing MAC Address under a kind of REDHAT operating system according to claim 3, network interface card recovers the method started, and it is characterized in that, described shell script mainly revises two files:
Ifcfg-eth, the MAC Address in these network card configuration files all will be revised as the MAC of current machine card of surfing Internet;
70-persistent-net.rules is the file that system generates automatically, the network interface card detected when comprising startup, determines network interface card order, directly empties.
5. after changing MAC Address under a kind of REDHAT operating system according to claim 1,2,3 or 4, network interface card recovers the method started, and it is characterized in that, described method operation steps is as follows:
1) draw by num=$ (ifconfig-a | grep eth | wc-l) statement the network interface card number that system recognizes, decide to revise corresponding ifcfg-ethx file;
2) current all correct network interface card information is listed by ifconfig – a, and by key word " HWaddr " value MAC Address;
3) first judge whether the configuration file of this network interface card exists, then step 2 by if condition before amendment) in recognize MAC Address and write this file for standby, and add # annotation;
4) draw corresponding relation according to network interface card quantity before, the ifcfg-ethx file that amendment is corresponding, write correct MAC Address;
5) empty 70-persistent-net.rules file, and restart.
6. after changing MAC Address under a kind of REDHAT operating system according to claim 5, network interface card recovers the method started, and it is characterized in that:
Write rear increase and can perform authority: chmod 755 mac.sh;
Perform script: ./mac.sh;
Ifconfig test after wait autoboot completes.
CN201410725087.9A 2014-12-03 2014-12-03 Method for restoring boot of network card after MAC (Media Access Control) address change under REDHAT operation system Pending CN104407899A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201410725087.9A CN104407899A (en) 2014-12-03 2014-12-03 Method for restoring boot of network card after MAC (Media Access Control) address change under REDHAT operation system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410725087.9A CN104407899A (en) 2014-12-03 2014-12-03 Method for restoring boot of network card after MAC (Media Access Control) address change under REDHAT operation system

Publications (1)

Publication Number Publication Date
CN104407899A true CN104407899A (en) 2015-03-11

Family

ID=52645532

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410725087.9A Pending CN104407899A (en) 2014-12-03 2014-12-03 Method for restoring boot of network card after MAC (Media Access Control) address change under REDHAT operation system

Country Status (1)

Country Link
CN (1) CN104407899A (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105138368A (en) * 2015-08-25 2015-12-09 浪潮电子信息产业股份有限公司 Network card configuration file burning method based on LINUX system
CN106254570A (en) * 2016-08-01 2016-12-21 天脉聚源(北京)教育科技有限公司 The MAC Address acquisition methods of a kind of ICE system and device
CN107040427A (en) * 2017-06-09 2017-08-11 上海联影医疗科技有限公司 A kind of method and device of network card configuration
CN107241239A (en) * 2017-06-23 2017-10-10 郑州云海信息技术有限公司 A kind of method for carrying out maximizing test to PCIE based on network interface card
CN108696394A (en) * 2018-05-18 2018-10-23 深圳市智微智能科技开发有限公司 The means of communication and equipment of multiple PCIE network interface cards under a kind of Linux system
CN111027104A (en) * 2019-11-26 2020-04-17 深圳中电长城信息安全系统有限公司 Method, device and mainboard for preventing loss of network card identification data

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102063347A (en) * 2010-12-28 2011-05-18 中国工商银行股份有限公司 Magnetic tape data recovery method and system
CN102427483A (en) * 2011-11-15 2012-04-25 浪潮电子信息产业股份有限公司 Method for binding network card name with equipment under Linux system

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102063347A (en) * 2010-12-28 2011-05-18 中国工商银行股份有限公司 Magnetic tape data recovery method and system
CN102427483A (en) * 2011-11-15 2012-04-25 浪潮电子信息产业股份有限公司 Method for binding network card name with equipment under Linux system

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
CZP11210: ""Linux脚本程序自动修改网卡配置文件中的MAC地址"", 《HTTP://WWW.2CTO.COM/OS/201308/236967.HTML》 *

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105138368A (en) * 2015-08-25 2015-12-09 浪潮电子信息产业股份有限公司 Network card configuration file burning method based on LINUX system
CN106254570A (en) * 2016-08-01 2016-12-21 天脉聚源(北京)教育科技有限公司 The MAC Address acquisition methods of a kind of ICE system and device
CN107040427A (en) * 2017-06-09 2017-08-11 上海联影医疗科技有限公司 A kind of method and device of network card configuration
CN107241239A (en) * 2017-06-23 2017-10-10 郑州云海信息技术有限公司 A kind of method for carrying out maximizing test to PCIE based on network interface card
CN108696394A (en) * 2018-05-18 2018-10-23 深圳市智微智能科技开发有限公司 The means of communication and equipment of multiple PCIE network interface cards under a kind of Linux system
CN111027104A (en) * 2019-11-26 2020-04-17 深圳中电长城信息安全系统有限公司 Method, device and mainboard for preventing loss of network card identification data

Similar Documents

Publication Publication Date Title
CN104407899A (en) Method for restoring boot of network card after MAC (Media Access Control) address change under REDHAT operation system
CN106095620B (en) A kind of development approach of built-in Linux partition holding
US8140907B2 (en) Accelerated virtual environments deployment troubleshooting based on two level file system signature
CN100377085C (en) Method for implementing hardware image starting optimizing of embedded operating system
CN109542682B (en) Data backup method, device, equipment and storage medium
CN102770841A (en) Method and apparatus for generating minimum boot image
EP2765525B1 (en) Apparatus, non-transitory computer readable information recording medium and information recording method
CN111258666B (en) Method and device for reading computer file, computer system and storage medium
CN103077043A (en) Method for fast starting and operating Linux
CN110007941A (en) A kind of the MCU firmware and upgrade method of Intelligent refuse classification recovery system
CN103747095A (en) Virtual desktop system and method
CN113986257A (en) Cloud platform front-end management interface deployment method and device and storage medium
US20050108704A1 (en) Software distribution application supporting verification of external installation programs
US20130086572A1 (en) Generation apparatus, generation method and computer readable information recording medium
CN107168719A (en) Application program operation method, device, terminal and computer-readable recording medium
CN103995717A (en) Method for upgrading software in embedded device
CN111400128B (en) Log management method and device, computer equipment and storage medium
CN114756355B (en) Method and device for automatically and quickly recovering process of computer operating system
CN109144948B (en) Application file positioning method and device, electronic equipment and memory
CN102298531A (en) Method for upgrading flash memory file system in embedded system
CN100504787C (en) Virtual executing method for installing software, and system
CN109857380B (en) Workflow file compiling method and device
CN106547589A (en) A kind of upgrade-system and upgrade method
CN113064698A (en) Method for providing product environment and corresponding device, system, equipment and medium
CN108363607B (en) Virtual link power failure recovery method of cloud platform virtual machine

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20150311

RJ01 Rejection of invention patent application after publication