Orbi WiFi 7 RBE973
Reply

Using a Static IP Address on a Raspberry Pi Connected to my Nighthawk Router

TerryJColes
Luminary

Using a Static IP Address on a Raspberry Pi Connected to my Nighthawk Router

Hi,

 

I have a couple of Raspberry Pis connected to my Home Network which is provided by my Netgear Router.  Ideally I want to set up a static IP Address for each of these Pis, but I cannot make them 'see' the Internet reliably unless I use Address Reservation in LAN Setup page.  This works, but it means that I can only have the IP Address that the Router gave me through DHCP before I reserved it.  What I really want is to specify static IP Addresses in the 'dhcpcd.conf' file on the Pis and have the Router accept these as the addresses to use.

 

I'm sure that I was able to do this in the past, but not any more.

 

Also.  If I reserve the DHCP Server on the Router gave me, I'm sure I used to be able to edit this to the IP Address that I want but this also causes the system to fail.  (For info.  The Router assigns the address and I can connect to either Pi using SSH via the LAN, but the Pis can't see the Internet.)

 

Is there a way to do this?

Model: D7800|Nighthawk X4S – AC2600 WiFi VDSL/ADSL Modem Router
Message 1 of 14

Accepted Solutions
TerryJColes
Luminary

Re: Using a Static IP Address on a Raspberry Pi Connected to my Nighthawk Router


@schumaku wrote:

So t the end of the day, what went wrong and broke the Pi <-> D7800 connection and the Internet connection finally?


The router was unaware of the presence of the Webserver, so didn't route Google traffic when I was trying to use the Static IP.

View solution in original post

Message 14 of 14

All Replies
labatt
Mentor

Re: Using a Static IP Address on a Raspberry Pi Connected to my Nighthawk Router

Configure the Raspberry Pi staticly. That means going into the Pi and assigning an IP address, mask and gateway. Make sure the IP address is outside of the DHCP scope on the router to get things to work. I have 2 Pi's setup this way. One is running Pi-Hole. 

 

If you need help with the assigning, Google is your friend. Lots of Pi info there. 

Message 2 of 14
TerryJColes
Luminary

Re: Using a Static IP Address on a Raspberry Pi Connected to my Nighthawk Router

'Configure the Raspberry Pi staticly. That means going into the Pi and assigning an IP address, mask and gateway. '

 

I have been configuring the IP address statically, eg:

# Static IP configuration:
interface eth1
static ip_address=192.168.1.98/24
static routers=192.168.1.1
static domain_name_servers=8.8.8.8
metric 200

What do you mean by 'mask and gateway' in this context?

Message 3 of 14
labatt
Mentor

Re: Using a Static IP Address on a Raspberry Pi Connected to my Nighthawk Router


@TerryJColes wrote:

'Configure the Raspberry Pi staticly. That means going into the Pi and assigning an IP address, mask and gateway. '

 

I have been configuring the IP address statically, eg:

# Static IP configuration:
interface eth1
static ip_address=192.168.1.98/24
static routers=192.168.1.1
static domain_name_servers=8.8.8.8
metric 200

What do you mean by 'mask and gateway' in this context?


I suspect when you did the actual configuration on the Pi you were asked mask. That does not show when doing the command you gave.  

Normally when doing the actual assignment there is a mask question. Is the .98 address within your DHCP scope? If so that can cause issues.

Can you ping the Pi? If not then that would be where to start assuming the .98 is outside of the DHCP scope. 

If you do a ifconfig eth1 you should see the mask. Here is output on my Pi.

