VMware Virtual machine Cloning CentOS system, there is a headache is the Mac and network card address need to do the corresponding operation; here's a little bit of a personal idea.
Hope to bring a little joy to everyone's mood.
#!/usr/bin/env bash# file user VMware clones CentOS, modifies NIC, configures IP address, configures Hostsnamehostfile="/etc/sysconfig/network"Netfile="/etc/sysconfig/network-scripts/"FILE70="/etc/udev/rules.d/70-persistent-net.rules"Selinucfile="/etc/selinux/config"Configurebase () {# Modify 70 start file sed-I.'7,12d'${file70} sed-I.'s/eth2/eth0/'${file70} sed-I.'s/eth3/eth1/'${file70} # Fetch MAC address Net701= ' Grep-e"eth0"${FILE70} | Awk-f"==" '{print $}'| Cut-d','-f1 | Sed's/\ "//g'' Net702= ' Grep-e"eth1"${FILE70} | Awk-f"==" '{print $}'| Cut-d','-f1 | Sed's/\ "//g'' # Modify the NIC NetF1= ' grep'HWADDR'${netfile}ifcfg-eth0 | Awk-f'=' '{print $}'' NetF2= ' grep'HWADDR'${netfile}ifcfg-eth1 | Awk-f'=' '{print $}'' Read-P"Enter Configure ip>>"Inpip Sleep3sed-I. s/"HWADDR=${NETF1}"/"hwaddr=${net701}"/${netfile}ifcfg-eth0 sed-I. s/"ipaddr=10.10.100.2[0-9]\{1,\}"/"Ipaddr=10.10.100.${inpip}"/${netfile}ifcfg-eth0 sed-I. s/"HWADDR=${NETF2}"/"hwaddr=${net702}"/${netfile}ifcfg-eth1 # Modify config file, restart effective (permanent) Read-P"Enter your hostname>>"HN Currhn=' hostname ' sed-I. s/"Hostname=${currhn}"/"Hostname=${hn}"/${hostfile} # Direct Config # hostname ${hn}} Disabsomser () {Service iptables stop/sbin/chkconfig iptables off sed-I.'s/selinux=enforcing/selinux=disabled/'${selinucfile}} RUN () {configurebase disabsomser reboot}run
VMware Virtual machine Cloning CentOS 6.5 Nic Modified Bunker method