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"