Sheepdog
Posts: 16
Joined: Sun Aug 21, 2016 7:44 pm

Static IP- Why... How

Mon Aug 06, 2018 10:44 am

Newbie here. Environment stated in signature...

I THINK I "need" my Pi to use a static IP. I am building a web-server in a home environment. It will be on my LAN, accessible to WAN via the magics of NAT and DYNDNS. Without a static IP, how does NAT know where to redirect incoming packets for the port I've chosen for the server?

If I turn off Pi's Wi-Fi, connect my Pi via a cable, and let the router assign the device its local IP address (LIPA) with the router's DHCP service, then I can ping the Pi across the LAN, and access google.com with Chrome.

But when I try to use the Pi's Wi-Fi with a static IP:
no joy with ping...
even though when I hover the mouse over the "network" icon on the Pi's screen (which has changed from up arrow/down arrows to signal strength indicator), I do see
wlan configured 192.168.0.190/24

... which is where I asked it to be. (For others reading this who don't know: The /24 says "subnet mask 255.255.255.0")

I don't think I've "messed with" anything other than /etc/.dhcpcd.conf

I'm doing this forum post "by hand" on a neighboring computer... the following could have typos... but I don't think I did more than add...

Code: Select all

interface wlan0
static ip address=192.168.0.190/24
static routers=192.168.0.1
static domain_name_servers=68.87.71.230 4.2.2.2
Running thus, I can't reach Google.com with Chrome, whereas I could reach it when using the cable, at the DHCP assigned LIPA

==== QUESTIONS....

Is the next thing to try changing BOTH wlan0 AND eth0 to the static spec I want? I was hoping that I could "swap" between WORKING "by cable, but DHCP-assigned-LIPA" and not-yet-working "by LIPA, static IP".

DO I "need" Static IP, or is there another way? HOW do I get it working, if I do?....
New to Pi and Linux generally... old to computers. Using Raspbian 9 (Stretch) on a Pi 3 B (ver 1.2), apt-get update, apt-get upgrade at least as recently as 5 Aug 2018

User avatar
rpdom
Posts: 16800
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Static IP- Why... How

Mon Aug 06, 2018 10:51 am

One way to get a "static" IP is to configure it in your router/DHCP server. You can usually associate the interface's MAC address with a particular IP address and then you don't have to change anything on the Pi.

Sheepdog
Posts: 16
Joined: Sun Aug 21, 2016 7:44 pm

Re: Static IP- Why... How

Mon Aug 06, 2018 12:59 pm

Thank you, rpdom... and thank you Arris/Motorola for a good router, with good documentation both in item and online.

It seemed like such a good answer!!! (Never solve something, when you can go around it!)

But. MY router's "pass through by MAC address" feature doesn't allow binding to a LAN IP addr... it requires that the service provider issue a separate WAN IP address for the passed through device. Even IF my service provider would do this... not sure... I don't want then to start fighting the "put a DDNS client on the Pi" fight.

Sigh. Just difficult to please, I suppose.

In a small system, static IPs are just So Much Simpler!!!... when avail! (I've used them for years... Arduino web servers, IP cameras, etc.)

So... still interested in other readers' ideas!...
New to Pi and Linux generally... old to computers. Using Raspbian 9 (Stretch) on a Pi 3 B (ver 1.2), apt-get update, apt-get upgrade at least as recently as 5 Aug 2018

bgrundy
Posts: 11
Joined: Mon Jun 22, 2015 6:51 pm

Re: Static IP- Why... How

Mon Aug 06, 2018 1:06 pm

So you router does not allow for "reserved IP address"? I'd be very surprised if this were the case. You might want to look at getting another router that allows both reserving an IP address (the DHCP server in the router assigns the address every time based on the MAC - as previously suggested).

Once that is done, you should also have a setting for "port forwarding". Where you can assign incoming traffic on a specific WAN port to a designated IP address/Port combo.

What specific model router do you have?

klricks
Posts: 7049
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: Static IP- Why... How

Mon Aug 06, 2018 1:16 pm

MAC filtering and DHCP Reservations to MAC are not the same thing.
Unless specified otherwise my response is based on the latest and fully updated RPiOS Buster w/ Desktop OS.

bgrundy
Posts: 11
Joined: Mon Jun 22, 2015 6:51 pm

Re: Static IP- Why... How

Mon Aug 06, 2018 3:49 pm

klricks wrote:
Mon Aug 06, 2018 1:16 pm
MAC filtering and DHCP Reservations to MAC are not the same thing.
I don't *think* anyone suggested MAC filtering. There may be some terminology differences here. DHCP reservation and port forwarding should accomplish what the OP is looking for unless I'm reading it wrong (which is entirely possible). MAC filtering obviously won't and I tend to doubt MAC passthough would either (I'm not completely up to speed on passthrough, but I thought it was about changing adapters).

Sheepdog
Posts: 16
Joined: Sun Aug 21, 2016 7:44 pm

Re: Static IP- Why... How

Mon Aug 06, 2018 6:14 pm

Thank you, bgrundy and others. The router is marked "Motorola Surfboard SBG6580. The interface, via 192.168.0.1 says "Arris SBG6580"

The wonderful Google managed to find the right document even though I missed out the S. Search string BG6580 forward by MAC address

https://arris.secure.force.com/consumer ... tedArticle

.. is where I found the bad news... after looking quite hard in router for feature mentioned. (The router does a fine job of sending things to specific static-local-IP-addressed clients on the LAN based on the PORT the request is made to, via the router's (one) external (WAN) IP address. NAT, and all that. I "get" that.

But will have another look, given your advice. But that would still leave the "needs a DDNS client in Pi" issue.

** Is it REALLY so difficult to tell the Pi to reside at a particular static IP address? Any "reason"? So many devices are quite happy with such a requirement. It would seem to be SIMPLER to provide for, on a technical level, than DHCP! (Not as user friendly, in many scenarios... but easier to provide for.)

===========
(klricks... thank you. I could well be confused about which/ what MAC related features in my router I want/ can ignore. Working on it!)

Whatever the NAME, and of course, it is important, I think the suggestion was that some routers are able to operate on the following basis...
Actually... having typed that, I realize that what I THOUGHT was being suggested won't work.

I'm going to make a bunch of statements. They are questions, sort of. The attempt to set out my current grasp of matters. Shoot me down, please, if you see Wrong Bits.

You can't (?) say "if this is for the device with MAC xyz, send it to the local IP address we assigned to that device with DHCP. The incoming message is merely sent to...
a) The external, "WAN-wards" IP address of the router in question, as assigned (and from time to time changed) by the service provider,
AND
b) A particular port.

