Zé Loff <zel...@zeloff.org> writes:

>> On 24/12/2015, at 10:07, Timo Myyrä <timo.my...@wickedbsd.net> wrote:
>>
>> Hi,
>>
>> I'm trying to use ifstated to switch between my laptops wireless and wired
>> interface
>
> man trunk

Just switched from using trunk as it won't renew the addresses. And I'd like
to
run the wireless down when I'm not using it to reduce power use.

>
>> Currently it works when I don't have cable plugged in but once I plug in
the
>> cable the ifstated starts to switch between wired and wireless states and
won't
>> stay in wired state.
>>
>> So it seems the em0.link.down condition gets triggered in wired state but
why?
>> The dhclient seems to run so the em0 should have IP and so it should be
up.
>>
>> Timo
>>
>> daemon:
>> Dec 24 10:43:29 phobos ifstated[31262]: changing state to wired
>> Dec 24 10:43:29 phobos dhclient[2004]: iwn0 down; exiting
>> Dec 24 10:43:33 phobos dhclient[22725]: DHCPREQUEST on em0 to
255.255.255.255
>> Dec 24 10:43:33 phobos dhclient[22725]: DHCPACK from 192.168.0.254
(00:1e:ab:0a:a4:a3)
>> Dec 24 10:43:33 phobos dhclient[22725]: bound to 192.168.0.105 -- renewal
in 43200 seconds.
>> Dec 24 10:43:33 phobos ifstated[31262]: changing state to wireless
>> Dec 24 10:43:33 phobos dhclient[5042]: em0 down; exiting
>> Dec 24 10:43:37 phobos dhclient[9581]: DHCPREQUEST on iwn0 to
255.255.255.255
>> Dec 24 10:43:37 phobos dhclient[9581]: DHCPACK from 192.168.0.254
(00:1e:ab:0a:a4:a3)
>> Dec 24 10:43:37 phobos dhclient[9581]: bound to 192.168.0.106 -- renewal in
43200 seconds.
>> Dec 24 10:44:29 phobos dhclient[9921]: DHCPREQUEST on iwn0 to
255.255.255.255
>> Dec 24 10:44:31 phobos findnwid: attached to network TW-EAV510v4A4A3 on
interface iwn0
>> ...
>>
>> ifstated.conf:
>> nwid  = '"[[ $(ifconfig iwn0 | sed -n \'/status/s/.*status: //p\') ==
\'active\' ]]" every 2'
>>
>> init-state wired
>>
>> state wireless {
>>    init {
>>        run "ifconfig em0 down"
>>        run "ifconfig iwn0 up"
>>        run "dhclient iwn0"
>>    }
>>
>>    # check if we have active wireless network
>>    # if not, re-check for networks
>>    if ! $nwid && em0.link.down
>>        run "/usr/local/bin/findnwid iwn0"
>>
>>    if em0.link.up
>>        set-state wired
>> }
>>
>> state wired {
>>    init {
>>        run "ifconfig iwn0 down"
>>        run "ifconfig em0 up"
>>        run "dhclient em0"
>>    }
>>
>>    if em0.link.down
>>        set-state wireless
>> }

Reply via email to