The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 2,422 other followers

Archive for the ‘Apple’ Category

Some links on getting MacOS network interfaces and DHCP information

Posted by jpluimers on 2021/07/30

One day I’ll put this in a script that shows all DHCP information for all network interfaces.

For now some links I will need when writing that script.

Many of the below commands are also in [WayBack] Command-Line Tools: The Missing Manpages (Mac OS X for Unix Geeks).

Shows all interfaces:

networksetup -listallhardwareports

Show any DHCP server on any interface (but does not list interfaces):

system_profiler SPNetworkDataType | grep "Server Identifier"

  • [WayBack] Find the IP address of your DHCP server. – Apple Community

    Other options would be:

    system_profiler SPNetworkDataType | grep "Server Identifier"

  • [WayBack] Crabeater: Stateful Parser in Python

    I came up with a method for parsing the output of system commands that require knowledge of previous lines to provide context. An example of this is parsing the MAC addresses for interfaces on a Mac running OS X Leopard using the system_profiler command. The output of the command has various levels of sections. The first level of section headers aren’t indented at all. The next level is indented four spaces and the next six spaces.

    For this task I want to parse out the interface names, which are indented four spaces, but there are plenty of similar subsection headers that are not interfaces. The context I need is whether or not the current line is in the Network section.

    I came up with a way to implement this where the Parser is a class and has an instance variable named “state” that holds the correct method to use to parse the next line.

    Notice that h2Pattern matches any subsection header, but I only use it to match a line if the line is inside the Network section (i.e. it is only used inside the network method.)

 

Read the rest of this entry »

Posted in Apple, Mac OS X / OS X / MacOS, macOS 10.13 High Sierra, Power User | Leave a Comment »

Listing information on all active interfaces on MacOS part 1: getting the active interface names

Posted by jpluimers on 2021/07/29

Listing Listing information on all active interfaces on MacOS is a process involving multiple pieces, which then can be combined together.

Listing all active interfaces try 1

This involves both the -l (list with optional criteria) and -u parameter (the up criterion) as per excerpts from the [Archive.is] ifconfig(8) [osx man page] / [WayBack] ifconfig Man Page – macOS – SS64.com:

NAME
     ifconfig -- configure network interface parameters

SYNOPSIS
     ...
     ifconfig -l [-d] [-u] [address_family]
     ...

DESCRIPTION
     The ifconfig utility is used to assign an address to a network interface and/or configure network interface parameters.

     The following options are available:

     ...

     address_family
             Specify the address family which affects interpretation of the remaining parameters.  Since an interface can receive transmissions
             in differing protocols with different naming schemes, specifying the address family is recommended.  The address or protocol fami-
             lies currently supported are ``inet'', ``inet6'', and ``link''.  The default is ``inet''.  ``ether'' and ``lladdr'' are synonyms
             for ``link''.

     ...

     The -l flag may be used to list all available interfaces on the system, with no other additional information.  Use of this flag is mutually
     exclusive with all other flags and commands, except for -d (only list interfaces that are down) and -u (only list interfaces that are up).

Example:

ifconfig -l -u

Each interface on one line:

ifconfig -l -u | xargs -n1 echo

The problem is that on my system, it also lists bridges as active, whereas they are not:

# ifconfig -l -u | xargs -n1 echo
lo0
en1
en2
en0
p2p0
awdl0
bridge0
utun0
en10

# ifconfig bridge0
bridge0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
    options=63<RXCSUM,TXCSUM,TSO4,TSO6>
    ether 6a:00:02:9a:23:f0 
    Configuration:
        id 0:0:0:0:0:0 priority 0 hellotime 0 fwddelay 0
        maxage 0 holdcnt 0 proto stp maxaddr 100 timeout 1200
        root id 0:0:0:0:0:0 priority 0 ifcost 0 port 0
        ipfilter disabled flags 0x2
    member: en1 flags=3<LEARNING,DISCOVER>
            ifmaxaddr 0 port 5 priority 0 path cost 0
    member: en2 flags=3<LEARNING,DISCOVER>
            ifmaxaddr 0 port 6 priority 0 path cost 0
    Address cache:
    nd6 options=201<PERFORMNUD,DAD>
    media: 
    status: inactive

So this is where the MacOS and BSD documentation is inaccurate.

Interface types

