قالب وردپرس درنا توس
Home / Apple / macos – Unable to connect to the Internet in bash using Mac OS

macos – Unable to connect to the Internet in bash using Mac OS



I prefer to use the System Configuration Tool to test for reachability instead of using ping / host / nslookup or another proxy to determine if a network device is or is not available.

  scutil -r google.com
reached

The benefits of this are that if you have VPN connections, you can call, modem or a routing conflict. This will actually test that you can reach the device and not just solve the cached host name, etc … in my experience. (it is also much harder to destroy the indirect, files, logic and you get a direct answer back in English)

Like any good command line tool, it returns 0 to tell you the answer it gives is safe and a mistake if you have problems testing the availability.

   -r [-W] {node name | address | local address remote address}
Check the network availability of the specified host name, IP
address, or a few local and external IP addresses. One or more of
The following strings are reported to the default output.

Not available. The specified node name / address cannot be
reached by current network configuration
tion.

Reachable The specified node name / address can be reached
uses the current network configuration.

Connection Connection The specified node name / address can be reached
via a transient (eg PPP) connection.

Connection required The specified node name / address can be reached
uses the current network configuration, but a
The connection must first be established. As
For example, this status will be returned for one
dial-up connection that was not currently active
but could handle network traffic for the target
system.

Connection Automatic The specified node name / address can be reached
uses the current network configuration, but a
The connection must first be established. Some
traffic directed to specified name / address
will start the connection.

Local address The specified node name / address is an associated one
with a network interface on the system.

Directly accessible addresses
Network traffic to the specified node
name / address will not go through a gateway, however
is sent directly to one of the interfaces on
system.

The reachability can also be monitored by specifying -W (see)
option. This will result in the current status being reported as
and status when / if the network configuration changes.

A zero output status will be returned when the current status is
reported correctly. A non-zero status will be returned if
Errors are detected with an error reported to standard error.

Since Apple's manual page index is a PITA to use, here's a hopefully more stable link to the entire manual page on the web: https://ss64.com/osx/scutil.html

As a bonus ̵

1; here is another decent question about the scutil and control solution:
nslookup & digs fail; ping, traceroute and scutil-r ​​work


Source link