SSH into Raspberry Pi running OpenWrt

Hi everyone,

I have installed the latest OpenWrt firmware on a Raspberry Pi 4, and now I am struggling to configure the network settings.

I am aware that the default IP address of the Raspberry Pi running OpenWrt is 192.168.1.1, but the issue is I cannot SSH into it if I connect it to the router because my default gateway IP (Router IP) is also 192.168.1.1

Even though changing the IP of the router and then SSH into Raspberry Pi via 192.168.1.1 is a solution, I am looking into a different solution where I can set a different static IP address for the Raspberry Pi by doing any sort of configuration to the files inside the SD card that I insert into the Raspberry Pi.

This is what I see inside the boot(E:) drive:

Best Regards,
Lakshantha

Do not connect the Pi to your main network at first.

To use the Pi as a LAN device you need to change its IP address to one that is within the network you're going to connect to, but not already in use.

Also very important you need to turn off the DHCP server which OpenWrt has set up by default, both IPv4 and IPv6.

This is straightforward to do by booting the Pi not connected to anything but the PC, then ssh in to 192.168.1.1. Make the changes and reboot and connect to your network.

If you're using the ext4 build you can mount the root filesystem on another Linux PC and edit the files /etc/config/network and etc/config/dhcp. These are on the second partition of the card, which is ext4 format which is a type of filesystem that Windows does not recognize.

2 Likes

connect the computer to the pi, separated from the router ?
change the IP of the Pi, connect everything back as normal ....

1 Like

@mk24 @frollic appreciate the quick responses!

I have tried connecting the Raspberry Pi directly to the PC via Ethernet but for some reason I fail to connect to it.

3ba73e51a1f5eff918d06c3eec98ad7

Also tried to ping 192.168.1.1 and this is the response:
59ebd848ca9e97728fa9ef17f1bbe2d

Am I missing something?

Best Regards,
Lakshantha

You need to be on the same subnet, and probably set the IP manually in your pc, .2 should work.

In worst case, put a switch between the two, even though the ports should be auto sensing.

1 Like

@frollic
I have done the following on my PC:
Capture

But still no luck to connect.

Are the settings correct?

Unfortunately I don't have access to a switch.

Yes

Looks correct to me.

Are you sure your RPI booted, attach it to a monitor.

1 Like

What you 'see' is only the boot partition, where the kernel and initrd (initial ramdisk, used to start-up the system) resides.

First step : setup your Windows host with a static ip address with something in the range 192.168.1.2-254 (192.168.1.1 already in use by PI)

https://kb.netgear.com/27476/How-do-I-set-a-static-IP-address-in-Windows

Then you can access the GUI web interface
Technically you can use an ssh connection with a terminal client like putty but you need to know the linux command line... not the simplest way

PING 192.168.1.1 MUST give a response, if DOESN'T something goes wrong, doublecheck and try again

Second step : change Raspberry ip address from 192.168.1.1 to something unused on your LAN
Third step : disable DHCP server on the PI ethernet connection (to avoid conflict with the router)

Fourth step : remove static ip address from your Windows host and use dhcp again

@frollic My RPI is booted and tried to attach to a monitor and it works fine that way.

Then I changed the IP address of the Raspberry Pi to 192.168.1.3, while disabling the DHCP server as well. After that, I connected the Raspberry Pi to my router and was able to SSH into it.

Thank you for your response.

@Fleur thank you for your explanation. I think I cannot directly connect my Raspberry Pi to computer via Ethernet because of two possible reasons:

  1. Raspberry Pi looking into DHCP server at first and it's unable to connect to one (maybe PC have to be on same subnet as Raspberry Pi as @frollic mentioned before)
  2. Using Straight through cable for the connection. Crossover cable might solve the issue (just an assumption)

Best Regards,
Lakshantha

1 Like

Hi @lakshanthad, glad to know you solved your problem.

If your PI is v.4 or your PC has a gigabit ethernet port you don't need to use a crossover cable (the PHY ethernet layer of this device can swap the Rx / Tx signal so you don't have to use a crossover cable anymore).

Strange behavior, however, usually a micro LAN (1 cable, two ethernet ports) simply solves the connection problems (in your configuration, where a peer also offers as a DHCP server, you don't even need to temporarily configure a fixed IP on your Windows host, just wait for PI to finish its bootstrap before plugging in the Ethernet cable).

At the cost of sounding repetitive, please remember that ping is your best friend!
So first check to do is ever:
ping 192.168.1.1

Thank you everyone for helping.

Now I can SSH into my Raspberry Pi using my PC!

I have now connected a USB 3.0 - Ethernet Adapter (tplink UE300) and converted my Raspberry Pi into a soft router.

I am currently running an OpenVPN client, connected RPI to another router to enable a VPN-enabled Wi-Fi network.

Also playing around with some plugins and packages!

Next in my mind is to build a file server using samba :slight_smile:

Best Regards,
Lakshantha