ifconfig eth0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.220 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::1683:1051:7637:eeeb prefixlen 64 scopeid 0x20<link>
ether b8:27:eb:57:7d:03 txqueuelen 1000 (Ethernet)
RX packets 1561476 bytes 193229943 (184.2 MiB)
RX errors 0 dropped 1 overruns 0 frame 0
TX packets 961779 bytes 114655160 (109.3 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

Message 4 of 14
antinode
Guru

Re: Using a Static IP Address on a Raspberry Pi Connected to my Nighthawk Router

> I have a couple of Raspberry Pis [...]

 

   Model?  Network interfaces?  Raspbian?

 

> [...] I want to set up a static IP Address for each of these Pis,
> [...]

 

   Why?

 

   Terminology: A "static" address is configured on the device itself.
What you configure on a (DHCP server on a) router is a reserved dynamic
address, not a static address.  Which do you mean?

 

   Do you really care which way you get a fixed address?  Using static
addresses requires more care in the configuration of the DHCP server.

(See below.)

 

> [...] This works, but it means that I can only have the IP Address
> that the Router gave me through DHCP before I reserved it. [...]

 

   It _does_?  How did you arrive at that conclusion?


> [...] What I really want is to specify static IP Addresses in the
> 'dhcpcd.conf' file on the Pis and have the Router accept these as the
> addresses to use.

 

   Is that what you "really want", or is it what you believe is the only
way to get what you _really_ "really want", namely free choice of fixed
IP configuration for these gizmos?  Don't choose the solution before you
define the problem.

 

> Also. If I reserve the DHCP Server on the Router gave me, I'm sure I
> used to be able to edit this to the IP Address that I want but this also
> causes the system to fail. [...]

 

   Huh?  "reserve the DHCP Server"?  Does that mess make sense to you
when you read it?

 

   If you do enough playing with address reservations, then you might
need to shut down the router (DHCP server) and all the client devices,
and then restart everyone to get everyone into a consistent condition.


> Configure the Raspberry Pi staticly. [...]

 

   I typically wouldn't.  I usually don't.  I usually use address
reservation for mine (Zero W, 3 B+), and it works just fine (on a
D7000[v1], V1.0.1.78_1.0.1).

 

   But, if you want to specify odd-ball parameters, like, say, a DNS
server other than the router, then DHCP from the router would not do
what you want.


> What do you mean by 'mask and gateway' in this context?

 

   The "subnet mask" is specified by your "/24".  "/24" is equivalent to
"255.255.255.0" (that is, 24 binary ones).  (And it's more compact.)
"ifconfig" uses the old (bulky) notation in its reports.

 

   "[default] gateway" and "default router" are equivalent.

 


   If you decide to use static addresses, then you should shrink the
DHCP pool on your router (DHCP server) from its default range,
".2" - ".254", to something smaller, like, say, ".100" - ".254".  Then
use the available non-pool addresses (".2" - ".99") as your static
addreses.  That way, you don't need to worry about the DHCP server
granting your static addresses to some DHCP clients.

 

   Around here, on an R-Pi Zero W (so the network interface is "wlan0"),
I set the following in "/etc/dhcpcd.conf":

 

interface wlan0
static ip_address=10.0.0.150/24
static routers=10.0.0.1
static domain_name_servers=10.0.0.140

 

(I wouldn't bet that setting "static domain_name_servers" there has any
effect on name resolution.  "/etc/resolvconf.conf" might have more
influence over that than anything in "/etc/dhcpcd.conf".)

 

   My subnet is different ("10.0.0.*" rather than "192.168.1.*"), but
otherwise we seem to be doing similar things.  Mine works:

 

pi@rpizw:~$ ping -c 1 dns.google
PING dns.google (8.8.8.8) 56(84) bytes of data.
64 bytes from dns.google (8.8.8.8): icmp_seq=1 ttl=118 time=67.7 ms

--- dns.google ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms

rtt min/avg/max/mdev = 67.708/67.708/67.708/0.000 ms

 


> Model: D7800|Nighthawk X4S - AC2600 WiFi VDSL/ADSL Modem Router

 

   Is that accurate?  Wouldn't a D7800 default to "192.168.0.*", not
"192.168.1.*"?  Are you just configuring the R-Pi on a wrong subnet?

Message 5 of 14
TerryJColes
Luminary

Re: Using a Static IP Address on a Raspberry Pi Connected to my Nighthawk Router


@labatt wrote:


> I suspect when you did the actual configuration on the Pi you were asked mask. That does not show when doing the command you gave.  

I don't understand what you mean by 'asked mask'?  This is not done by some kind of wizard.  It is done by editing the file dhcpcd.conf.  AFAIK the subnet mask is defined by the /24 in the declaration.

Message 6 of 14
TerryJColes
Luminary

Re: Using a Static IP Address on a Raspberry Pi Connected to my Nighthawk Router

The reason I am doing all this is because I am stuck at home in shielding and we have an extensive private network at our local Model Town which is used to control around 20 Pi based devices which measure water levels, operate pumps and open valves in the model river system.  Owing to lockdown we are unable to get to the site to monitor this or take readings.

 

The two Raspberry Pis in question are both Pi3s but the remaining Pis are all Zeros.  One of the Pi3s has been in place for three years and is running a Captive Portal and Webserver.  This needs two Ethernet ports; eth0 connected to the Pis network on 192.168.0.* and eth1 connected to the Model Town's Office Router on 192.168.1.*,  (Yes that is the IP Range of my Nighthawk.  I set it that way because that is the IP Range of the Office Router and the Pis subnet was the same as the Nighthawk subnet.)

 

To get round the problems of lockdown (Most of us are in shielding) we are installing a VPN Server which I am testing at home using a subset of the Model Town's hardware.  I want static IP Addresses for the Webserver and VPN Server because the VPN Server needs both ports to be  static and the Webserver is easier to test while I am developing the system here at home.

Message 7 of 14
antinode
Guru

Re: Using a Static IP Address on a Raspberry Pi Connected to my Nighthawk Router

> [...] One of the Pi3s has been in place for three years and is running
> a Captive Portal and Webserver. [...]

 

   I don't know what "Captive Portal" means to you, but I may not need
to.

 

> [...] This needs two Ethernet ports; eth0 connected to the Pis network
> [...]

 

   You lost me.  To make sense of this, I'd need a map showing what's
connected to what, including which IP addresses are used on which LAN
segments.  So far, I'm not even sure how many routers you have.  Or
where the Internet connection appears.

 

> [...] we are installing a VPN Server [...]

 

   I know nothing about that, either.  (Or VPNs, in general, for that
matter.)


   The one piece of "/etc/dhcpcd.conf" which you exhibited looked ok to
me.  If you're having trouble getting to the Internet that way, then I'd
worry more about the router configuration and the routes on the R-Pi
than on its basic IP configuration.  Possibly interesting:

 

      ifconfig
      netstat -rn

 

      Typically, if you're using multiple subnets, then someone needs more
routing info than a simple default route/gateway.  Your main router, for
example.

 


> [...] AFAIK the subnet mask is defined by the /24 in the declaration.

 

   Yes, as I said.

Message 8 of 14
TerryJColes
Luminary

Re: Using a Static IP Address on a Raspberry Pi Connected to my Nighthawk Router


@antinode wrote:

 I don't know what "Captive Portal" means to you, but I may not need to.

 

You lost me.  To make sense of this, I'd need a map showing what's connected to what, including which IP addresses are used on which LAN segments.  So far, I'm not even sure how many routers you have.  Or where the Internet connection appears.

 

I know nothing about that, either.  (Or VPNs, in general, for that matter.)

 

Typically, if you're using multiple subnets, then someone needs more routing info than a simple default route/gateway.  Your main router, for example.

A Captive Portal is a software tool that directs Visitors logging on to a WiFi Network at an attraction and directs their device to particular content.  It uses iptables to restrict or allow access to the Internet and yes, it does it by using routing tables.

 

Similarly, a VPN Server uses iptables to route traffic (amongst other things) and also is more than 'just any old Pi'.  Many VPN Servers work by taking encrypted traffic off the Internet (via the Router) and then putting the clear traffic back out onto the same network.  However, this won't work when the two networks are on different subnets, so the server has two Ethernet ports.

 

Whilst I appreciate your advice, don't you think you might be getting a little patronising?  I asked one very clear question; how to set up a static IP Address when the Pi is connected to a Netgear Router.  Having a diagram showing how I'm using the other side of the Pis, complete with IP Addresses is pretty irrelevant I would have thought and the fact that you know nothing about Captive Portals or VPNs doesn't help.

Message 9 of 14
TerryJColes
Luminary

Re: Using a Static IP Address on a Raspberry Pi Connected to my Nighthawk Router

I'm still struggling with this.  If I make no attempt to reserve the address that the Router has allocated to my Webserver Pi and disable the static IP Address configuration in dhcpcd.conf, then my Captive Portal software works.  (It relies on accessing the Internet via a few ports to 'fool' Android phones into thinking that they are not in a Walled Garden, even though they are.)  However, I can't even reserve that address in the Netgear Address Reservation page, because the device never appears in the list .

 

I've put the VPN Server config to one side for the moment, but will pick it up again shortly because I suspect that the plethora of blocked ports on the Webserver may be confusing the Router.  Is this possible?

Message 10 of 14
schumaku
Guru

Re: Using a Static IP Address on a Raspberry Pi Connected to my Nighthawk Router

Breaking this discussion down into two issues I think I have read about on this D7800 (firmware version unknown, ISP/WAN encapsulation unknown [because we know this can make a differences on Netgear's famous routers]):

 

  1. The D7800 does not accept a wirless client with a client side static configured IP (address from the subnet, correct default gateway/router IP, mask matching) to reach the Internet. 

    At that stage, the wireless client dos also not show up in the attached devices. [Why should it? There was no DHCP nor any Internet traffic, and the ARP request can be answered from any other IP stack on the wireless or on the wired LAN].

    Unanswered is the most simple test: Ping the router LAN IP from the Pi. Ideally, capture the wlan0 interface traffic while doing this so we can see if there is anything from the other side coming back, like ARP replies, ping, ...  Ideally, try the ping test from the router while capturing the Pi wlan0 interface, too. If this does success, while capturing the Pi wlan0 traffic, try e.g an ssh or ftp access ot, and from the Pi. Potentially there is a problem on the Pi firewall (iptables etc.) config, or the traffic does flow into the concurrently installed and configured VPN default gateway. 

    Can't see that is should matter if the static Pi IP is in the router DHCP pool (IP address range) or not - organisationally I would add a reservation for that MAC-LAN IP pair at least. 

    Does the Pi connect to the D7800 primary or the guest network? Wireless isolation on the guest network or whatever other oddities might lead to issues.
  2. The D7800 LAN config does not (or more specifically no longer) allow to change an already assigned IP address in the MAC-IP reservation table to be changed for a further BOOTP/DHCP assignment. 

    Does the D7800 allow manually entering a MAC-IP pair in the LAN DHCP reservation table (Pi deassociated, worst case following a router reboot to forget about the PI wlan0 BSSID (MAC)) instead of picking and editing the dynamic entry from the DHCP table?

PS. Does anybody want to hear why I try to avoid Netgear's consumer routers where ever possible?

Message 11 of 14
TerryJColes
Luminary

Re: Using a Static IP Address on a Raspberry Pi Connected to my Nighthawk Router

@schumaku 

 

I think that I should clear up a few things.  The WiFi generated by the Netgear Router doesn't come into this and neither does the WiFi on the Pi, because it has been disabled.  The only WiFI that is relevant to this discussion (and then only peripherally) is that provided by two Outdoor WiFi Antennas which allow the Visitors (or staff if they so wish) to open the splash page of the Captive Portal and thence open the content hosted on the Model Town's private Website which provides Audio Guides, etc.  These Outdoor Antennas are connected to the 192.168.0.* subnet and are primarly provided for Visitors.  Staff and volunteers can plug into a switch on the 192.168.0.* subnet or log into the network on the Outdoor WiFI Antennas and then SSH into the Pis.

 

All this is not particularly useful (other than for interest 🙂  ).  The IP Addresses that I want to be static are on the Main Office Router side (the Netgear for my Test Rig).  Since my posting earlier this morning, I have kind of accepted that the main Router doesn't show the devices added with a static IP.  It isn't really a problem,  I now feel that as long as I understand why this is occuring I can live with it.  My initial problem was caused by the lack of visibility of what was connected to the Router; I had got used to seeing this.

 

As far as pinging the Netgear Router from the 192.168.0.* subnet is concerned; no that doesn't work.  I never expected it to (it didn't stop me trying 🙂  ).  Both of these devices purposely prevent it.  The Webserver (which includes the Captive Portal software) uses iptables to turn the Webserver Pi into router and block practically everything going out on that Ethernet port; that's what it's for.  Similarly the VPN Server also uses iptables to create a router that uses MASQUERADE (eg NAT) to prevent traffic going out, except in response to valid packets from an external device using the VPN service.

 

Anyway.  Thanks for the insights that everyone has provided in this thread.  Even the ones that were off beam have helped me work though this problem and come to an understanding of what is going on.

Message 12 of 14
schumaku
Guru

Re: Using a Static IP Address on a Raspberry Pi Connected to my Nighthawk Router

Ok, so you have a wired connection on one of the Ethernet ports for the link to the router - not much of a difference: A static config on that interface should to the job with a few potential deal breakers like WiFI isolation. The ping and traffic capturing was clearly intended for testing the link from the Pi to the router of course. Anything beyond is your Pi project business 8-). Everything I wrote above does still apply - as all that has to work and that's the only part where the router is affected.

 

So t the end of the day, what went wrong and broke the Pi <-> D7800 connection and the Internet connection finally?

 

 

 

 

Message 13 of 14
TerryJColes
Luminary

Re: Using a Static IP Address on a Raspberry Pi Connected to my Nighthawk Router


@schumaku wrote:

So t the end of the day, what went wrong and broke the Pi <-> D7800 connection and the Internet connection finally?


The router was unaware of the presence of the Webserver, so didn't route Google traffic when I was trying to use the Static IP.

Message 14 of 14
Top Contributors
Discussion stats
  • 13 replies
  • 7668 views
  • 0 kudos
  • 4 in conversation
Announcements

Orbi WiFi 7