The above interfaces are many more than just ethernet or WiFi interfaces; there is a list at [WayBack] macos – What are en0, en1, p2p, and so on, that are displayed after executing ifconfig? – Stack Overflow by [WayBackmcint:

In arbitrary order of my familarity / widespread relevance:

lo0 is loopback.

en0 at one point “ethernet”, now is WiFi (and I have no idea what extra en1 or en2 are used for).

fw0 is the FireWire network interface.

stf0 is an IPv6 to IPv4 tunnel interface to support the transition from IPv4 to the IPv6 standard.

gif0 is a more generic tunneling interface [46]-to-[46].

awdl0 is Apple Wireless Direct Link

p2p0 is related to AWDL features. Either as an old version, or virtual interface with different semantics than awdl.

many VPNs will add additional devices, often “utun#” or “utap#” following TUN/TAP (L3/L2)virtual networking devices.

More on AWDL at [WayBack] ios – What is AWDL (Apple Wireless Direct Link) and how does it work? – Stack Overflow.

Listing all active interfaces try 2

Read the rest of this entry »

Posted in *nix, *nix-tools, Apple, bash, Development, ifconfig, Mac OS X / OS X / MacOS, Power User, Scripting, Software Development | Leave a Comment »

Listing information on all active interfaces on MacOS part 2: adding DHCP/BOOTP and routing details

Posted by jpluimers on 2021/07/27

This is a continuation of yesterdays

Listing information on all active interfaces on MacOS part 1: getting the active interface names.

It is based on ideas in these StackExchange posts:

I threw most of the implementation details in the ideas away, as they were way to much based on empirical trial and error, than proper research.

So I tried doing the research and came up with the things below.

Getting the IPv4 address and DHCP/BOOTP information of a NIC

By using the ipconfig command, you can get specific details for a NIC like an IPv4 (with the getifaddr) or DHCP (with the getpacket option to get the latest DHCP packet):

for i in $(ifconfig -l -u); do if ifconfig $i | grep -q "status: active" ; then echo $i; fi; done | xargs -n1 -I_nic_ sh -c 'echo "_nic_: $(ipconfig getifaddr _nic_)"'

or DHCP/BOOTP:

for i in $(ifconfig -l -u); do if ifconfig $i | grep -q "status: active" ; then echo $i; fi; done | xargs -n1 -I_nic_ sh -c 'echo "_nic_: $(ipconfig getpacket _nic_)"'

The latter returns a very long list, which I wanted to shorten into a more readable format.

ipconfig syntax

You can find more information in the [Archive.is] ipconfig(8) [osx man page] / [WayBack] ipconfig Man Page – macOS – SS64.com excerpt:

Read the rest of this entry »

Posted in *nix, *nix-tools, Apple, bash, Development, ifconfig, Mac OS X / OS X / MacOS, Power User, Scripting, Software Development | Leave a Comment »

How to toggle finder’s “Keep Both” vs. “Skip”, and when copying or moving files – why does the “default” seem to change?

Posted by jpluimers on 2021/07/02

Based on:

Via macos “keep both” versus “skip” – Google Search

When copying or moving files on MacOS using the Finder, sometimes you get a popup with chooses “Skip”, “Stop”, “Replace”, but at other times “Keep Both”, “Stop”, “Replace”.

Empirically:

  • “Keep Both” happens with less than 5 duplicate file names
  • “Skip” happens with 5 or more 5 duplicate file names
  • The “Alt” or “Option” key toggles between “Keep Both” and “Skip”
  • This was introduced around OS X 10.8 Mountain Lion, as it used to be always “Keep Both” in all Mac OS X versions up to and including Mac OS X 10.7 Lion. The new behaviour has stayed in all OS X and macOS versions since.

–jeroen

Posted in Apple, Mac OS X / OS X / MacOS, Mac OS X 10.7 Lion, macOS 10.12 Sierra, macOS 10.13 High Sierra, OS X 10.10 Yosemite, OS X 10.11 El Capitan, OS X 10.8 Mountain Lion, OS X 10.9 Mavericks, Power User | Leave a Comment »

Need to figure uit: MacOS High Sierra suddenly holding a key down does not produce an accented character any more

Posted by jpluimers on 2021/06/21

Logging on as a different user, holding a vowel key produces a small menu with accented characters.

Inspecting the keyboard preferences for both users did not show obvious differences.

On my list to figure out if it ever happens again.

These links might help me then:

This failed me on a few  occasions so far.

Sometimes a reboot is required. Sometimes quitting the most memory hungry applications, then restarting them (Chrome! Microsoft Remote Desktop!) re-enables it.

Related twitter thread below.

Learned new shortcut Command+Option+Space: shows the character viewer:

More of these at [WayBack] Mac keyboard shortcuts – Apple Support

There I learned about these Sleep, log out, and shut down shortcuts:

You might need to press and hold some of these shortcuts for slightly longer than other shortcuts. This helps you to avoid using them unintentionally.

  • Power button: Press to turn on your Mac or wake it from sleep. Press and hold for 1.5 seconds to put your Mac to sleep.* Continue holding to force your Mac to turn off.
  • Option–Command–Power button* or Option–Command–Media Eject : Put your Mac to sleep.
  • Control–Shift–Power button* or Control–Shift–Media Eject : Put your displays to sleep.
  • Control–Power button* or Control–Media Eject : Display a dialog asking whether you want to restart, sleep, or shut down.
  • Control–Command–Power button:* Force your Mac to restart, without prompting to save any open and unsaved documents.
  • Control–Command–Media Eject : Quit all apps, then restart your Mac. If any open documents have unsaved changes, you will be asked whether you want to save them.
  • Control–Option–Command–Power button* or Control–Option–Command–Media Eject : Quit all apps, then shut down your Mac. If any open documents have unsaved changes, you will be asked whether you want to save them.
  • Shift-Command-Q: Log out of your macOS user account. You will be asked to confirm. To log out immediately without confirming, press Option-Shift-Command-Q.

* Does not apply to the Touch ID sensor.

–jeroen

Read the rest of this entry »

Posted in Apple, Mac OS X / OS X / MacOS, macOS 10.12 Sierra, Power User | Leave a Comment »

 
%d bloggers like this: