Use Unix / Linux commands to check your Android’s Internet connection.
If your Android web browser can’t display your favorite sites, the device may have lost its IP connection to the Internet. You can check this by using three simple Linux commands. (Android is built upon a Linux foundation.) This requires five steps:
- Install the Terminal Emulator app. (You’ll find Terminal Emulator within the Google Play Store on your Android desktop.)
- Run Terminal Emulator. Enter the command netcfg (and press Enter). Your current IP address will be displayed in the third column for one of the devices in the first column. On my phone, the Internet interface device is pdp0 (the bottom line in the first screenshot). The fourth column displays your subnet mask.
- The command netstat -rn will display each active communication session: protocol, bytes in transmit and receive queues, your IP address, a colon followed by the active port, and the IP address and active port of the host with which you’re communicating.
- Again, run Terminal Emulator. Type the command ping 22.214.171.124 (and press Enter). Internet node 126.96.36.199 (which is a Google DNS server) should reply. TTL is Time To Live — the number of hops remaining in the packet. Time is the number of milliseconds required for a packet to traverse the route to and from 188.8.131.52. If you’re not connected, you’ll see a message such as Network is unreachable.
- Finally, let’s make certain that you have DNS (Domain Name Service). Run Terminal Emulator once more. Type the command ping www.amazon.com (and press Enter). If your DNS worked and you have IP connection, Amazon’s server will reply.
This works on my stock T-Mobile Samsung SGH-T679 phone running Android 2.3.6. I have not rooted it, yet. There may be better ways to check Internet connectivity on Android devices. I’m new to Android and still a novice, though I first installed Linux circa 1993. If you know of a better method, please advise me. I wrote this article on my Android phone; it was a struggle, especially when trying to copy and paste. Any text editing suggestions?
On my phone, I can abort the pings and return to the command prompt by simultaneously pressing the Volume Down button (on the left edge of the phone) while pressing the Z key on the keyboard. This simulates a Ctrl-Z key sequence from a full-size keyboard.
Restore your last command
To restore your previous command to the command line, press the Volume Down button (on the left edge of the phone) while pressing the P key on the keyboard. This simulates a Ctrl-P key sequence from a full-size keyboard. You can backspace to edit the command. Press Enter to execute the command.
Can’t connect to your mobile phone carrier?
You first need to connect to your carrier’s nearest cell site. Here’s how: Re-connect Android to the Internet
Having trouble reaching one or more hosts?
Use Android’s traceroute command to discover where your packets stop enroute to their destination.