NAT takes advantage of the possibility of specifying a port, and enables the user to TRANSLATE from "this is for port X" into this is for the device on the LAN at (local) IP address 192.138.0.Y.... and, by the way, use port Z. Z may be the "X" that was used "at the top" of the "chain", or a different number... That detail will be determined by the way the NAT table has been filled in.

It IS possible to have things for a particular device- as identified by it's MAC- go there.... IF the router has been configured to leave that OUT of the provisions of DHCP... but only if the router's to the WAN, "the internet", has more than one "outward facing" "point of contact", i.e. more than one wide area IP address. (And then you have to manage knowing what that IP address is, and telling people who need to know, all of which can be taken care of via a DDNS service, if a DDNS client app is running continuously in the device so set up.)
New to Pi and Linux generally... old to computers. Using Raspbian 9 (Stretch) on a Pi 3 B (ver 1.2), apt-get update, apt-get upgrade at least as recently as 5 Aug 2018

Sheepdog
Posts: 16
Joined: Sun Aug 21, 2016 7:44 pm

Re: Static IP- Why... How

Mon Aug 06, 2018 6:25 pm

(new material added to this post, 7 Aug 2018, 3pm New York time)
One way to get a "static" IP is to configure it in your router/DHCP server. You can usually associate the interface's MAC address with a particular IP address and then you don't have to change anything on the Pi.
I think my router provides for this. But under this system, if I've got it right, just takes the device with that MAC "outside" of EVERYTHING else in the system. It also assumes that my service provider will "play", and connect that device directly to the internet, via a second "external", or WAN IP address (WIPA) specific to that device, e.g. the Pi. (The first WIPA being the one that all the other traffic passing to that router goes over.)

But that leads to an new "thing to go wrong". The Pi, "looking" to the WAN like a "separate" entity needs its own DDNS client, to keep the DDNS service apprised of what IP address the service provider has given the Pi at this time. (These WIPAs change from time to time.) And besides adding something else to go wrong, this solution adds to what you'd be paying your DDNS service provider.

Hence, I don't think I'm ready to abandon hoping that the Pi CAN be given a static IP address... or perhaps find out that I haven't really understood the "do it with the MAC address" "answer".

===
New material...
Well... I DID have it right... but only half right. What I described was ONE of the ways my router could handle an address for a device.

It did indeed ALSO offer the facility that the kind people who replied were trying to point me to.

For furture readers of the thread, here's the story told another way:

DHCP is a wonderful thing. For some purposes. Some routers even let you "have cake and eat it to"....
You can tell the router "reserve address XX (one of the addresses WITHIN the pool set aside for DHCP assignment). Only issue it if you see a device with the following MAC. (number). If a device with that MAC presents itself, connect it to the LAN with local IP address (LIPA) 192.168.0.XX"

So, thus, it is very like you've "given" the device with that MAC a "static" LIPA!... which is what I needed. Solved! Hurrah! (But I WOULD still like to be able to do it the other way! So that less is in my router configuration, and more is tied to the relevant hardware. For instance, I sometimes have two Raspberries (or similar) which I use in alternation in a particular role. (One in service, the other being worked on, developing an improved version. With the LIPA in the Raspberry, I can just swap them over. With the LIPA tied to the MAC, not so easy. (I doubt my router is going to let me associate the same LIPA with two MACs, just in case I one day plug both bits of hardware in at the same time.)

Why do I want a static IP anyway? So that I can have a webserver (and perhaps other similar things) behind a router, and use the port to tell the router where to send particular incoming messages.
Last edited by Sheepdog on Tue Aug 07, 2018 7:11 pm, edited 1 time in total.
New to Pi and Linux generally... old to computers. Using Raspbian 9 (Stretch) on a Pi 3 B (ver 1.2), apt-get update, apt-get upgrade at least as recently as 5 Aug 2018

hippy
Posts: 7177
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Static IP- Why... How

Mon Aug 06, 2018 9:11 pm

Sheepdog wrote:
Mon Aug 06, 2018 6:14 pm
** Is it REALLY so difficult to tell the Pi to reside at a particular static IP address?
Not really. I set my static IP address with just a few simple lines in /etc/network/interfaces.

That's no longer the approved way of doing things, but I couldn't get the approved way to work for me. I require my Pi to have multiple static IP addresses on different networks but a single static IP address should work as expected.

Return to “Raspberry Pi OS”