timl
Posts: 44
Joined: Sat May 04, 2013 3:41 am

static IP add for wifi

Sat May 04, 2013 4:09 am

Hi, I have been tinkering with the Pi I just received and I would like to configure a static IP address on the wifi connection - DHCP works fine but I plan to access this remotely so I would like a fixed address. I should point out that I tend to use Fedora/Centos so the world of raspbian has a few challenges for me :?

The first suggestions I read regarded the /etc/network/interface file which I modified thus (I renamed it when I could not get it to work):
pi@raspberrypi ~ $ cat /etc/network/interfaces.man
auto lo

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
iface wlan0 inet manual

address 10.1.1.91
netmask 255.255.255.0
gateway 10.1.1.1
#wpa-ssid TP-LINK_CF9006

wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
#iface default inet dhcp
I experimented with the ssid or the wpa_supplicant.conf file (which referenced that ssid) but ifup had problems with both.

Then I read about wicd which I installed. I set up the static address 10.1.1.91 as above, defined netmask, gateway and DNS server, used wicd to disconnect/connect and all was good - I had the address set up how I wanted it. I ticked the box to "automatically connect" and rebooted.

After the reboot the wireless connection was active but it had lapsed back to the DHCP address allocated before - 10.1.1.101.

So...any recommendations for the configuration of /etc/network/interface? Or, is there anything I missed out in wicd?

Thanks

eplimish
Posts: 1
Joined: Sun May 12, 2013 9:10 pm

Re: static IP add for wifi

Sun May 12, 2013 9:24 pm

Hi timl,

I hope you already have found your answer.

I've just been doing the same thing (one week later) - this post by jb1000 provided the answer, both to keeping your WiFi passwords clear of /etc/network/interfaces and to providing a static ip address to wlan0.

http://www.raspberrypi.org/phpBB3/viewt ... 26&t=22660

The trick is using id_str in /etc/wpa_supplicant/wpa_supplicant.conf.

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

Re: static IP add for wifi

Mon May 13, 2013 2:44 am

Instead of a static setup, what I do is configure my router for IP to MAC address reservations (DHCP). When setup like this the router (DHCP) will always give the RPi the same IP address. No configuration needed on the RPi itself for basic things like SSH, RDP etc.
I have a tutorial on my web page showing how to do reservations on a Linksys router. Other routers are similar.
http://home.budget.net/~klricks/Comp/RPi/DHCP.html
Last edited by klricks on Fri Jan 17, 2014 1:17 pm, edited 1 time in total.
Unless specified otherwise my response is based on the latest and fully updated Raspbian Buster w/ Desktop OS.

SirLagz
Posts: 1705
Joined: Mon Feb 20, 2012 8:53 am
Location: Perth, Australia
Contact: Website

Re: static IP add for wifi

Mon May 13, 2013 2:51 am

timl wrote:
pi@raspberrypi ~ $ cat /etc/network/interfaces.man
auto lo

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
iface wlan0 inet manual

address 10.1.1.91
netmask 255.255.255.0
gateway 10.1.1.1
#wpa-ssid TP-LINK_CF9006

wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
#iface default inet dhcp
So...any recommendations for the configuration of /etc/network/interface?

Thanks
You want to use the word 'static' and not 'manual' in /etc/network/interfaces like so -

Code: Select all

auto wlan0
iface wlan0 inet static
address 10.1.1.91
netmask 255.255.255.0
gateway 10.1.1.1
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
My Blog - http://www.sirlagz.net
Visit my blog for Tips, Tricks, Guides and More !
WiFi Issues ? Have a look at this post ! http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=44044

mmcbride0303
Posts: 1
Joined: Fri Jan 17, 2014 4:32 am

Re: static IP add for wifi

Fri Jan 17, 2014 4:41 am

This is not just a Wifi issue. it is an overall connection problem. I just got a Rpi. I am trying to enable my networking. Off the bat, dchp works fine and I can connect, download packages, etc. But I am trying to set up a static ip for my pi so I can port forward/connect remotely via ssh etc. (pi connected via ethernet to back of router). All attempts thus far have failed. I have followed every tutorial for both the operating systems I am trying to run A.) Arch and B.) Raspian. Attempting to set up and static IP has failed on both and after which, my dhcp services become corrupted and I cannot connect at all. I don't want to think it is an Rpi hardware flaw, but moreso i believe it is a router issue. I know this is a wide open question, but any ideas?

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

