Add a network Clip interface IP address shell script

Source: Internet
Author: User


#!/bin/bash#author wangning#date 2017-7-15#qq 1198143315#email [email protected]##### ########################## define color ############################# #red = "\033[31m" green= "\033 [32m "yellow=" \033[33m "color=" \033[0m "################################## menu function ######### ############### #menu () {echo -e  "=========================please select number 1-16, add ip 10.0.2.xor delete ip 10.0.2.x$green  1.add ip  $color $red   2.delete ip  $color $yellow  3.exit  $color    =============== ========== "}################################ jude integer function ####################### # #jude_integer () {read -p  "please select 1 or 2 or 3:"   num1clearexpr  $num 1 + 1 &>/dev/nullif [ $? -ne 0 ];then    echo -e  "please input a  $yellow  integer number  $color"    continue  1fi}############################### configure ip address function ############# ######## #config_ip () {if [ -z  $num 1 ];then  echo -e  "$yellow  can ' t  be empty  $color "elif [  $num 1 -gt 3 ];then  echo -e   "you must input a number  $yellow  less than 4  $color" elif  [  $num 1 -eq 1 ];then  read -p  "Please input number   1-16 add ip: " num2   ip addr add 10.0.2.${num2}/24  dev eth0: $num 2     if [ $? -eq 0 ];then         echo -e  "$green  the ip 10.0.2. $num 2  Has added successful  $color "     else        echo -e   "$red  the ip 10.0.2 $num 2 has added failed  $color"       fielif [  $num 1 -eq 2 ];then  read -p  "please  Input number 1-16 delete ip: " num3  ip addr del 10.0.2.${ Num3}/24 dev eth0: $num 3     if [ $? -eq 0 ];then         echo -e  "$green  the ip 10.0.2. $num 3  has deleted successful  $color "     else         echo -e  "$red  the ip 10.0.2. $num 3 has deteted  failed  $color "     fielif [  $num 1 -eq 3 ];then   exit 0fi}################################### main function ############################## #main () {while  Truedomenujude_integerconfig_ipdone}main


This article is from the "Galloping Camel" blog, make sure to keep this source http://wn2100.blog.51cto.com/9915310/1947971

Add a network Clip interface IP address shell script

Related Article

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.