Skip to main content
Question

Deleting USB Network Interfaces

  • July 24, 2017
  • 3 replies
  • 26 views

Forum|alt.badge.img+3

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.

3 replies

Forum|alt.badge.img+15
  • Contributor
  • July 24, 2017

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

Forum|alt.badge.img+6
  • Contributor
  • June 28, 2018

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"


Forum|alt.badge.img+6
  • Contributor
  • June 28, 2018

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