Thursday 1 November 2018

networking - Directly connect MacBook to Linux desktop via ethernet for fast SSH?


I am looking at building a Linux desktop—desktop only; no monitor support—and getting a MacBook Pro as my main computer for mobility. I would like—while I am at the office—to basically use my MacBook as my keyboard and main monitor, hook up another monitor or two to it and then SSH into my Linux console for my coding, etc.


Is it possible to directly connect my MacBook Pro to the Linux box via Ethernet? Or will I have to go through the building’s wired connection and then back into my Linux box?



Answer




Is it possible to directly connect my MacBook Pro to the Linux box via Ethernet?



Yes, you can directly connect systems via Ethernet. What you would do is on the Linux box you would assign a static IP address in /etc/network/interfaces something like this:


# The local hostmachine access interface.
auto eth1
iface eth1 inet static
address 192.168.99.10
netmask 255.255.255.0

Reboot your machine and now the eth1 physical port will have the IP address of 192.168.99.10.


Now on your Mac, hook up the Ethernet cable and set the network connection to the following IP address:


192.168.99.20

And set the “Subnet Mask” to 255.255.255.0 as well.


Then you will have a magical “two computer network” where the Linux machine has the IP address of 192.168.99.10 and your Mac’s Ethernet port has 192.168.99.20.


And to make your life even easier you can add the Linux equivalent of Bonjour broadcast networking by installing the Avahi daemon. On Ubuntu you would install it like this:


sudo aptitude install avahi-daemon avahi-utils

Then after it installs wait a second or two and on your Mac you will be able to reach the Linux box via it’s hostname. So let’s say your Linux box has a hostname of “LinuxDesktop” with Avahi installed it could be reached via the address of LinuxDesktop.local. And if you pinged LinuxDesktop.local it would return 192.168.99.10.


Now the big “gotcha” here is the actual network address scheme. I am using 192.168.99.x because typical LAN network addresses have the 192.168.x.x prefix octet. But in some cases it might be better for you to go with a 10.x.x.x address. What determines what is “better” is what address range your actual network outside of this Ethernet cable operates on. You basically do not want conflicts. Create a network address range for this Ethernet cable-based network based on an IP range your LAN—or even WAN—is not using.


But honestly, I am pretty sure addresses in the 192.168.99.x range will be fine.


No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...