Shell script to collect Linux network configuration information

Source: Internet
Author: User

This script has been tested under the Centos/rhel and Fedora Linux operating systems.
Available for current network configuration information.

Code:

#!/bin/Bash#hwinf=/usr/sbin/hwinfoifcfg=/sbin/IFCONFIGIP4FW=/sbin/IPTABLESIP6FW=/sbin/Ip6tableslspci=/sbin/Lspciroute=/sbin/Routenetstat=/bin/NETSTATLSB=/usr/bin/Lsb_release # # files # #DNSCLIENT="/etc/resolv.conf"drvconf="/etc/modprobe.conf"NETALIASCFC="/etc/sysconfig/network-scripts/ifcfg-eth?-range?"NETCFC="/etc/sysconfig/network-scripts/ifcfg-eth?"NETSTATICROUTECFC="/etc/sysconfig/network-scripts/route-eth?"SYSCTL="/etc/sysctl.conf"# # Output File # #OUTPUT="network.$ (date + '%d-%m-%y '). Info.txt"# # Email Info to??# #SUPPORT_ID="[email protected]"Chk_root () {Local Meid=$ (ID-u)if[$meid-ne0 ]; Then Echo"you must be a root user to run this tool"Exit999fi} write_header () {echo"---------------------------------------------------">>$OUTPUT Echo"[email protected]">>$OUTPUT Echo"---------------------------------------------------">>$OUTPUT} dump_info () {echo"* Hostname: $ (Hostname)">$OUTPUT Echo"* Run Date and Time: $ (date)">>$OUTPUT Write_header"Linux distro"Echo"Linux Kernel: $ (UNAME-MRS)">>$OUTPUT $LSB-A >>$OUTPUT [-X ${hwinf}] && Write_header"${hwinf}--network_ctrl" [ -X ${hwinf}] && ${hwinf}--network_ctrl >>$OUTPUT [-X ${hwinf}] && Write_header"${hwinf}--isapnp" [ -X ${hwinf}] && ${hwinf}--isapnp >>$OUTPUT Write_header"PCI Devices"${lspci}-V >>$OUTPUT Write_header"$IFCFG Output"$IFCFG>>$OUTPUT Write_header"Kernel Routing Table"$ROUTE-N >>$OUTPUT Write_header"configuration of the NIC driver $DRVCONF" [ -F $DRVCONF] && grep eth $DRVCONF >> $OUTPUT | | Echo"Error $DRVCONF File not found.">>$OUTPUT Write_header"DNS $DNSCLIENT configuration information" [ -F $DNSCLIENT] && cat $DNSCLIENT >> $OUTPUT | | Echo"Error $DNSCLIENT File not found.">>$OUTPUT Write_header"Network configuration file Information"  forFinch$NETCFC Do  if[ -F $f] then echo"* * $f * *">>$OUTPUT Cat $f>>$OUTPUTElseEcho"Error $f not found.">>$OUTPUT fi done Write_header"Network aliase File"  forFinch$NETALIASCFC Do  if[ -F $f] then echo"* * $f * *">>$OUTPUT Cat $f>>$OUTPUTElseEcho"Error $f not found.">>$OUTPUT fi done Write_header"Network static routing configuration"  forFinch$NETSTATICROUTECFC Do  if[ -F $f] then echo"* * $f * *">>$OUTPUT Cat $f>>$OUTPUTElseEcho"Error $f not found.">>$OUTPUT fi done Write_header"IP4 Firewall Configuration"$IP 4FW-l-n >>$OUTPUT Write_header"IP6 Firewall Configuration"$IP 6FW-l-n >>$OUTPUT Write_header"Network Status"$NETSTAT-S >>$OUTPUT Write_header"Network tweaks via $SYSCTL" [ -F $SYSCTL] && cat $SYSCTL >> $OUTPUT | | Echo"Error $SYSCTL not found.">>$OUTPUT Echo"The network configuration information is written to the file: $OUTPUT. Please send an email to: $SUPPORT _id."} chk_rootdump_info

Shell script to collect Linux network configuration information

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.