PureAfrican
Posts: 4
Joined: Mon Oct 23, 2017 6:01 pm

Static IP Addressing issues (Wlan0)

Tue Oct 24, 2017 12:48 am

Greetings All,

I know that I am new to this forum but I have come seeking knowledge so that I may resolve a technical issue that I have been trying to solve on my own for quite some time now, at this point I think I need to escalate my questions to this community, lets get straight to the point shall we?

I've been having issues setting up a Static IP address, I believe the changes that I made have pushed successfully my only issue is that I am unable to ping google's DNS of 8.8.8.8. once my static IP has been set. I may be overlooking a step in the process listed below but I was hoping a fresh brain could point me towards the right direction.

There seems to be a lot of miscommunication when it comes to configuring Static IP addresses for our Pi's, I believe that I am on the right track when I am reviewing the stack exchange tut that i've mentioned below.
Setup a Static IP Address

Questions about setting Static IP Address are among the most common on this site. There are very many tutorials (many wrong, obsolete or incomplete).

Disclaimer

Before proceeding I feel obliged to state that setting up a static address is NOT recommended. Telecommunications Engineers do not do this. Static IP Addresses can be the bane of a Network Administrator's life. There are situations where Static IP Addresses are necessary e.g. if you are running a DHCP server, or running on an isolated network with no DHCP server.
If you are determined to proceed anyway you should make sure you get it right. Adapted from Foundation Network Tutorial

Find the Settings of your local Network

This is most easily done with the Pi itself, using DHCP, but can be done on any computer on your network, although the commands may differ on other systems.

Run either of the following (depending on whether you are using Ethernet or WiFi):

ip -4 addr show dev eth0 | grep inet
ip -4 addr show dev wlan0 | grep inet
On Stretch (which may not use wlan0 or eth0) run the following

ip -4 addr show | grep inet
which should give an output like:

inet 10.1.1.30/24 brd 10.1.1.255 scope global eth0
inet 10.1.1.31/24 brd 10.1.1.255 scope global wlan0
(ignore any lo entry)

The first address is the IP address of your Pi on the network, and the part after the slash is the network size. It is highly likely that yours will be a /24.

The second address is the brd (broadcast) address of the network.

Find the address of your router (or gateway)

ip route | grep default | awk '{print $3}'

10.1.1.1
Finally note down the address of your DNS server, which is often the same as your gateway.

cat /etc/resolv.conf

# Generated by resolvconf
nameserver 10.1.1.1
Then follow ONE of the following options. (There are other methods not documented here. These are the most common on Raspbian.) (In either method, and in the discovery above, substitute the appropriate network interface name for eth0 or wlan0.)

dhcpcd method

Leave /etc/network/interfaces at its default (as above).

Edit /etc/dhcpcd.conf as follows:-

Here is an example which configures a static address, routes and dns.
interface eth0
static ip_address=10.1.1.30/24
static routers=10.1.1.1
static domain_name_servers=10.1.1.1

interface wlan0
static ip_address=10.1.1.31/24
static routers=10.1.1.1
static domain_name_servers=10.1.1.1
ip_address is the address and size from the command above (or another unused address on the same network),
routers is the address of your router (or gateway).
domain_name_servers is the DNS address(es) from /etc/resolv.conf.
(see man dhcpcd.conf)

Then disable the DHCP client daemon and switch to standard Debian networking:

sudo systemctl disable dhcpcd
sudo systemctl enable networking
Reboot for the changes to take effect:

sudo reboot
https://raspberrypi.stackexchange.com/q ... ip-address

Side Note- I will be placing the output for all the command that are listed above under this line.

This is the output from sudo cat /etc/os-relase to ensure that I have provided all the pertinent info regarding my pi

