1

I'm trying to connect to a microcomputer from my Mac over WiFi via ssh but am also connected to Ethernet. If I go to System Preferences > Network, I can see that I'm connected to both the Ethernet and WiFi networks simultaneously. I want the Ethernet network to be of higher priority (higher on the list) so that most programs use that connection (e.g., when I open a web browser, it connects via the Ethernet network). However, I want to be able to open the terminal and ssh to the microcomputer over the WiFi network that I'm also connected to.

I know that both connections can be used simultaneously because I can make it work with this order of operations:

  1. Disconnect from the Ethernet network by physically removing the Ethernet jack from the Mac (now WiFi to the other microcomputer is the only connection in System Preferences > Network).
  2. ssh from the Mac to the address of the microcomputer
  3. Reconnect to Ethernet by plugging the Ethernet cable back into the Mac. Now I can see communicate with the microcomputer over the ssh connection I established in step 2 but can also use the Ethernet network for all other programs.

I don't like this process because I frequently need to disconnect and reconnect to the ssh connection. I'd prefer to be able to keep my Ethernet cable connected to my Mac but still be able to ssh over the WiFi network.

The ideal solution is that there flag I can pass to the ssh command to specify that I want to use the WiFi connection to perform the ssh rather than the Ethernet connection. What is the easiest way to do this from the terminal?

2 Answers 2

0

It sounds like you're running into issues because you essentially end up with a misconfigured IP network.

Typically a home network with an internet connection uses IP addresses on the form of 10.x.x.x, 192.168.x.x or 172.16.x.x. Your home network would be setup with a so called "subnet mask", which specify how large parts of those x's that are actually part of your home network.

When you add the microcomputer to the mix, it comes with its own network setup. Because you mention these difficulties, it seems you have an overlap in two networks now. I.e. both your ordinary home network and your microcomputer network use IP addresses on the same "form" (such as 192.168.x.x) with subnet masks that makes these two networks overlap.

You can fix this in two ways:

  1. Change the network configuration so that you do not have overlapping, separate networks.

or

  1. Use a work-around to let SSH connect via the microcomputer-connected network interface

For option 1, how you do this is dependent on what kind of network equipment you use, what kind of microcomputer it is, etc. The general idea is though to make sure the networks are non-overlapping. For example if you use 10.x.x.x addresses on both networks, then make sure that one uses 10.0.x.x and the other 10.1.x.x addresses for example. The subnet mask should reflect that so that instead of having a mask of 255.0.0.0 for example, it would be 255.255.0.0 or similar.

For option 2, the work-around, you can actually specify to ssh that you want to connect via a specific network interface (i.e. the WiFi). If your WiFi interface is en1 and you usually connect to the microcomputer on IP 192.168.1.1, that command would look something like this:

ssh -B en1 [email protected]
2
  • 1
    The second option was exactly what I was looking for, thanks! Writing this for anyone else like me who isn't too familiar with WiFi settings/protocols, etc.: I had to go into the System Information... (⌥ > ) menu then to Network > Wi-Fi. I then found the name of my microcomputer WiFi address and the channel is the number that I had to modify. So in my case it was ssh -B en0 [email protected] since the channel was 0.
    – none
    Nov 30, 2022 at 17:06
  • So your WiFi network and Ethernet network have different subnets? Typically when I’ve encountered your scenario it’s always been the same subnet (both WiFi and Ethernet acquire dhcp address from the same dhcp server in the same subnet.) Nov 30, 2022 at 17:44
0

Having a WiFi network and Ethernet network connected to the same local area network is not supported. You may be able to make it work marginally, but that isn't going to work reliably and will produce the same symptoms you have now.

To make this work, you would need two things:

  • Two separate networks (one LAN for WiFi and one LAN for Ethernet) with different IP addresses.
  • You will need to limit use of DHCP to only one of the two connections, specifically the one you wish to reach the Internet via. The other connection should be hardcoded with a static IP address.
3
  • 1
    This is not correct. There's nothing about having WiFi + Ethernet connected to the same LAN that is "not supported". You also do not need separate networks with different IP ranges. There's also no requirement that only one of them be configured with DHCP.
    – jksoegaard
    Nov 30, 2022 at 8:02
  • While your comment is 100% true, it ignore ARP issues bouncing between Ethernet and WiFi depending on ARP timeouts and default routing issues when two network interfaces are the exact same LAN with the same subnet. That was the basis for my answer. Nov 30, 2022 at 17:46
  • But that is the not the correct basis as he most definitely do not have both network interfaces on the same LAN. He has two separate networks - one with his other devices and internet connection, and one with just the microcomputer.
    – jksoegaard
    Nov 30, 2022 at 20:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .