Posted on 11-17-2017 06:55 AM
Hi,
I try to disable any usb, usb-c, or other ways of ethernet and temperately disable it. let wifi run. and then reactive when I finish my script.
any way to find out active ethernet adapter and disable it?
thanks!
Solved! Go to Solution.
Posted on 11-17-2017 07:24 AM
but even just change the service order, you need to know the name for the adapter?
actually I just found out how to do it:
a=$(networksetup -listnetworkserviceorder |grep 'Hardware Port' |grep '10/100' |grep -o '....$' |cut -c 1-3)
sudo ifconfig $a down
and later when I want it back, I use
sudo ifconfig $a up
maybe this long command can be simplify :)
Posted on 11-17-2017 07:11 AM
I think this is going to be rather tricky. Primarily because it seems that each new adapter creates a new service.
Do you need to actually disable it? Can you just change the service order?
Regards
TJ
Posted on 11-17-2017 07:15 AM
However, if you need to do it.
What you're probably looking for is:sudo networksetup -listallnetworkservices
sudo networksetup -setnetworkserviceenabled
example: sudo networksetup -setnetworkservice "Belkin USB-C LAN" off
Posted on 11-17-2017 07:24 AM
but even just change the service order, you need to know the name for the adapter?
actually I just found out how to do it:
a=$(networksetup -listnetworkserviceorder |grep 'Hardware Port' |grep '10/100' |grep -o '....$' |cut -c 1-3)
sudo ifconfig $a down
and later when I want it back, I use
sudo ifconfig $a up
maybe this long command can be simplify :)
Posted on 11-17-2017 07:24 AM
@tthurman we are thinking on the same route! haha
Posted on 03-02-2020 07:01 PM
With the newer version of macOS, you might have to change '10/100' to 'Ethernet' to have the script work.