0

I am trying to give my pi zero a static IP. The pi zero is connected via a single USB connection into my PC. The reason why I want this is because I want to create a server-client program (Server runs on PC & Client runs on Pi). To connect to my Pi via my PC I need an IP Address. I have found my IP Address on my Pi but it changes after every reboot (So does my MAC Address). I hope this isn't off topic. Thanks

EDIT: As requested I will now explain what I have done: I have flashed a fresh image of Rasbian Lite on my Pi zero. Afterwards I changed the config.txt to add this line to the bottem of the file: dtoverlay=dwc2. Then I modified the the cmdline.txt file to add this line after rootwait: modules-load=dwc2,g_ether. I then created a file named ssh to enable ssh connections to my Pi. I then inserted the SD Card into my pi and connected an USB cable from the USB Port (the closest one to the board) into my PC. I am now able to connect to my pi using pi@raspberrypi.local or raspberrypi.local as IP Address. I am also able to connect to my pi by using the IP Address found by typing ifconfig into the command line. My question is: How do I make the IP I find by typing ifconfig a static IP Address which doesn't change after every reboot (Which it does now).

WoJo
  • 11
  • 2
  • It is possible to assign a [Static IP Address](https://raspberrypi.stackexchange.com/a/74428/8697) (although IMO unnecessary), but if you want any detailed answer you need to explain what you have done - at the moment this is vague, and you have provided no detail. – Milliways Apr 23 '20 at 11:13
  • @Milliways I have added more information on what I have done and what my goal is. I hope this clears it up. Also, I checked out the link you mentioned, but that won't work because when I check the gateway address it is `usb0` in stead of an IP Address – WoJo Apr 23 '20 at 11:22
  • It seems, based on the additional information that everything is working so I don't see the problem. What is wrong with `raspberrypi.local` - I rarely use anything else? You still haven't said what the IP address is ( post output of `ip a` ) – Milliways Apr 23 '20 at 11:29
  • @Milliways the thing is I'm not completely sure I can use `raspberrypi.local` for everything that needs an IP Address. Also, the IP Address is: `169.254.xxx.xxx` where all the `x` change after every reboot. – WoJo Apr 23 '20 at 11:37
  • This is a [Link-local address](https://en.wikipedia.org/wiki/Link-local_address) - indicating that whatever you have connected the Pi to does not have a DHCP server. You can allocate an address on the Pi (provided this is compatible with the network segment used by whatever you have connected the Pi to uses) as described in the link above. It is still unclear what you are trying to achieve. – Milliways Apr 23 '20 at 11:57
  • Thank you. I believe I can work with this. If you are still interested in what I am trying to achieve: I am trying to build a server-client program (server on PC and client on PI) that reads the hardware on my PC and displays it on an LCD or OLED screen. I am planning on putting the Pi in my PC Case so therefore I want to use as less cables as possible. Thanks again for your time and help – WoJo Apr 23 '20 at 12:01
  • 1
    Does this answer your question? [How do I set up networking/WiFi/static IP address?](https://raspberrypi.stackexchange.com/questions/37920/how-do-i-set-up-networking-wifi-static-ip-address) Why it does not work for you? What exactly is the instruction that fails? – Ingo Apr 24 '20 at 17:10
  • Thanks I already got it working :) – WoJo Apr 26 '20 at 11:40

0 Answers0