I have a network setup where a Raspberry Pi is connected to a switch (not a router). I then connect my laptop to the same switch, and I then want to start an SSH session with the Pi. I would also want to do FTP or SCP to the Raspberry Pi for deploying scripts.
How would I find the IP address assigned to the Raspberry Pi and my laptop, and could I use that information to do SSH connections to the Pi?
43 Answers
There's quite a few scenarios here.
If you have a standard consumer router also connected to this switch, it should have a built-in DHCP server that assigns IP addresses. You can also usually configure static mappings from there, and they will also frequently resolve hostnames via their built-in DNS caching server.
If you only have these two devices connected to the switch and no DHCP server (or consumer router containing one), you can:
- Use link-local addresses
- Or, manually assign static IP addresses (picked from the same RFC1918 subnet) on each device
- Or, set up a DHCP server
Link-local addresses, especially with IPv6, may "just work". IPv6 interfaces should always have a link-local address. You can look for the address within your network configuration on each device. On Linux, the ip addr show command may help. On Windows, ipconfig /all. The syntax for connecting to one may be a bit funny.
A link-local/APIPA IPv4 address from 169.254.0.0/16 address may also work. Windows will assign one automatically if it does not receive an address from manual config or DHCP. Linux might not, depending on your network stack - look at Avahi.
Note that link-local and DHCP-assigned addresses are not "stable" - they can change, especially when you re-connect to the network. You may wish to also use a name service like NetBIOS/LLMNR, mDNS (Bounjour), etc., to enable you to discover these addresses by hostname.
In most Linux distros, you can find your IP address by typing the following in bash:
ip addressYou will see all your network adapters and IP addresses. Most routers assign IPs in the 192.168.x.x range.
It definitely sounds like you didnt install the OpenSSH server, so you will need to install and start it with:
sudo apt install openssh-server; sudo service ssh startThen you can SSH into your Pi with a SSH client from your laptop.
2This can be done without using a switch. First plug your mac directly to your Pi via Ethernet without a switch. On your Mac, go to System Preference -> Sharing, and enable Internet sharing To Computer Using whatever your ethernet port is (mine is a USB LAN). Now on the Pi check IP Address and you should see one that you can ssh into.