I have discovered that you can set parameters in /etc/rc.conf, /etc/conf.d/dhcpcd and /etc/conf.d/wireless to do all of the above, using dhcpcd to set up wireless for either static or dynamic IP address/subnet. In order to use dhcpcd, it's enough simply to set ra0="dhcp" as in the following code snippet of /etc/rc.conf:
- Code: Select all
#Static IP example
eth0="eth0 192.168.0.2 netmask 255.255.255.0 broadcast 192.168.0.255"
ra0="dhcp" # a static IP address can be requested in /etc/conf.d/dhcpcd
INTERFACES=(eth0 ra0)
If you want a dynamic IP address for ra0, you don't need to change anything in /etc/conf.d/dhcpcd. On the other hand, if you want to set up a static IP address/subnet for ra0, you can get dhcpcd to do this by changing the definition of DHCPCD_ARGS in /etc/conf.d/dhcpcd as follows ("-m 1" sets the interface metric; -A avoids using ARP; "-C hostname" avoids messing with the hostname; "-C resolv.conf" avoids messing with /etc/resolv.conf; "-E" tries to resurrect an unexpired lease; -K ignores a dropped carrier; -L ignores link-local):
- Code: Select all
DHCPCD_ARGS="-q -m 1 -r 192.168.0.102 -A -C hostname -C resolv.conf -E -K -L --noipv6rs"
As I am using static IP addresses for eth0 and ra0, I added static default gateways for each of these, giving a higher priority to eth0:
- Code: Select all
#gateway="default gw 192.168.0.1"
#ROUTES=(!gateway)
gateway_eth0="default gw 192.168.0.1 metric 0 dev eth0"
gateway_ra0="default gw 192.168.0.1 metric 1 dev ra0"
ROUTES=(gateway_eth0 gateway_ra0)
Finally, I added some lines to the end of /etc/conf.d/wireless to set the wireless password, etc.:
- Code: Select all
WIRELESS_TIMEOUT=2 # sleep awhile after bringing up ra0, before starting dhcpcd
if [[ "$0 $1" = "/etc/rc.d/network start" ]] ; then
ifconfig ra0 up
iwpriv ra0 set WirelessMode=0 # 0=bg 1=b 2=a 3=abg 4=g 5=abgn 6=n 7=gn 8=an 9=bgn 10=agn
iwpriv ra0 set AuthMode=WPA2PSK
iwpriv ra0 set EncrypType=AES
iwpriv ra0 set WPAPSK="Your wireless access point password"
sleep ${WIRELESS_TIMEOUT}
fi
wlan_ra0="ra0 mode managed essid YourWirelessAccessPointName"
WLAN_INTERFACES=(ra0)
Consider this an update to my method that WarheadsSE quoted in the first post of this thread. Apparently it is important to use dhcpcd to do the necessary handshaking between the wireless card and the router. This remains true even if you want to set up a static IP address; I was having as much trouble as everyone else until I discovered this.