|
|
Discover network status from CLI?
|
|
|
|
Addicted to MacNN
Join Date: Oct 2001
Location: Yokohama, Japan
Status:
Offline
|
|
I want to be able to tell whether or not the network is up from the CLI. I suppose I could just ping something and wait for it to time out, but that seems like a bad solution. Anyone know if this is stored as a paramter readable with defaults or something?
|
|
|
|
|
|
|
|
|
Moderator
Join Date: May 2001
Location: Hilbert space
Status:
Offline
|
|
First would be ifconfig. ifconfig tells you what kind of connection you have, if any, which speed, whether or not duplex is active, the ip, etc.
If you get a 169.x.x.x ip, your computer couldn't find a dhcp server and assigned this ip to itself (windows does the same).
Then you could check whether or not you can find a name server. Enter nslookup www.apple.com and you should get Apple's server's ip address.
What else are you trying to find out?
|
I don't suffer from insanity, I enjoy every minute of it.
|
|
|
|
|
|
|
|
Addicted to MacNN
Join Date: Oct 2001
Location: Yokohama, Japan
Status:
Offline
|
|
I just want to find out if the machine has access to the internet. ifconfig has plenty of info, but not a simple boolean about whether the network is up or down.
I suppose host will do (nslookup is deprecated). Thanks.
|
|
|
|
|
|
|
|
|
Moderator
Join Date: May 2001
Location: Hilbert space
Status:
Offline
|
|
Yes, ifconfig delivers you exactly that: if there is a physical connection, you will see a speed and an ip. If you don't have a connection, it'll just show you the MAC address and the speeds available.
nslookup still works in Tiger, but you can also use dig. dig www.apple.com.
|
I don't suffer from insanity, I enjoy every minute of it.
|
|
|
|
|
|
|
|
Addicted to MacNN
Join Date: Oct 2001
Location: Yokohama, Japan
Status:
Offline
|
|
Yeah but then I still have to parse it more carefully than a simple "network-status=up" or something. Plus a physical connection doesn't necessarily mean an internet connection, which is what I really want. (No, I didn't really specify that before. Sorry.)
I know nslookup works, but it warns you when you run it that it's deprecated. I like to try to futureproof my apps.
I tried dig, but the output of host ended up being easier to parse. Thanks for the tip, though.
|
|
|
|
|
|
|
|
|
Moderator
Join Date: May 2001
Location: Hilbert space
Status:
Offline
|
|
It's mainly because there are so many levels of `is this working'.
Take a look at Apple's Connection Doctor. I think they have seven different stages or so.
|
I don't suffer from insanity, I enjoy every minute of it.
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Sep 2000
Location: in front of the keyboard
Status:
Offline
|
|
Originally Posted by wataru
Yeah but then I still have to parse it more carefully than a simple "network-status=up" or something. Plus a physical connection doesn't necessarily mean an internet connection, which is what I really want. (No, I didn't really specify that before. Sorry.)
You can't possibly know if you have an internet connection unless you attempt to connect and it either works, or times out.
You can be connected to a private lan, and ifconfig will show the link status, but you still wont have an internet connection.
|
signatures are a waste of bandwidth
especially ones with political tripe in them.
|
|
|
|
|
|
|
|
Forum Regular
Join Date: May 2000
Status:
Offline
|
|
seems like you should just do a ping to www.google.com and see if it responds
|
|
|
|
|
|
|
|
|
Addicted to MacNN
Join Date: Oct 2001
Location: Yokohama, Japan
Status:
Offline
|
|
Actually I'm doing host www.google.com, but the result is similar
|
|
|
|
|
|
|
|
|
Professional Poster
Join Date: Apr 2001
Location: Asheville, NC
Status:
Offline
|
|
Originally Posted by wataru
Depending on where your DNS server is located, a successfully name resolution doesn't necessarily mean you are on the internet. For example: if the DNS server is the router, but the routing functionality has failed, you will still be able to do name resolution, but you won't be able to ping, as those packets will be dropped.
|
ACSA 10.4/10.3, ACTC 10.3, ACHDS 10.3
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Sep 2000
Location: in front of the keyboard
Status:
Offline
|
|
Hehehe.....Detrius, that's a pretty contrived situation, eh?
But, more likely is that you had full connectivity, and lookupd has cached the results, and at some later point you no longer have connectivity, but the name will still resolve due to the cached value.
So, that's two ways that using host isn't the best option for checking realtime internet connectivity.
|
signatures are a waste of bandwidth
especially ones with political tripe in them.
|
|
|
|
|
|
|
|
Addicted to MacNN
Join Date: Oct 2001
Location: Yokohama, Japan
Status:
Offline
|
|
Ok, ok, I'll use ping. You guys are pushy
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|