[PRETTY_NAME="Raspbian GNU/Linux 8 (jessie)"
VERSION_ID="8"
VERSION="8 (jessie)"
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

Code: Select all

 ip-4 addr show | grep inet 
inet 99.177.130.170/22 brd 99.177.131.255 scope global wlan0

Code: Select all

 ip route | grep default | awk '{print $3}' 
99.177.128.1

Code: Select all

 cat /etc/resolv.conf 
# Generated by resolv.conf nameserver 192.168.1.254

After I obtained all the nesscary networking information for my static IP I made changes to my "/etc/dhcpcd.conf file and placed them at the bottem of the last line.
#A hook scripct is provided to lookup the hostname if not set by the DHCP
# server, but it should not be run by default.
nohook lookup-hostname

interface wlan0
static ip_address=99.177.130.170/22
static routers=99.177.128.1
static domain_name_servers=192.168.1.254

I appreciate you all for taking the time to read through my issue, I hope this issue can be solved until then enjoy your Pi's!

User avatar
KLL
Posts: 1453
Joined: Wed Jan 09, 2013 3:05 pm
Location: thailand
Contact: Website

Re: Static IP Addressing issues (Wlan0)

Tue Oct 24, 2017 9:20 am

i have not the slightest idea what you try to do, or what is so special about your network setup....
but as you say you have issues, i show you my setup with what i never have issues, info: my router is on 192.168.1.1
you better find a way to scan your network first ( like by mobile fing app ) so you know what IP is free for your RPIs..
but never use a IP what is given to you by router, check router setup for this range...

for my RPI3 i use:

sudo nano /etc/dhcpcd.conf
add at end:

Code: Select all

interface eth0
static ip_address=192.168.1.103/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1 8.8.8.8 8.8.4.4

interface wlan0
static ip_address=192.168.1.203/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1 8.8.8.8 8.8.4.4
possibly just the static domain_name_servers= line helps.

after this edit just reboot

User avatar
RaTTuS
Posts: 10610
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: Static IP Addressing issues (Wlan0)

Tue Oct 24, 2017 9:32 am

inet 99.177.130.170/22 brd 99.177.131.255 scope global wlan0
CODE: SELECT ALL
ip route | grep default | awk '{print $3}'
99.177.128.1
CODE: SELECT ALL
why these addresses
as you will not be able to route to 192.168.x.x with those set,

use your router to set any static ip address

dont chose them from out of the air
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

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

Re: Static IP Addressing issues (Wlan0)

Tue Oct 24, 2017 9:44 am

A non-technical reply.

It seems from the IP addressing and Routing information that you have gleaned about your network connection that this is not a private home network, but probably a network provided for you in a business, company, university, hospital or similar?

If that is the case, simply contact the Help Desk or Network Support team responsible for your connection. If you are entitled to use the network in the way you intend they will be best placed to help you. There may be administrative restrictions in the network configuration that would prevent unauthorized connections.

PureAfrican
Posts: 4
Joined: Mon Oct 23, 2017 6:01 pm

Re: Static IP Addressing issues (Wlan0)

Tue Oct 24, 2017 10:37 am

The IP values in question have been obtain from ifconfig.

99.177.130.170 is the address currently set by DHCP for my Pi &
99.177.131.255 is the broadcast.

You are correct about not being able to route that address.
I have made the necessary changes and my static route now reflects the address of my router not my Pi.
RaTTuS wrote:
Tue Oct 24, 2017 9:32 am
inet 99.177.130.170/22 brd 99.177.131.255 scope global wlan0
CODE: SELECT ALL
ip route | grep default | awk '{print $3}'
99.177.128.1
CODE: SELECT ALL
why these addresses
as you will not be able to route to 192.168.x.x with those set,

use your router to set any static ip address

dont chose them from out of the air

PureAfrican
Posts: 4
Joined: Mon Oct 23, 2017 6:01 pm

Re: Static IP Addressing issues (Wlan0)

Tue Oct 24, 2017 10:40 am

Actually that address was provided to me by DHCP and set for my Pi not my router, I appreciate your out of the box thinking tho.
B.Goode wrote:
Tue Oct 24, 2017 9:44 am
A non-technical reply.

It seems from the IP addressing and Routing information that you have gleaned about your network connection that this is not a private home network, but probably a network provided for you in a business, company, university, hospital or similar?

If that is the case, simply contact the Help Desk or Network Support team responsible for your connection. If you are entitled to use the network in the way you intend they will be best placed to help you. There may be administrative restrictions in the network configuration that would prevent unauthorized connections.

PureAfrican
Posts: 4
Joined: Mon Oct 23, 2017 6:01 pm

Re: Static IP Addressing issues (Wlan0)

Tue Oct 24, 2017 10:50 am

I believe I got my addresses mixed up as I placed the IP address that was set for my Raspberry Pi 3 for my static route when I should have instead placed the address for router.
I also made changes to my static IP address and ensured that it was set outside the DHCP addressing pool, I am now able to ping Google and connect to internet with my newly set static IP!

I appreciate everyone's help with my issue and I actually learned alot, this thread can be closed.
KLL wrote:
Tue Oct 24, 2017 9:20 am
i have not the slightest idea what you try to do, or what is so special about your network setup....
but as you say you have issues, i show you my setup with what i never have issues, info: my router is on 192.168.1.1
you better find a way to scan your network first ( like by mobile fing app ) so you know what IP is free for your RPIs..
but never use a IP what is given to you by router, check router setup for this range...

for my RPI3 i use:

sudo nano /etc/dhcpcd.conf
add at end:

Code: Select all

interface eth0
static ip_address=192.168.1.103/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1 8.8.8.8 8.8.4.4

interface wlan0
static ip_address=192.168.1.203/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1 8.8.8.8 8.8.4.4
possibly just the static domain_name_servers= line helps.

after this edit just reboot

Hishashigupta
Posts: 2
Joined: Mon Dec 19, 2016 11:44 pm

Re: Static IP Addressing issues (Wlan0)

Wed Sep 30, 2020 6:02 am

Thank you, I had some misconfigurations in my dhcpcd.conf and this post really helped me out fix my issue.

Return to “Beginners”