See the shell, write a script to set the parameters of the network card try it. It's inefficient, but it's a good use.
===================
#!/bin/bash
Lang=zh_cn. UTF-8
Clear #Select the network card
echo "' Date '"
Echo-e "\033[34m Select Network Card (Enter to continue) \033[0m"
ceshi=$ (find/etc/sysconfig/network-scripts/-name ' *ifcfg* ')
#Segmentation variables Data
Old_ifs= "$IFS"
Ifs= ""
Arr= ($ceshi)
ifs= "$OLD _ifs"
I=0 #Definitions and variables
For S in ${arr[@]} #for
Do
# echo "$s"
# echo "--"
Conid[i]= $s
echo "No." $i "Network card:" $s
((i++))
Done
# echo ${conid[0]}
# echo ${conid[1]}
#echo ${#conid [*]} #pinrt conid[*]
#检测用户选择网卡
Echo-e "\033[34m Select Network card No.: \033[0m"
Read Conidnum #user in
#echo $conidNum
Clear #onboot
ECHO-E "\033[34m you select No. $conidNum Network card:${conid[$conidNum]} \033[0m"
echo "You want-to-boot with this card (onboot):"
Echo-e "1.onboot=\033[33m YES \033[0m"
Echo-e "2.onboot=\033[33m NO \033[0m"
echo "Enter 1 or 2:"
Read Onboot
Case $onboot in
1)
onboottxt= "YES"
;;
2)
onboottxt= "NO"
;;
Esac
Clear #Bootproto
ECHO-E "\033[34m you select No. $conidNum Network card:${conid[$conidNum]} \033[0m"
Echo-e "\033[34m Boot with the This card $onboottxt. (Onboot=${onboottxt}) \033[0m "
echo "Select network Mode (Bootproto):"
Echo-e "1.bootproto=\033[33m STATIC \033[0m"
Echo-e "2.bootproto=\033[33m DHCP \033[0m"
echo "Enter 1 or 2:"
Read Bproto
Case $bproto in
1)
bprototxt= "STATIC"
;;
2)
bprototxt= "DHCP"
echo "Any key to Finish,ctrl+c to Exit. "
Read-n 1
Sed-i '/onboot/d ' ${conid[$conidNum]}
Sed-i '/bootproto/d ' ${conid[$conidNum]}
echo "onboot=" $onboottxt >>${conid[$conidNum]}
echo "bootproto=" $bprototxt >>${conid[$conidNum]}
#del Old Config
Sed-i '/ipaddr/d ' ${conid[$conidNum]}
Sed-i '/netmask/d ' ${conid[$conidNum]}
Sed-i '/gateway/d ' ${conid[$conidNum]}
Sed-i '/dns1/d ' ${conid[$conidNum]}
Sed-i '/dns2/d ' ${conid[$conidNum]}
echo "Modifications is complete!!! Service REATST: "
Service Network restart
#service Network Restart
echo "-------Print ifconfig-------"
Ifconfig
echo "-------Print ifconfig-------"
#echo ${conid[$conidNum]}
echo "any key to Exit. "
Read-n 1
Exit
;;
Esac
Clear #IPADDR
ECHO-E "\033[34m you select No. $conidNum Network card:${conid[$conidNum]} \033[0m"
Echo-e "\033[34m Boot with the This card $onboottxt. (Onboot=${onboottxt}) \033[0m "
ECHO-E "\033[34m the network mode $bprototxt. (Bootproto=${bprototxt}) \033[0m "
echo "Plase Enter IP address:"
Read IPAddr
echo "Plase Enter NetMask:"
Read netmask
echo "Plase Enter GateWay:"
Read Gateway
echo "Plase enter NDS Main:"
Read dns1
echo "Plase Enter NDS Alternate (enter to Default configuration):"
Read Dns2
echo "Plase check the Configuration,enter to Finish or CTRL + C to Exit. "
#echo ${conid[$conidNum]}
#del Old Config
Sed-i '/onboot/d ' ${conid[$conidNum]}
Sed-i '/bootproto/d ' ${conid[$conidNum]}
Sed-i '/ipaddr/d ' ${conid[$conidNum]}
Sed-i '/netmask/d ' ${conid[$conidNum]}
Sed-i '/gateway/d ' ${conid[$conidNum]}
Sed-i '/dns1/d ' ${conid[$conidNum]}
Sed-i '/dns2/d ' ${conid[$conidNum]}
#add New Config
echo "onboot=" $onboottxt >>${conid[$conidNum]}
echo "bootproto=" $bprototxt >>${conid[$conidNum]}
echo "ipaddr=" $ipaddr >>${conid[$conidNum]}
echo "netmask=" $netmask >>${conid[$conidNum]}
echo "gateway=" $gateway >>${conid[$conidNum]}
echo "dns1=" $dns 1 >>${conid[$conidNum]}
If Test-z "$dns 2"
Then
$dns 2= "Null"
Else
echo "dns2=" $dns 2 >>${conid[$conidNum]}
Fi
#echo "Completed modification!!! Restarting service: "
echo "Modifications is complete!!! Service REATST: "
#service Network Restart
Service Network restart
echo "-------Print ifconfig-------"
Ifconfig
echo "-------Print ifconfig-------"
#echo "any key to exit. "
echo "any key to Exit. "
Read-n 1
Exit
===============================================================
PostScript: Able to solve the problem of 3 lines to write a lot of many lines. Ran a bit on the centos6.5 to meet the demand. The first time to write a shell script, only to find that the original English information is "the simplest."
Initial shell, set NIC parameters