-1

I want to hook up two Raspberry Pis via a network cable in order to send commands from one Pi to the other. To do so, I want to set a static IP address on both Pis. I know I will have to edit the dhcpcd.conf-file.

My first approch was:

`interface eth0
static ip_address=169.254.250.193/24
static routers=169.254.255.255
static domain_name_servers=169.254.255.255`

with the ip address and router given from my ifconfig after I hook up both Pis.

However, the ifconfig does show me the interface eth0, but does not include any ip address or broadcast address.

I also went for sudo service dhcpcd status and it says:

... Jan 22 15:00:23 raspberrypi dhcpcd[376]: eth0: no IPv6 Routers available ...

I have got 2 questions:

  1. Do you think it is even neccessary to give both pis a static address if I'm only working on a direct ethernet network cable connection? The Pis will both boot up and should start communicate on their own in the future application.

  2. If yes, how can I change the Ip address to a static one, since I'm not passing any router?

Thank you so much!

Best regards, Tobi

Tobse
  • 37
  • 1
  • 7

2 Answers2

0

Oh wow guys, that was quick. I found a solution for that.

I know you should not touch the interfaces file anymore, but this was what did the job for me.

I used the IP address and the netmask given in ifconfig and the gateway from route -n.

I added to the interfaces file:

auto eth0 address 169.254.255.193 netmask 255.255.0.0 gateway 0.0.0.0

with just a difference in the address for both pis. And now everything works fine for me. After reboot, I see their static addresses.

Still, if anyone has a better solution to do this, I would be more than happy.

Thanks you all! Tobi

Tobse
  • 37
  • 1
  • 7
0

Maybe there is a better way to achieve this on raspberry pi, but wouldn't the classic approach work? It is to

  • turn the NIC device down
  • change its IP
  • turn it up again
  • optionally wrap these into a sh script and make it run on an init level of your choice

example (assuming debianish distro and NIC device of name eth0)

sudo ifconfig eth0 down
sudo ifconfig eth0 169.254.250.193
sudo ifconfig eth0 up

I would also recommend to stop all dhclient services if present (dhclient, network-manager, etc)

Maybe more info to be found: https://askubuntu.com/q/459140

helvete
  • 2,455
  • 13
  • 33
  • 37