hemsingh
Posts: 2
Joined: Fri Aug 07, 2015 12:26 pm

Problem setting static ip on raspbian

Fri Aug 07, 2015 12:59 pm

Hello,
I have installed Raspbian os on Raspberry pi 2. I am setting wifi with static ip. The configuration in:
/etc/network/interfaces

.....
.....
auto wlan0
#allow-hotplug wlan0 #also tried it without comment
iface wlan0 inet static
address 192.168.2.101
netmask 255.255.255.0
#also tried with /without broadcast
gateway 192.168.2.1
dns-nameservers 202.56.215.54
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

......
.....
/etc/wpa_supplicant/wpa_supplicant.conf contents
......
.....
network={
ssid="mySSID"
psk="myPassword" #simple password key. not encrypted.
key_mgmt=WPA-PSK
# also tried many other options like proto, scan_ssid etc.. My SSID is not hidden
}

Sometime my internet is working and sometime not. If it works then it is so slow. The problem is that in GUI (desktop) the wifi icon at top-right corner of the screen is showing the different IP not the static IP that I set in /etc/network/interfaces.

Can anyone tell me how it will use only one static IP. i.e. the wifi icon should show the same IP that is in .../interfaces file.

I have spent many days trying from google but internet is still not working properly.

Thanks,
Hem Singh
Last edited by hemsingh on Mon Aug 10, 2015 5:35 am, edited 2 times in total.

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

Re: Problem setting static ip on raspbian

Sat Aug 08, 2015 10:01 am

hi hemsingh

1. i think the syntax for interfaces is ( but what i know )
dns-nameservers 8.8.8.8 8.8.4.4 and not dns-servers 202.56.215.54

2. address and gateway have a typo, "." missing

3. according KNUTE better not use interfaces for fix IP,
viewtopic.php?p=798866#p798866 its perfect!
sudo nano /etc/dhcpcd.conf

Code: Select all

interface eth0
static ip_address=192.168.1.101/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1
interface wlan0
static ip_address=192.168.1.201/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1 
and
sudo nano /etc/network/interfaces

Code: Select all

auto lo
iface lo inet loopback

auto eth0
allow-hotplug eth0
iface eth0 inet manual

auto wlan0
allow-hotplug wlan0
iface wlan0 inet manual
wpa-ssid "my-wlan"
wpa-psk "We_Love_RPi" 
and dhcpcdui show:
http://kll.engineering-news.org/kllfusi ... d_conf.png

hemsingh
Posts: 2
Joined: Fri Aug 07, 2015 12:26 pm

Re: Problem setting static ip on raspbian

Mon Aug 10, 2015 6:52 am

KLL wrote:hi hemsingh

1. i think the syntax for interfaces is ( but what i know )
dns-nameservers 8.8.8.8 8.8.4.4 and not dns-servers 202.56.215.54

2. address and gateway have a typo, "." missing

3. according KNUTE better not use interfaces for fix IP,
viewtopic.php?p=798866#p798866 its perfect!
sudo nano /etc/dhcpcd.conf

Code: Select all

interface eth0
static ip_address=192.168.1.101/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1
interface wlan0
static ip_address=192.168.1.201/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1 
and
sudo nano /etc/network/interfaces

Code: Select all

auto lo
iface lo inet loopback

auto eth0
allow-hotplug eth0
iface eth0 inet manual

auto wlan0
allow-hotplug wlan0
iface wlan0 inet manual
wpa-ssid "my-wlan"
wpa-psk "We_Love_RPi" 
and dhcpcdui show:
http://kll.engineering-news.org/kllfusi ... d_conf.png
Hi KLL,

Thanks for the reply. The mistakes you have seen was not in my config files. They were just here because I have typed these manually. But your reply solved my problem. By putting static IP values in /etc/dhcpcd.conf there is now single IP.

Thanks a lot,

Regards,
Hem Singh

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

Re: Problem setting static ip on raspbian

Mon Aug 10, 2015 9:05 am

hemsingh wrote:because I have typed these manually.
understand, n.p. i hope you can work headless like with "putty"... and learn/use copy paste in both way.
so my writing style here ( and in my blog )
command

Code: Select all

any code
has exactly that in mind, copy the command, paste it to putty, and the editor / file opens, and also copy paste code,
now only need [ctrl][o][enter][ctrl][x] to save it.
if it is 5 lines only, where you not need writing mistakes, or if it is a whole python code project.
a big step to productivity.
as much i like the Desktop / GUI tools, but as long most of us not use the RPI browser ( like for get info from this forum... )
browsing with PC and use the old style putty to RPi is still best.

Return to “Troubleshooting”