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