How to disable/disconnect ethernet adapter USB type using Network Framework API for Mac

I have tried

networksetup -setnetworkserviceenabled "USB 10/100/1000 LAN" on networksetup -setnetworkserviceenabled "USB 10/100/1000 LAN" off

and same with ifconfig cmd

sudo ifconfig <interface> down sudo ifconfig <interface> up

I am able to bounces the interfaces with these commands but the network connectivity is not restored properly for USB 10/100/1000 LAN interface

May I know is there any other way we can achieve this programmatically using network framework API available for Mac

I don't know what "bounces the interfaces" means.

You seem to be saying

"my <insert brand here> USB to Ethernet adapter does not come up properly after the I use the networksetup or ifconfig commands to bring it down then back up again"

have you tested whether similar commands produce the right response from the same hardware on another platform? This might be a problem with the off-brand hardware, rather than the commands provided by macOS.

May I know is there any other way we can achieve this programmatically using network framework API

Network framework is not involved in configuring networking interfaces. Rather, that work is done with the System Configuration framework and its underlying infrastructure (configd and its various plug-ins).

IMPORTANT That infrastructure ‘owns’ the interface configuration. If you modify the interface state using lower-level tools, like ifconfig, your changes will most likely be overwritten by configd the next time it works with the interface.

The standard System Configuration framework docs are rather minimal but there’s a good introduction in the Documentation Archive: System Configuration Programming Guidelines.

The networksetup tool uses System Configuration framework internally.

As to your specific question, it’s hard to give you answers without more information about your high-level goal. Please clarify.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Our requirement is to disable and enable the ethernet interface using API or commands so that RADIUS request is triggered. When a client is connected to wired network using USB Ethernet Adaptor, and we disable/enable the USB Ethernet Adaptor using ifconfig command and other commands as mentioned in the ticket then interface status changes but RADIUS request is not triggered.

I have tried with System Configuration methods Fetched the service and then disable and enabled using SCNetworkServiceSetEnabled API. Here also interface connects back but RADIUS request is not triggered.

If we manually do it for USB Ethernet adaptor from SystemSettings->Network then interface bounces and RADIUS request is also generated.

we are trying to achieve similarly using commands or other methods available in macOS.

Our requirement is to disable and enable the ethernet interface using API or commands so that RADIUS request is triggered. When a client is connected to wired network using USB Ethernet Adaptor, and we disable/enable the USB Ethernet Adaptor using ifconfig command and other commands as mentioned in the ticket then interface status changes but RADIUS request is not triggered.

I have tried with System Configuration methods Fetched the service and then disable and enabled using SCNetworkServiceSetEnabled API. Here also interface connects back but RADIUS request is not triggered.

If we manually do it for USB Ethernet adaptor from SystemSettings->Network then interface bounces and RADIUS request is also generated.

we are trying to achieve similarly using commands or other methods available in macOS

How to disable/disconnect ethernet adapter USB type using Network Framework API for Mac
 
 
Q