im trying to setup a static ip for my raspberry pi ive set a set ip in my router setting but the pi dont listen to it and keeps makeing its own ive fallowed a few tips on how to do it threw the pi but i ended up mesing up the network interface so i re flashed my sd, so eveything works fine right now it just keeps changing IP on my heres what i have now in ifconfig eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.121 netmask 255.255.255.0 broadcast 192.168.0.255
inet6 fe80::900:aa75:230:37bd prefixlen 64 scopeid 0x20
ether b8:27:eb:ae:d4:3f txqueuelen 1000 (Ethernet)
RX packets 2141863 bytes 244132445 (232.8 MiB)
RX errors 0 dropped 58 overruns 0 frame 0
TX packets 1077072 bytes 2057902650 (1.9 GiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10
loop txqueuelen 1000 (Local Loopback)
RX packets 458876 bytes 6528652036 (6.0 GiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 458876 bytes 6528652036 (6.0 GiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlan0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether b8:27:eb:fb:81:6a txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
yes i run it wired, so i can i set the pi to make its own static ip?
Additional information about your setup (OctoPrint version, OctoPi version, printer, firmware, octoprint.log
, serial.log
or output on terminal tab, ...)
Having used ssh to get a remote connection to your Raspberry Pi:
sudo nano /etc/network/interfaces
In the section where it indicates eth0 you need something like this:
auto eth0
allow-hotplug eth0
iface eth0 inet static
address 192.168.0.200
netmask 255.255.255.0
gateway 192.168.0.1 # I'm guessing here on the address of your router
network 192.168.0.0
broadcast 192.168.0.255
dns-nameservers 8.8.8.8 8.8.4.4
# Feel free to insert your own router's address in here, for example:
# dns-nameservers 192.168.0.1 8.8.8.8 8.8.4.4
It's best to leave the rest of the file the way it is. Save that, reboot and see if ifconfig
includes the selected/static IP address above.
Optionally...
If it does not, then it sounds like dhcpd
is getting in the way. Swap in networking
instead and see if that makes this work.
sudo systemctl disable dhcpcd
sudo systemctl enable networking
sudo reboot
Another option is to leave the Pi getting its IP address via DHCP and going to your router and add a "fixed lease" for the Pi (using the Ethernet MAC address).
In reality, once the router and the Pi have negotiated an dynamic IP address, it will be the same for quite a long time (months, years). When the Pi renews its lease, it asks if its old address is still available. The router will give it that same address unless something else has taken it while the Pi wasn't active, and this only happens if there is a "new" device in your network during the time the Pi wasn't active and the router has run out of addresses to hand out. All the old devices are also asking for their old address as well so even if the Pi is off for an extended period, there's a good chance the router will assign it the same old address anyway.
1 Like
I use the router option. This way, all the devices, wired, wireless, static, and nonstatic, are all on the same screen for me
It's easier to keep an eye on things that way... Easier FOR ME anyway