AnneCreek
Posts: 35
Joined: Thu Oct 04, 2018 4:51 pm

Setting WiFi static IP

Mon Oct 15, 2018 3:40 pm

I am currently accessing my RPi via SSH , both wired (via Ethernet) and wireless (built-in WiFi).
Been using wired SSH for awhile and really do not recall how the IP got set to be static.
I have the WiFi working , but would like to set the IP as static.
No technical reason , just for convenience. .

Here is a copy of setting static IP I am going to use as an example

static ip_address=192.168.0.10/24

My question is - what is the purpose of "/24" at the IP?


static value
Configures a static value. If you set ip_address then dhcpcd
will not attempt to obtain a lease and just use the value for the
address with an infinite lease time. If you set ip6_address,
dhcpcd will continue auto-configuation as normal.

Here is an example which configures two static address, an IPv4
router, DNS and disables IPv6 auto-configuration. You could also
use the inform6 command here if you wished to obtain more infor-
mation via DHCPv6. For IPv4, you should use the inform ipaddress
option instead of setting a static address.
interface eth0
noipv6rs
static ip_address=192.168.0.10/24
static ip6_address=fd51:42f8:caae:d92e::ff/64
static routers=192.168.0.1
static domain_name_servers=192.168.0.1
fd51:42f8:caae:d92e::1




Secondly - my current dhcpcd.con is NOT using "wlan0" as interface "name ".

Code: Select all

interface wlx00173ffc9a9c
noipv6
My "raspi-config" is configured to use "wlan0" !

