Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
06-27-2014, 11:50 AM
|
#1
|
LQ Guru
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,330
|
script to provide info necessary for network troubleshooting
i created this script called net-diag.ksh which i refer people to identify their network card and stuff:
Code:
#!/bin/bash
echo uname && uname -a -m -p &> /tmp/00-uname.schneidz && \
echo lspci && lspci &> /tmp/01-lspci.schneidz && \
echo lsusb && lsusb &> /tmp/02-lsusb.schneidz && \
echo lsmod && lsmod &> /tmp/03-lsmod.schneidz && \
echo ifconfig && ifconfig &> /tmp/04-ifconfig.schneidz && \
echo ifconfig -a && ifconfig -a &> /tmp/05-ifconfig-a.schneidz && \
echo iwconfig && iwconfig &> /tmp/06-iwconfig.schneidz && \
echo iwlist && sudo iwlist `awk '/IEEE/ {print $1}' /tmp/06-iwconfig.schneidz` scan &> /tmp/07-iwlist.schneidz && \
echo resolv.conf && cat /etc/resolv.conf &> 08-resolv.conf.schneidz && \
echo route && route -n &> /tmp/09-route.schneidz && \
echo ping router && ping -c 1 `route | awk '/default/ {print $2}'` &> /tmp/10-ping-router.schneidz && \
echo ping dns server && ping -c 1 `awk '/nameserver/ {print $2}' /etc/resolv.conf | head -n 1` &> /tmp/11-ping-dns-server.schneidz && \
echo ping using ip && ping -c 1 64.235.229.141 &> /tmp/12-ping-using-ip.schneidz && \
echo ping using dns && ping -c 1 www.02144.com &> /tmp/13-ping-using-dns.schneidz
head -n 99999 /tmp/*.schneidz
one would basically need to copy-pasta the source code and save as net-diag.ksh.
then run it as source netdiag.ksh (or change perms like chmod 744 netdiag.ksh then run it like: ./net-diag.ksh).
whatever it spits out should be copy-pastad in the thread (in [code] tags) to give whoever wishes to answer a starting point for determining the issue.
critiques are welcome.
Last edited by schneidz; 06-27-2014 at 11:53 AM.
|
|
|
07-01-2014, 01:13 PM
|
#2
|
Moderator
Registered: May 2001
Posts: 29,417
|
Quote:
Originally Posted by schneidz
critiques are welcome.
|
Thanks for the opportunity:
- not testing for binaries to use,
- predictable (fixed) file name instead of using `mktemp`,
- using multiple file names where one would suffice (also see use of 'head'),
- unnecessary use of double ampersands,
- no error checking (does `route | awk '/default/ {print $2}'` always present something one can resolve?).
*Ever heard of 'ss' or 'ip'? Esp. 'ip' can provide a lot of nfo in one tool. And what about protocol focus? UDP and ICMP are one thing but how about TCP? As in 'tcptraceroute'? Or content as in "curl -kI https://something"?
|
|
1 members found this post helpful.
|
07-01-2014, 01:46 PM
|
#3
|
LQ Guru
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,330
Original Poster
|
thanks,
double &&'s so that it stops at the step that it failed on.
head puts a header before each file so it is easier to scan thru a wall of text.
i've had good luck with parsing the route command but parsing /etc/resolv.conf for a nameserver sometimes gives an ipv6 address that ping chokes on.
ip seems very useful and will probably replace most of the steps.
|
|
|
07-01-2014, 05:53 PM
|
#4
|
Senior Member
Registered: Sep 2009
Location: Raleigh, NC
Distribution: Ubuntu, PopOS, Raspbian
Posts: 1,899
|
There's no need to do the double ampersands. You can start your script with...
See man bash. The set command is detailed at the end.
set -e will stop your script on first error and report the last error exit code. Regarding ip command like unspawn mentions I wrote a blog post which provides an example of obtaining the IP address for the interface of the default route. It uses the ip command.
SAM
Last edited by sag47; 07-01-2014 at 05:55 PM.
|
|
2 members found this post helpful.
|
03-13-2015, 10:32 AM
|
#5
|
LQ Guru
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,330
Original Poster
|
added rfkill
modified lspci:
i created this script called net-diag.ksh which i refer people to identify their network card and stuff:
Code:
#!/bin/bash
echo uname && uname -a -m -p &> /tmp/00-uname.schneidz && \
echo lspci && lspci -vvv -nn | awk 'BEGIN {RS="\n\n"} /Ethernet controller|Network controller/ {print $0}' &> /tmp/01-lspci.schneidz && \
echo lsusb && lsusb &> /tmp/02-lsusb.schneidz && \
echo lsmod && lsmod &> /tmp/03-lsmod.schneidz && \
echo ifconfig && ifconfig &> /tmp/04-ifconfig.schneidz && \
echo ifconfig -a && ifconfig -a &> /tmp/05-ifconfig-a.schneidz && \
echo iwconfig && iwconfig &> /tmp/06-iwconfig.schneidz && \
echo rfkill && rfkill list &> /tmp/07-rfkill.schneidz && \
echo iwlist && sudo iwlist `awk '/IEEE/ {print $1}' /tmp/06-iwconfig.schneidz` scan &> /tmp/08-iwlist.schneidz && \
echo resolv.conf && cat /etc/resolv.conf &> 09-resolv.conf.schneidz && \
echo route && route -n &> /tmp/10-route.schneidz && \
echo ping router && ping -c 1 `route | awk '/default/ {print $2}'` &> /tmp/11-ping-router.schneidz && \
echo ping dns server && ping -c 1 `awk '/nameserver/ {print $2}' /etc/resolv.conf | head -n 1` &> /tmp/12-ping-dns-server.schneidz && \
echo ping using ip && ping -c 1 64.235.229.141 &> /tmp/13-ping-using-ip.schneidz && \
echo ping using dns && ping -c 1 www.02144.com &> /tmp/14-ping-using-dns.schneidz
head -n 99999 /tmp/*.schneidz
one would basically need to copy-pasta the source code and save as net-diag.ksh.
then run it as source netdiag.ksh (or change perms like chmod 744 netdiag.ksh then run it like: ./net-diag.ksh).
whatever it spits out should be copy-pastad in the thread (in [code] tags) to give whoever wishes to answer a starting point for determining the issue.
critiques are welcome.
Last edited by schneidz; 03-13-2015 at 11:49 AM.
|
|
|
03-13-2015, 10:50 PM
|
#6
|
Senior Member
Registered: Sep 2009
Location: Raleigh, NC
Distribution: Ubuntu, PopOS, Raspbian
Posts: 1,899
|
See posts #2 and #4. I would apply that same feedback to your most recent script. Additionally, just because you call a script *.ksh does not make it ksh. The shebang is what really matters unless you execute the script as an argument of the interpreter. In your case, the shebang is #!/bin/bash. So that's a bash script. If you want it to be ksh then you should update the shebang.
|
|
|
03-13-2015, 11:42 PM
|
#7
|
Moderator
Registered: May 2001
Posts: 29,417
|
Nice but you're still:
- not testing for binaries you use,
- using predictable file names instead of using 'mktemp',
- using multiple file names...
|
|
|
All times are GMT -5. The time now is 09:08 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|