Re: static IP add for wifi

Fri Jan 17, 2014 1:37 pm

mmcbride0303 wrote:This is not just a Wifi issue. it is an overall connection problem. I just got a Rpi. I am trying to enable my networking. Off the bat, dchp works fine and I can connect, download packages, etc. But I am trying to set up a static ip for my pi so I can port forward/connect remotely via ssh etc. (pi connected via ethernet to back of router). All attempts thus far have failed. I have followed every tutorial for both the operating systems I am trying to run A.) Arch and B.) Raspian. Attempting to set up and static IP has failed on both and after which, my dhcp services become corrupted and I cannot connect at all. I don't want to think it is an Rpi hardware flaw, but moreso i believe it is a router issue. I know this is a wide open question, but any ideas?
Sounds like you have not set the static IP in the router correctly.

As I mentioned above..... Instead of a static setup I would do IP to MAC reservations under DHCP. This way the router will always give the same IP of your choice to the RPi, but there is no configuration to do at all in the RPi. Just leave it at the default DHCP enabled.
Unless specified otherwise my response is based on the latest and fully updated Raspbian Buster w/ Desktop OS.

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

Re: static IP add for wifi

Fri Jan 17, 2014 1:49 pm

klricks wrote:
mmcbride0303 wrote:This is not just a Wifi issue. it is an overall connection problem. I just got a Rpi. I am trying to enable my networking. Off the bat, dchp works fine and I can connect, download packages, etc. But I am trying to set up a static ip for my pi so I can port forward/connect remotely via ssh etc. (pi connected via ethernet to back of router). All attempts thus far have failed. I have followed every tutorial for both the operating systems I am trying to run A.) Arch and B.) Raspian. Attempting to set up and static IP has failed on both and after which, my dhcp services become corrupted and I cannot connect at all. I don't want to think it is an Rpi hardware flaw, but moreso i believe it is a router issue. I know this is a wide open question, but any ideas?
Sounds like you have not set the static IP in the router correctly.

As I mentioned above..... Instead of a static setup I would do IP to MAC reservations under DHCP. This way the router will always give the same IP of your choice to the RPi, but there is no configuration to do at all in the RPi. Just leave it at the default DHCP enabled.
WHS...
TBH the best way is to get the router to do this - not all routers can but most do - this way you are able to set the RPi address [both ethernet and wifi] to what you want and make it so that your RPi will work with other places with minimum fuss
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
default_user8
Posts: 678
Joined: Mon Nov 18, 2013 3:11 am

Re: static IP add for wifi

Fri Jan 17, 2014 2:28 pm

If you are having problems setting up a static ip on your router get the current firmware from the manufacturer and update your router. If like me you are using dd-wrt firmware for your router you have to understand that not all routers are able to run the full version of dd-wrt and as a result pf that not all features are available. I highly recommend dd-wrt even if you have to replace your router with one that will run the full version it is worth it.
Two heads are better than one, unless one's a goat head.

User avatar
Richard-TX
Posts: 1549
Joined: Tue May 28, 2013 3:24 pm
Location: North Texas

Re: static IP add for wifi

Fri Jan 17, 2014 2:39 pm

I have had problems with supplicant.

Here is the interface file that works for me every single time.

Edit the IPs,ssid, and password then reboot.

Code: Select all

    auto lo

    iface lo inet loopback
    iface eth0 inet static
    address 10.232.1.81
    netmask 255.255.255.0
    gateway 10.232.1.1


    auto wlan0
    allow-hotplug wlan0
    iface wlan0 inet static
    address 10.232.1.99
    netmask 255.255.255.0
    gateway 10.232.1.1
    wpa-passphrase password
    wpa-ssid myssid
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip

bcatalin
Posts: 23
Joined: Mon Jan 30, 2012 9:45 am

Re: static IP add for wifi

Thu Mar 19, 2015 6:03 am

@Richard
And what is happening if you setup both IP addresses for eth0 and wifi to be the same. You will have the same IP if you are
connected on wire or via wifi. Can you tell us what is in your /etc/resolv.conf file ?

pagalengineer
Posts: 2
Joined: Sun May 10, 2015 4:15 am

Re: static IP add for wifi

Sun May 10, 2015 4:18 am

thanks @richard , your settings worked perfectly

Return to “Beginners”