wouter1
Posts: 1
Joined: Mon Mar 31, 2014 12:13 am

giving the wlan0 a static ip address

Mon Mar 31, 2014 12:46 am

hi,

i have spent 4 hours to get my tp-linkwn725 visible in the wifi-config....
now it says when i start browsing with midori unable to resolve hostname.
if have found out that you need to give the pi a static ip address.
main adress is on my router... i guess but how about the netmask, gateway, network and broadcast?
please some insight...

regards,

Wouter

Tarcas
Posts: 741
Joined: Thu Jan 09, 2014 5:38 am
Location: USA

Re: giving the wlan0 a static ip address

Mon Mar 31, 2014 1:59 am

netmask, gateway, network and broadcast
Netmask will be the same as on other devices on your network. Usually 255.255.255.0

Gateway will always be the IP of your router.

Network depends on your IP and netmask. If the netmask is all 255s and 0s, it's easy. Any octet where there's a 255, the network address is the same as the IP address. For octets where the netmask has a 0, the network has a 0. If your netmask is not all 255s and 0s, paste the IP and netmask here and someone can do the math for you.

Broadcast also depends on the IP and netmask. Assuming the netmask is all 255s and 0s, find the network, but for any octet where the network has a 0, replace it with a 255. Again, if your netmask is not all 255s and 0s, paste the IP and netmask here and someone can do the math for you.

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

Re: giving the wlan0 a static ip address

Mon Mar 31, 2014 5:11 am

That is really a loaded question. A lot depends on how your local lan is configured. A good place to look is on your internet router. The configuration for most routers for a LANs is an 8 bit /24 bit subnetting scheme.
Let's say that the router sets up your local lan with a 192.168.2.0 network.
That means you can have a possible 254 host addresses. So here is how that translates to your Rpi setup.
broadcast 192.268.2.255
gateway router-ip-address
netmask 255.255.255.0

If is unlikely that your router would set up your local lan as anything other than a 8/24 bit network .
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

User avatar
DougieLawson
Posts: 39303
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: giving the wlan0 a static ip address

Mon Mar 31, 2014 8:47 pm

Isn't it best to start by looking at the network config that DHCP gives you.

ifconfig -a
route -n

Or look at a Windows machine with
ipconfig /all

That gives you all the info you need to get started with assigning a static address (although you may need to look at the DHCP settings on your router to reserve a range of IP addresses that won't be dynamically assigned).

If your router can do static IP based on MAC address then it's much easier to use that. (I've never met a router that can do that stuff - we can but hope.)

This all gets easier with IPv6 where hardware MAC forms part of the assigned IPv6 address automagically so every machine gets a fixed IPv6 within the /64 network prefix.

BTW, do NOT code broadcast in /etc/network/interfaces it's much better to leave it out as Linux is perfectly capable of working it out from ip addr, gateway & netmask.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

mefd5791
Posts: 3
Joined: Thu Apr 03, 2014 7:03 pm

Re: giving the wlan0 a static ip address

Thu Apr 03, 2014 7:06 pm

Okay so I've been trying to set up a static ip on my rpi as well, and this post is the first post that's telling me that the network and broadcast depend on the netmask.... and that's a problem because my netmask is 255.255.252.0. my gateway (router ip) is 10.2.12.1

Can someone help?

User avatar
DougieLawson
Posts: 39303
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: giving the wlan0 a static ip address

Thu Apr 03, 2014 7:38 pm

Why do you need a /22 network are there really 1024 stations on your LAN segment?

The basics are just the same
netmask
gateway
& local ip.

Everything should just work itself out.

Base address 10.2.12.0
Broadcast 10.2.15.255
Host mask 0.0.3.255
Next base 10.2.16.0

As long as the gateway is somewhere between 10.2.12.1 and 10.2.15.254 it will be OK.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

Return to “Beginners”