Code: Select all

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.0.1.58  netmask 255.255.255.0  broadcast 10.0.1.255
        inet6 fe80::a80d:65ff:fedf:6204  prefixlen 64  scopeid 0x20<link>
        ether aa:0d:65:df:62:04  txqueuelen 1000  (Ethernet)
        RX packets 34  bytes 7175 (7.0 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 224  bytes 34939 (34.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
Should I be concerned ?

Thanks for reading, help is appreciated. .

B.Goode
Posts: 6544
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Setting WiFi static IP

Mon Oct 15, 2018 3:53 pm

My question is - what is the purpose of "/24" at the IP?


CIDR is the concept to research.

For example: https://www.ipaddressguide.com/cidr

AnneCreek
Posts: 35
Joined: Thu Oct 04, 2018 4:51 pm

Re: Setting WiFi static IP

Mon Oct 15, 2018 4:48 pm

B.Goode wrote:
Mon Oct 15, 2018 3:53 pm
My question is - what is the purpose of "/24" at the IP?


CIDR is the concept to research.

For example: https://www.ipaddressguide.com/cidr
Do I understand correctly "/24" is some kind of "range" ?
Is it optional / can it be omitted ?
So how does it work when I assign SINGLE static IP?

DirkS
Posts: 9259
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: Setting WiFi static IP

Mon Oct 15, 2018 5:18 pm

AnneCreek wrote:
Mon Oct 15, 2018 4:48 pm
Do I understand correctly "/24" is some kind of "range" ?
Is it optional / can it be omitted ?
So how does it work when I assign SINGLE static IP?
It's actually the netmask. /24 means 24 bit, which is the same as a netmask of 255.255.255.0
It's basically a more compact way to represent a single (!) network address

dhcpcd5 (which uses /etc/dhcpcd.conf) will assume /24 if you omit it, but it's best to use it anyway.
Last edited by DirkS on Mon Oct 15, 2018 7:33 pm, edited 1 time in total.

B.Goode
Posts: 6544
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Setting WiFi static IP

Mon Oct 15, 2018 7:30 pm

[Original content of this post made redundant by subsequent events, so deleted.]
Last edited by B.Goode on Mon Oct 15, 2018 7:40 pm, edited 1 time in total.

DirkS
Posts: 9259
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: Setting WiFi static IP

Mon Oct 15, 2018 7:34 pm

B.Goode wrote:
Mon Oct 15, 2018 7:30 pm
It's actually the netmask. /24 means 24 bit, which is the same as a netmask of 255.25.255.0

I think that should be..

"It's actually the netmask. /24 means 24 bit, which is the same as a netmask of 255.255.255.0"
Corrected.
Cheers!

LTolledo
Posts: 736
Joined: Sat Mar 17, 2018 7:29 am

Re: Setting WiFi static IP

Mon Oct 15, 2018 9:50 pm

If you have access to your router, its better to have it supply a static IP to your devices, whether those are connected via Ethernet LAN cable or via WiFi.

and just leave the network settings on all your devices to get IP automatically via DHCP.
"Don't come to me with 'issues' for I don't know how to deal with those
Come to me with 'problems' and I'll help you find solutions"

Some people be like:
"Help me! Am drowning! But dont you dare touch me nor come near me!"

User avatar
Greg Erskine
Posts: 76
Joined: Sat Sep 15, 2012 4:20 am

Re: Setting WiFi static IP

Mon Oct 15, 2018 10:32 pm

LTolledo wrote:
Mon Oct 15, 2018 9:50 pm
If you have access to your router, its better to have it supply a static IP to your devices, whether those are connected via Ethernet LAN cable or via WiFi.

and just leave the network settings on all your devices to get IP automatically via DHCP.
+1

Use your router to map MAC to a static IP address.

AnneCreek
Posts: 35
Joined: Thu Oct 04, 2018 4:51 pm

Re: Setting WiFi static IP

Mon Oct 15, 2018 11:10 pm

Greg Erskine wrote:
Mon Oct 15, 2018 10:32 pm
LTolledo wrote:
Mon Oct 15, 2018 9:50 pm
If you have access to your router, its better to have it supply a static IP to your devices, whether those are connected via Ethernet LAN cable or via WiFi.

and just leave the network settings on all your devices to get IP automatically via DHCP.
+1

Use your router to map MAC to a static IP address.
I hope I am making sense , but I like to have permanent IP ( static) for WiFi just like I have for Ethernet.
That way my SSH IP would be always same.
Right now I can access RPi via same Ethernet IP.
But the WiFi IP always changes after reboot.
Technically I do not care, but my crossconnncet complier has to be reconfigured each time WiFi IP changes.
It would be more convenient if the WiFI IP stayed the same.

SurferTim
Posts: 1766
Joined: Sat Sep 14, 2013 9:27 am
Location: Miramar Beach, Florida

Re: Setting WiFi static IP

Mon Oct 15, 2018 11:16 pm

You can set static network settings for a specific ssid, like the one at your home, and get dhcp settings for the rest, like work or school.
In /etc/dhcpcd.conf:

Code: Select all

ssid YourSSID
static ip_address=192.168.0.200/24
static routers=192.168.0.1
static domain_name_servers=8.8.8.8

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

Re: Setting WiFi static IP

Mon Oct 15, 2018 11:55 pm

AnneCreek wrote:
Mon Oct 15, 2018 11:10 pm
Greg Erskine wrote:
Mon Oct 15, 2018 10:32 pm
LTolledo wrote:
Mon Oct 15, 2018 9:50 pm
If you have access to your router, its better to have it supply a static IP to your devices, whether those are connected via Ethernet LAN cable or via WiFi.

and just leave the network settings on all your devices to get IP automatically via DHCP.
+1

Use your router to map MAC to a static IP address.
I hope I am making sense , but I like to have permanent IP ( static) for WiFi just like I have for Ethernet.
That way my SSH IP would be always same.
Right now I can access RPi via same Ethernet IP.
But the WiFi IP always changes after reboot.
Technically I do not care, but my crossconnncet complier has to be reconfigured each time WiFi IP changes.
It would be more convenient if the WiFI IP stayed the same.
As others have said use the DHCP MAC to IP Reservation feature of your router instead of setting a static config on your RPi.
That way the router will always assign the same IP address of your choice with no changes made on the RPi itself.
Be sure to assign a different IP to each interface Wired and WIFI.

This is handy because you can wipe your SD card and start again or boot a different OS and the network will just work.
Also if you take your RPi to another network it will revert to DHCP mode and work there as well.
Unless specified otherwise my response is based on the latest and fully updated Raspbian Stretch w/ Desktop OS.

jsimmonstx
Posts: 6
Joined: Fri Sep 21, 2018 8:06 pm

Re: Setting WiFi static IP

Wed Oct 17, 2018 4:18 pm

These links might help you set your pi to have a static IP...

https://www.modmypi.com/blog/how-to-giv ... ess-update
https://www.modmypi.com/blog/tutorial-h ... ip-address

You have to work on your google foo... :)

If you want to do it through a GUI, you can try this app:

sudo apt-get -y install wicd

Return to “Networking and servers”