I got sick of trying to cope with Apple's ever changing interface names for Ethernet and other network interfaces. For example I know of the following for Ethernet:
Ethernet
Ethernet 1
Ethernet 2
USB Ethernet
Thunderbolt Ethernet
and so on.
So I wrote a script that was configurable and would do a lot of the hard work for you. Simply specify an interface name such as "Ethernet", the DNS and Search Domain addresses and the script will hunt round for any interface that has "Ethernet" in the name and apply the settings.
Parameter 4: Network Service Name
Parameter 5: Search Domain 1
Parameter 6: Search Domain 2
Parameter 7: DNS Address 1
Parameter 8: DNS Address 2