You are not logged in.

#1 2011-03-31 16:57:36

Revelation60
Member
From: The Netherlands
Registered: 2009-03-19
Posts: 158
Website

nd: Simple network diagnostics

I am probably not the only Arch user that has network trouble from time to time. What I normally do to find the problem, is ping some servers, ping my gateway, check if devices are up, etc. This can be very tedious.

What I propose is a community project that automates network checks. These checks start from the bottom and stop when an issue is detected. For example, the software first checks if devices are up, then sees if the devices have an IP, if a gateway is specified et cetera.

I want to do it in bash and my bash skills are not that great. If however, some of you want to join development I am sure we can make this work. One of the first things we must do is make a list of the checks, from the bottom up.

What do you guys think about such a project?


edit: I have named the project nd, which stands for network diagnostics. It is hosted here. Click  here for the AUR package.

Last edited by Revelation60 (2011-04-01 16:56:21)

Offline

#2 2011-03-31 18:04:06

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: nd: Simple network diagnostics

Nice idea:
- add some Warning / ErrMsgs e.g. when ifconfig doesn't return an IP address or use 'ifconfig -a' to find all interfaces,
- you can use some other useful commands,
- use $() instead of backticks :-)

Offline

#3 2011-04-01 00:42:02

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,231
Website

Re: nd: Simple network diagnostics

I like it, I don't know why I haven't thought of this before!

1) Functions should return 0 (success) or non-zero (failure) so the status can be reported to the user in context, rather than a generic message in the function itself.
2) I'd suggest using the iproute2 commands (eg, ip address show, ip route show etc) as iproute2 is supposed to be replacing ifconfig/route etc AFAIK.

EDIT: Think of a cool name, create a git repo and I'll fork it wink

Last edited by fukawi2 (2011-04-01 00:42:54)

Offline

#4 2011-04-01 15:07:44

Revelation60
Member
From: The Netherlands
Registered: 2009-03-19
Posts: 158
Website

Re: nd: Simple network diagnostics

I have named the project nd, which stands for network diagnostics. I guess that will do as a working title smile

Everyone, feel free to contribute!

Offline

#5 2011-04-01 15:49:49

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: nd: Simple network diagnostics

I'd suggest using the 'host' tool for DNS resolution instead of relying on ping.

Offline

#6 2011-04-01 16:31:53

Revelation60
Member
From: The Netherlands
Registered: 2009-03-19
Posts: 158
Website

Re: nd: Simple network diagnostics

Done smile What would be important to check next? I am thinking of checking if devices are up, and if it's wireless a wireless connection, check if it is associated.

Offline

#7 2011-04-01 16:40:53

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: nd: Simple network diagnostics

Network connectivity is a sketchy thing. It all comes down to how you define it.

