Deleting USB Network Interfaces

Vasean
New Contributor

I recently discovered that my Mac has been creating network connections for every iPad I have prepared with Apple Configurator 2. Now, there are hundreds of connections. I need a way to delete them all/reset network preferences and prevent this from happening again.b3fd19dbc8f445f29ba8a061964d6c67

3 REPLIES 3

thoule
Valued Contributor II

I didn't want to delete my network interfaces so I didn't test. But this should give you enough to do something with... It'll delete any network interface with USB in the name.

#!/bin/sh                                                                                                                                                                                                                                                                                                             
#todd h

IFS=$'
'
networkService=`networksetup -listallnetworkservices | tail -n +2 | sed 's|*||'`

for oneServ in ${networkService[@]}; do
    case $oneServ in
        *USB* )
            echo "found USB in $oneServ.  Deleting"
            networksetup -removenetworkservice $oneServ
            ;;

            *)
            echo "Not a USB interface. Ignoring $oneServ"
            ;;
    esac
done

ryoshioka
New Contributor III

Hey @Vasean , Did you ever find a solution for this? I have the same problem and not into removing them one at a time :(

@thoule , tried your script but it returns "You cannot remove iPhone USB XXX because there aren't any other network services on iPhone USB. Error: The parameters were not valid"

ryoshioka
New Contributor III

Nevermind figured it out, expanded on @thoule 's script. Running the remove on sudo so you only have to authenticate once.

#!/bin/sh

IFS=$'
'
networkService=`networksetup -listallnetworkservices | tail -n +2 | sed 's|*||'`

for oneServ in ${networkService[@]}; do
    case $oneServ in
        *USB* )
            echo "found USB in $oneServ.  Deleting"
            sudo networksetup -deletepppoeservice $oneServ
            ;;

            *)
            echo "Not a USB interface. Ignoring $oneServ"
            ;;
    esac
done