1

I have a php script on my rpi which i can visit when my computer is on the same network as the rpi.

But, i want to connect a rpi directly to my computer with an ethernet cable and in the browser of my computer i would like to open the php page from the rpi by visiting http://193.168.1.1/index.php. Is this possible and how can i approach this?

1
  • 2
    Yes, you plug an ethernet cable in between the two. This is a general network question and not specific to the Raspberry Pi.
    – joan
    Apr 15, 2017 at 21:21

1 Answer 1

1

I assume you have a Raspberry Pi with a wireless network interface. So you want to have a static IP in the spare wired port of the rpi.

First of all 193.168 is not the best network for trying this, because it doesn't belong to a private range. I will use 10.1.1 in the example, it is the one I use in my own setup.

Edit the file /etc/network/interfaces of the rpi and change the eth0 section like this:

# rpi /etc/network/interfaces
auto eth0

iface eth0 inet static
    address 10.1.1.1
    netmask 255.255.255.0

I assume the other PC is a linux too, add a similar section with another IP. Notice this one ends in .2

# PC /etc/network/interfaces
auto eth0

iface eth0 inet static
    address 10.1.1.2
    netmask 255.255.255.0

Hope this helps.

1
  • Excellent. It works. The rpi was assigning itself an ip in the range 169.254. Could not understand why it would not connect. However, as suggested by you i set up one of the private networks (10.1.1) and the magic started happening. Thank you! On a windows machine I had to set the gateway as well (dns can be left blank). Do not forget to call sudo ifup eth0 and sudo ifdown eth0 to reload the interfaces.
    – Nitin
    Apr 18, 2017 at 16:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.