How do I use a static IP address with wireless networking?

Dynamic IP for wireless works:
in /etc/wpa_supplicant.conf
Code:
network={
  ssid="Name with spaces"
  psk="freebsdmall"
}
and in /etc/rc.conf
Code:
wlans_ath0="wlan0"
ifconfig_wlan0="WPA DHCP"

I tried to set a static IP to my wireless networking but it just didn't work. Also, the wireless SSID name has spaces (and I can't change it) and also a password (psk) is needed. How can I resolve this problem?
 
Last edited by a moderator:
I tried "ifconfig_wlan0="WPA NOSYNCDHCP"" and it didn't work.

I tried "WPA inet XXX.XXX.XXX.XXX..." and it didn't work as well.

What I need is to log on to the wireless router and at the same time set the static IP. I wonder how can I do it?
 
Set
Code:
ifconfig_wlan0="WPA inet <IP>"
eventually set ssid:
Code:
ifconfig_wlan0="WPA inet <IP> ssid <SSID of wireless router>"

Mandatory set default router:
Code:
defaultrouter="<IP of wireless router>"

Restart services:

service netif restart
service routing restart
 
Well, those "ifconfig_wlan0="WPA inet <IP> ssid <SSID of wireless router>"", etc. didn't work. It simply said "no carrier" on the status when I did a "ifconfig wlan0".

The ssid has spaces (I cannot change it), so I put single-quote with it. However, I don't think this is the reason it didn't work.
 
Yes, I did.

I'd like to confirm: what can I do to set an ssid with spaces? Do I put it in single-quotes?
 
Well, it does not work. DHCP just work fine. :-( I'm not sure what to do now... I need to configure the firewall and hope the DHCP address stays all the same.
 
Instead of "WPA DHCP" put "inet XXX.XXX.XXX.XXX"
I believe you are missing the subnet mask with this.

ifconfig wlan0= "WPA inet 000.000.000.000 netmask 000.000.000.000"
or
ifconfig wlan0="WPA inet 000.000.000.000/00"

Example for class C subnet:
ifconfig wlan0="WPA inet 192.168.1.100/24"
or
ifconfig wlan0="WPA inet 192.168.1.100 netmask 255.255.255.0"
 
Last edited:
I need to configure the firewall and hope the DHCP address stays all the same.

Might not be appropriate at your situation or I might have misunderstood above comment, but in pf that is not a problem:

pf.conf()

Host name resolution and interface to address translation are done
at ruleset load-time. When the address of an interface (or host
name) changes (under DHCP or PPP, for instance), the ruleset must
be reloaded for the change to be reflected in the kernel. Sur-
rounding the interface name (and optional modifiers) in parentheses
changes this behaviour. When the interface name is surrounded by
parentheses, the rule is automatically updated whenever the inter-
face changes its address. The ruleset does not need to be
reloaded. This is especially useful with [I]nat.[/I]
 
You are right. I seldom do it and get something like

inet 10.0.0.1 netmask 0xff000000 broadcast 10.255.255.255
10.x.x.x is a class A network. This classful designation isn't used much anymore, it's mostly classless nowadays. But many TCP/IP tools still fallback to this old behavior if you don't supply a subnet mask.

 
eg. /etc/rc.conf:
Code:
ifconfig_wlan0="WPA inet 192.168.1.XX netmask 255.255.255.0 ssid 'XYZQPZ'"
defaultrouter="192.168.Q.Z"
create_args_wlan0="country XY regdomain FCC4"

/etc/resolv.conf:
Code:
nameserver 192.168.Q.Z
 
Back
Top