Does an interface exist? Does it have a carrier? It might be connected to an AP that requires authentication (and you don't have auth)
Does it have an IP address? If it was staticly assigned, there's no guarantee that it does anything.
Do you have a route to where you want to go? Is there a VPN/SSH tunnel that's required to get there? Is there proxying involved midway?

Even if you can get satisfactory functional verification of all of the above (and there's more -- just think of OSI), you're then still dependent on the end point responding to your request. As much as you can check, I've discovered the hard way that attempting to programatically determine whether or not have you a network connection is a flawed premise. There's too much involved.

Don't get me wrong -- I'm not trying to discourage you, just point out what you're battling here.

Offline

#8 2011-04-01 18:29:10

Stebalien
Member
Registered: 2010-04-27
Posts: 1,239
Website

Re: nd: Simple network diagnostics

This isn't very important but using www.example.com and 192.0.32.10 instead of google would probably be better.


Steven [ web : git ]
GPG:  327B 20CE 21EA 68CF A7748675 7C92 3221 5899 410C

Offline

#9 2011-04-01 20:25:49

gorilla
Member
From: Berlin
Registered: 2010-06-15
Posts: 72

Re: nd: Simple network diagnostics

Great app! Thanks!

Offline

#10 2011-04-01 21:33:22

Revelation60
Member
From: The Netherlands
Registered: 2009-03-19
Posts: 158
Website

Re: nd: Simple network diagnostics

You're welcome smile I've added some checks to see if devices are up, if a device is a wireless and if so, if it is associated. I still have some fine tuning to do to filter out Ethernet devices. But that's something for tomorrow.

Offline

#11 2011-04-02 07:57:20

ga01f4733
Member
From: NYC
Registered: 2008-12-05
Posts: 117

Re: nd: Simple network diagnostics

Find it useful and fast, nice script, very handy. smile

dank je , thank you


There are no foreign lands. It is the traveler only who is foreign. --R.L Stevenson

Offline

#12 2011-04-03 01:36:41

mikesd
Member
From: Australia
Registered: 2008-02-01
Posts: 788
Website

Re: nd: Simple network diagnostics

Nice! I use something similar at work and at home but with a gui. At home it appears as part of my status bars. I always look at connectivity as a dependency based problem. That is: Can I ping my router, if so can I ping my adsl modem, if so can I ping a internet based IP ( I normally use Google Public DNS or OpenDNS's server), if so does DNS resolving work, next check VPN and tunnels, etc. Works for me.

One small issue for me is that the output of nd.sh is garbled when it does the ping steps. This is caused by an entry in my PATH for a color wrapping utility that colorizes the output of common commands. It doesn't play well with scripts though. smile There are two ways to fix this:

1. Use the full PATH to executables in your script.

2. Set a sane PATH at the top of your script. This is a good idea for security anyways.

Offline

#13 2011-04-03 08:13:44

Revelation60
Member
From: The Netherlands
Registered: 2009-03-19
Posts: 158
Website

Re: nd: Simple network diagnostics

I have added a default search path. Is it working now?

Offline

#14 2011-04-03 09:02:08

mikesd
Member
From: Australia
Registered: 2008-02-01
Posts: 788
Website

Re: nd: Simple network diagnostics

Perfect! Much obliged. smile

Offline

#15 2011-04-07 16:53:30

lth
Member
Registered: 2009-01-23
Posts: 3

Re: nd: Simple network diagnostics

This sounds like something that would go well with netcfg, since they're both network bash scripts.

Offline

#16 2011-04-08 12:57:45

X-dark
Member
From: France
Registered: 2009-10-25
Posts: 142
Website

Re: nd: Simple network diagnostics

Ping is not working through my corporate proxy so it kind of defeat this. I guess if this is the net connectivity we want to check a telnet on port 80 would be more reliable.

Edit: But the interface cannot be selected then.

Last edited by X-dark (2011-04-08 12:59:13)


Cedric Girard

Offline

#17 2011-04-08 13:15:12

Revelation60
Member
From: The Netherlands
Registered: 2009-03-19
Posts: 158
Website

Re: nd: Simple network diagnostics

Edit: But the interface cannot be selected then.

You can specify your own interface as an argument to nd.

Ping is not working through my corporate proxy so it kind of defeat this. I guess if this is the net connectivity we want to check a telnet on port 80 would be more reliable.

I'll check it out!

Offline

#18 2011-04-08 13:54:38

X-dark
Member
From: France
Registered: 2009-10-25
Posts: 142
Website

Re: nd: Simple network diagnostics

Revelation60 wrote:

Edit: But the interface cannot be selected then.

You can specify your own interface as an argument to nd.

I was speaking about telnet.

Ping is not working through my corporate proxy so it kind of defeat this. I guess if this is the net connectivity we want to check a telnet on port 80 would be more reliable.

I'll check it out!

After some thinking, I'm not sure it is the easiest thing to do. You would need to parse the output to see if the connection have been established and then send a signal to kill it.


Cedric Girard

Offline

#19 2011-04-09 10:12:00

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,231
Website

Re: nd: Simple network diagnostics

Your firewall admins need a boot up the arse, especially if they are blocking ICMP while allowing port 80!! yikes

Offline

#20 2011-04-11 20:07:38

Revelation60
Member
From: The Netherlands
Registered: 2009-03-19
Posts: 158
Website

Re: nd: Simple network diagnostics

Has anyone got some more ideas for things to check?

Offline

#21 2011-04-18 12:43:55

X-dark
Member
From: France
Registered: 2009-10-25
Posts: 142
Website

Re: nd: Simple network diagnostics

fukawi2 wrote:

Your firewall admins need a boot up the arse, especially if they are blocking ICMP while allowing port 80!! yikes

I've stopped trying to understand how someone can configure a firewall so badly ... We are many to tunnel a lot of thing through a ssh connection (on port 443) in order to have a usable environment.


Cedric Girard

Offline

#22 2011-06-01 04:45:08

anonymous_user
Member
Registered: 2009-08-28
Posts: 3,059

Re: nd: Simple network diagnostics

Sometimes when I run nd, I see messages like:

grep: 7986: No such file or directory
grep: 14010/cmdline: No such file or directory

What is causing that and how could I stop those messages?

Offline

#23 2011-06-01 08:34:33

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,231
Website

Re: nd: Simple network diagnostics

Interesting... That's a part I did. Next time that happens, can you post the output of the following commands? smile

pgrep '^(dhcp|dhclient)'
ps -ef | grep -E '(dhcp|dhclient)'

Offline

#24 2011-06-01 14:33:13

anonymous_user
Member
Registered: 2009-08-28
Posts: 3,059

Re: nd: Simple network diagnostics

~ $ nd
* Link OK
* Interface is UP
grep: 1481/cmdline: No such file or directory
    Local IP:    192.168.1.64
    DHCP: no
* Default gateway: 192.168.1.254
    Responded to ping in 0.792 ms
* Testing external IP...
    Responded to ping in 13.7 ms
* Testing DNS resolver...
    Hostname was resolved.

You seem to have a working internet connection!
~ $ pgrep '^(dhcp|dhclient)'
1450
1481
~ $ ps -ef | grep -E '(dhcp|dhclient)'
root      1450  1391  0 07:26 ?        00:00:00 [dhcpcd] <defunct>
root      1481     1  0 07:26 ?        00:00:00 /sbin/dhcpcd eth0 -h kevin-desktop
kevin     2047  1990  0 07:32 pts/0    00:00:00 grep -E (dhcp|dhclient)

Offline

#25 2011-06-01 23:26:24

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,231
Website

Re: nd: Simple network diagnostics

I didn't think about multiple dhcp processes, whoops. Thanks for the output smile

Fixed and pull request sent to benruijl
https://github.com/benruijl/nd/pull/3

Offline

Board footer

Powered by FluxBB