How to specify DNS server with USB hotspot?
A combination of two problems: (1) Either my Mac or my iPhone has a Wi-Fi problem; and (2) the cell provider's DNS servers have issues.
Because of the second problem, I explicitly specify other servers for the iPhone Wi-Fi. But due to the first, I use the USB connection.
When the Mac thinks (right or wrong) that the Wi-Fi signal has disappeared, the USB connection remains good, but I can't reach web servers (except through Tor, which won't let me log in to S.E.) and mail has frequent failures.
The GUI lets me specify DNS servers explicitly for each Wi-Fi SSID or Bluetooth pair (but Bluetooth won't stay connected--again, I don't know whether it's the Mac or the phone).
But the GUI has no DNS settings for the USB connection, and I have not been able to find one in the 'defaults' settings. I could (maybe) use ipfw or iptables to redirect DNS queries but that would be a bit of a nuisance. Any other solution?
(Yeah, another cell provider, but Peru doesn't have many and I hate to toss what cost 120 soles on the hope that another is better.)
I suspect the wireless issues are in the Mac, because the iPad works much better. However, on the iPad, it frequently quits, but a quick off-and-on of both devices brings it back, while when the Mac Wi-Fi connection drops, it's gone for a long time. The phone SSID doesn't appear on the menu.
Another oddity is with rebooting the iPhone:
Rebooting the iPhone gets the SSID to show up in the Wi-Fi list, but the Mac fails to connect.
Rebooting the iPhone gets mail working again, but web browser still can't find hostnames.
Solution 1:
The answer seems to be
sudo networksetup -setdnsservers "iPhone USB" address address …
For more details, see How can I quickly change DNS server