Script to automatically modify Linux/ETC/SYSCONFIG/NETWORK-SCRIPTS/IFCFG-ETHX network card files

Source: Internet
Author: User

This script modifies Linux/ETC/SYSCONFIG/NETWORK-SCRIPTS/IFCFG-ETHX network card files in the network card one, network card two IP address (ipaddr), subnet mask (NETMASK) information

#!/bin/sh
Proc=/bin/sed
File_path1=/etc/sysconfig/network-scripts/ifcfg-eth0
File_path2=/etc/sysconfig/network-scripts/ifcfg-eth1
Ip_primal1= ' grep-i ipaddr $FILE _path1|awk-f "=" ' {printf $} '
Mask_primal1= ' grep-i netmask $FILE _path1|awk-f "=" ' {printf $} '
Ip_primal2= ' grep-i ipaddr $FILE _path2|awk-f "=" ' {printf $} '
Mask_primal2= ' grep-i netmask $FILE _path2|awk-f "=" ' {printf $} '
ip_modi1=192.168.1.200
mask_modi1=255.255.255.0
ip_modi2=192.168.2.200
mask_modi2=255.255.255.0
$PROC-E "s/$IP _primal1/$IP _modi1/g"-E "s/$MASK _primal1/$MASK _modi1/g" $FILE _path1>ifcfg-eth0.bak
$PROC-E "s/$IP _primal2/$IP _modi2/g"-E "s/$MASK _primal2/$MASK _modi2/g" $FILE _path2>ifcfg-eth1.bak
CP-PF./ifcfg-eth0.bak $FILE _path1
CP-PF./ifcfg-eth1.bak $FILE _path2
Cat $FILE _path1
Cat $FILE _path2
Service Network restart

File Download Address: http://download.csdn.net/source/3032618

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.