View network configurations using shell scripts

Source: Internet
Author: User

View network configurations using shell scripts

#!/bin/bashifconfig|grep -E 'eth|inet'|grep -Ev '(inet6|127.0.0.1)'|sed 's/ /\n/g'|awk NF|grep -Ev '(inet|encap|Link|HWaddr)'|sed 's/00:/MAC:/g';route|grep default|awk '{print "\nGATEWAY:"$2}'cat /etc/resolv.conf|grep nameserver|awk '{print "DNS:"$2}'


How can I automatically read the files to be configured during shell script execution?

If the installation command is install. sh and the file name is set to target. sh, run the following command:
./Install. sh <target. sh

Which of the following linux statements can help you write a linux shell script? Thank you very much for checking and changing the NIC configuration file.

I did not want to write a part. 20 points not comfortable:
Declare-a array; array = ('ifconfig | grep encap | awk-F "" '{print $1 }''); echo "You have $ {# array [@]} network card"; echo "Network card list:"; for var in $ {array [@]}; do echo $ var; done; echo "Display the configure of Networkcard? (Y/n) "; read dpc; if [$ dpc =" y "]; then echo" Please choice which interface you want to display: "; echo" 0 :: all "; numc = 1; for chin $ {array [@]}; do echo" $ numc: $ chin "; numc = $ [numc + 1]; done; echo "You Input is:"; read choice; if [$ choice-gt $ {# array [@]}]; then echo "You Input Error"; sleep 10; fi; if [$ choice-eq 0]; then for ethvar in $ {array [@]}; do ifconfig $ ethvar; done; else ifconfig $ {array [$ choice-1]}; fi;

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.