Use common network commands to view current network status--mac OS x

Source: Internet
Author: User



Reprinted from: http://blog.csdn.net/zkh90644/article/details/50539948









The operating system has a common set of utilities to determine the connectivity of the local host's wired or Wireless Link state and IP. If the machine has an IP connection, then it means that wired or wireless is working properly. In the Mac OS x system, there are several useful programs to confirm the connection status:
ifconfig: Find the native IP address and network interface.
netstat: use-R to find the default gateway for a particular network interface.
Ping: used to test the end-to-end IP connection between the machines.
ARP: manages the local ARP cache.



The following are examples of connection states and IP connections:


  1. Open Terminal(translator attached: can be via Spotlight or utilities-- terminal ")
  2. Enter the ifconfig command to find the IP address of a specific network interface. In this example, the address of this wireless network interface (EN1) is: 192.168.128.253.
  3. Myhost:/usr/bin someuser$ Ifconfig
    en1:flags=8863 (Up,broadcast,smart,running,simplex,multicast)
    inet 192.168.128.253 netmask 0xffffff00 broadcast 192.168.128.255
    Ether 00:17:f2:e8:ac:0a
    Media:autoselect status:active
    Supported Media:autoselect

  4. Enter Netstat-r to find the default gateway for the utility network interface EN1 . In this example, the default gateway address for EN1 is: 192.168.128.1.
  5. Myhost:/usr/bin someone$ Netstat-r
    Routing tables
    Internet:
    Destination Gateway > Flags Refs use netif Expire
    Default 192.168.128.1 > UGSC 2 en1

  6. The data of the local area network interacts on the 2nd layer of the OSI model (the Data Link layer ). Host in the same LAN to send data to the local area network users to use the second layer of address (ie MAC address ), each host has a dynamic MAC address into the list of IP addresses mapped to the arp table , the table is through the ARP protocol to find which MAC address corresponds to which IP address in the LAN (the IP address is in the third layer of the OSI Network layer). ARP is very detailed, and many of its contents are removed in order to Better express ARP. The following is a brief introduction to ARP:
  7. Each time a host needs to send data to another host, he checks the native ARP table, and if there is an associated mapping in the ARP table, the data is sent directly to the MAC address of the IP address. If there is no mapping, in order to obtain the MAC address of the IP address that receives the data, the native will send an ARP request to broadcast to the local area network to see all the IP addresses in the known LAN. When the host that corresponds to the IP address receives this ARP request, the ARP response message is sent to the requester in a unicast manner, telling the requester its own IP address and its associated MAC address. When the requester receives the ARP response message, it updates its ARP table and sends the frame directly to the destination host using its own MAC address. To prevent the ARP cache from aging, the host will frequently send ARP requests to update its own ARP cache.

  8. In order to manually re-refresh your arp table using Terminal (terminal) , we use the following command:
  9. Mycomputer:/usr/bin someuser$ arp-d-A

  10. Ping the default gateway or the IP address of another host on the LAN to test the connectivity of the IP. On Mac OS x, the ping command is continuous (the translator does not use a terminal command, and the ping program does not stop under the default parameters).
  11. Mycomputer:/usr/bin someuser$ Ping 192.168.128.1


If the local connection is the same and the destination host is also online and attainable, you will output each ICMP (Internet Control Message Protocol) echo request to display each ICMP echo reply .



The format is as follows:


PING 192.168.128.1 (192.168.128.1): Data bytes

Bytes from 192.168.128.1:icmp_seq=0 ttl=64 time=3.255 ms
Bytes from 192.168.128.1:icmp_seq=1 ttl=64 time=0.897 ms
Bytes from 192.168.128.1:icmp_seq=2 ttl=64 time=0.897 ms
Bytes from 192.168.128.1:icmp_seq=3 ttl=64 time=0.905 ms


7. If the ICMP request times out and is answered by an ICMP echo , it is most likely that there is a problem with the cable between the local host and the destination host, or the destination host is too busy to respond. In this case, you can try to ping the hosts on the other LAN. If the timeout does not exist during the ping process, then the local connection is good and you need to troubleshoot the problem host.
The situation is as follows


PING 192.168.128.1 (192.168.128.1): Data bytes

Bytes from 192.168.128.1:icmp_seq=0 ttl=64 time=3.255 ms
Bytes from 192.168.128.1:icmp_seq=1 ttl=64 time=0.897 ms
Request Timeout for icmp_seq 2
Request Timeout for icmp_seq 3
Bytes from 192.168.128.1:icmp_seq=4 ttl=64 time=0.897 ms
Bytes from 192.168.128.1:icmp_seq=5 ttl=64 time=0.905 ms
Request Timeout for icmp_seq 6







    1. If your connection is good but the other's firewall rejects your ICMP echo request , you are receiving a message that the ICMP request timed out . If the destination host does respond to your ARP request, it means that your local connection is good and the network status is good. Then you should try to shut down the destination host's firewall and send the ping request again, or try to ping one of the other hosts.




PING 192.168.128.1 (192.168.128.1): Data bytes 
Request timeout for icmp_seq 0 
Reque St Timeout for icmp_seq 1 ,
Request timeout for icmp_seq 2 ,
Request timeout for icmp_seq 3 
Request Timeout for icmp_seq 5

      • If the destination host does not respond to an ARP request, or if the destination host is not in the line, you will receive a message like "host is down". This way you need to try to ping other hosts, if you still receive the message "host is down", then it means that your IP address is misconfigured or your uplink is good, but the rest of the LAN is problematic. The possible cause of this problem is improper management of the uplink, VLAN mismatch, and damage to the upstream of the cable.

        PING 192.168.128.1 (192.168.128.1): Data bytes
        Ping:sendto:No Route to host
        Ping:sendto:Host is down
        Ping:sendto:Host is down
        Ping:sendto:Host is down
        Ping:sendto:Host is down

      • If your local connection is problematic, you will receive a "No route to host" message, in which case you need to verify that your adapter is enabled, or re-attach the tea-ether cable (network cable), or restart your wireless connection.

        PING 192.168.128.1 (192.168.128.1): Data bytes
        Ping:sendto:No Route to host
        Ping:sendto:No Route to host
        Ping:sendto:No Route to host
        Ping:sendto:No Route to host
        Ping:sendto:No Route to host


Use common network commands to view current network status--mac OS x


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.