4

I'm using Raspberry PI 3 with Raspbian Jessie to make an industrial datalogger product. For obvious reasons I need to tell the Rasp to use a static IP configuration, in order to make it work in other networks. After googling I found out that the proper way to achieve that was to alter the dhcpdcd.conf file (/etc/dhcpcd.conf) adding the following lines:

interface wlan0
static ip_address=192.168.168.207
static routers=192.168.168.254
static domain_name_servers=192.168.168.254

When I know (or at least I think so) I'm giving the dhcp client the static IP, Default Gateway (routers) and DNS Address, which is good. Everything is fine and the Pi actually uses those information.

The problem is the subnet mask. So far, I couldn't figure out how to set it properly. Setting this info is crucial (I guess), since this device will work in different networks, including different subnetworks. What I would like to configure is a simple subnet mask, (such as 255.255.0.0, or even more subnetted).

I'm a missing something ? Maybe something TCP\IP related. Is subnet mask an optional parameter when configuring a device nowadays?

  • from what I understand, your last octet 192.168.168.x addresses tend to change. This should imply that your subnet mask is 255.255.255.0 because you need to mask the first three octets of the IPv4 address – Shan-Desai Mar 1 '17 at 10:39
3

I had a similar problem to set a Subnet Mask 255.255.254.0 for static IP 192.168.161.154 in /etc/dhcpcd.conf. How I address this is by adding /23 at the end of the static IP address,

interface wlan0
static ip_address=192.168.161.154/23

For the above discussed issue, it can be addressed by adding /16, as specified below.

interface wlan0
static ip_address=192.168.168.207/16
static routers=192.168.168.254
static domain_name_servers=192.168.168.254

For more reference https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing

0

I don't know why you think "For obvious reasons I need to tell the Rasp to use a static IP", but putting this aside I don't know why you think this is the correct way to set /etc/dhcpcd.conf (it certainly didn't come from the man page) - dhcpcd uses CIDR format.

To add to the above the value you are using for routers= seems improbable.

See How do I set up networking/WiFi/Static IP for an example and suggested methods for determining the correct values.

  • Regarding static configurations: static IP address is a must and a standard in every industrial enviroment, at least in my country. You must be able to connect to a device with always the same configuration (including IP and Port) in order to automate its use – Andrew Mar 1 '17 at 11:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.