Solved rc.d netif restart lagg0 and pf

im using a lagg failover device
with a usb ethernet adaptor

the issue is the lagg0 device doesnt pick up the ethernet device in ifconfig
( post at the bottom explains the problem in detail )

it should have this line under lagg0 in ifconfig

Code:
laggport: ue0 flags=5<MASTER,ACTIVE>

but it doesnt, probably because its a usb to ethernet adaptor
so i have to manually run the following commands after login to get pf working

Code:
doas service netif restart lagg0
doas service pf restart

i have to use netif to restart lagg0 and then restart pf
if you just restart netif it clears the routes

after running the above commands ifconfig does list laggport: ue0
which is the ethernet connection and pf works

i also have the same issue with my alfa usb wifi card
and you have use netif to restart lagg0 and then restart pf

so looks like an issue with usb ethernet and wifi adaptors and lagg

i would like to run the commands above automatically

so i need to create a rc.d script to

1 - use netif to restart lagg0
2 - restart pf

looking at the pratcical rc.d scripting page

it mentions REQUIRE, for example

Code:
# REQUIRE: NETWORKING

Keep in mind that putting a service name in the REQUIRE: line does not guarantee that the service will actually be running by the time our script starts.

i would have though i need to restart netif and pf after they have loaded

so would i need to use some like the following

Code:
# REQUIRE: NETWORKING pf

or would be pf be uppercase

Code:
# REQUIRE: NETWORKING PF

took quite a while to figure out why pf wasnt working with lagg0
and my usb ethernet adapator

and my brain is still a bit fried

if anyone could point in the general direction of how to create a rc.d script
that does the job that would be great

pratcical rc.d scripting

laggo failover device post
 
i tried the following in rc.conf

Code:
netwait_enable="YES"

but still the same issue

Code:
laggport: ue0 flags=5<MASTER,ACTIVE>

doesnt show up in ifconfig

'lagg0' is created in 'netif', but 'netwait' is invoked after 'netif',
so 'netwait' is not suitable to this case.

from that link it sound like you have to move ifconfig settings from rc.conf
to a script in

Code:
/usr/local/etc/rc.d

current rc.conf

Code:
/etc/rc.conf

Code:
# laggo failover device - bwn
# ethernet mac address set to wifi mac address
ifconfig_ue0="ether 04:0c:ce:d5:b0:ae"
cloned_interfaces="lagg0"
wlans_bwn0="wlan0"
ifconfig_wlan0="WPA"
create_args_wlan0="country US regdomain FCC"
ifconfig_lagg0="up laggproto failover laggport ue0 laggport wlan0 DHCP"

remove the ifconfig settings

Code:
# laggo failover device - bwn
# ethernet mac address set to wifi mac address
cloned_interfaces="lagg0"
wlans_bwn0="wlan0"
create_args_wlan0="country US regdomain FCC"

create a script called lagg-pf and make it executable

Code:
/usr/local/etc/rc.d/lagg-pf

rough guess

Code:
#!/bin/sh

# PROVIDE: lagg-pf
# REQUIRE: devd ipfw pf routing

ifconfig_ue0="ether 04:0c:ce:d5:b0:ae"
ifconfig_wlan0="WPA"
ifconfig_lagg0="up laggproto failover laggport ue0 laggport wlan0 DHCP"

and then in rc.conf enable the script

Code:
lagg-pf_enable="YES"

would obviously need more code than that
but its late at night
 
Code:
#!/bin/sh

# PROVIDE: lagg-pf
# REQUIRE: devd ipfw pf routing

ifconfig_ue0="ether 04:0c:ce:d5:b0:ae"
ifconfig_wlan0="WPA"
ifconfig_lagg0="up laggproto failover laggport ue0 laggport wlan0 DHCP"

This is backwards. The wlan MAC address should be set to the same as the ethernet address.

cloned_interfaces="lagg0"
ifconfig_em0="-tso4 wol_magic"
create_args_wlan0="wlanaddr nn:nn:nn:nn:nn:nn"
cloned_interfaces="lagg0"
ifconfig_lagg0="laggproto failover laggport em0 laggport wlan0 DHCP"

Put your Apple laptop's ethernet address into the wlan0 definition.
 
In theory, either the Ethernet or wireless MAC address can be changed to match the other.
However, some popular wireless interfaces lack support for overriding the MAC address. We therefore recommend overriding the Ethernet MAC address for this purpose.

 
i created an rc.d script called laggpf that does the job

i tried adding the ifconfig commands to the rc.script
but it didnt work for me

so i just use netif to restart lagg0
and then restart pf

i prefer this solution as it still keeps all the ifconfig settings in rc.conf
rather than splitting them into another file

Code:
/usr/local/etc/rc.d/laggpf

Code:
#!/bin/sh

# PROVIDE: laggpf
# REQUIRE: devd pf routing
# KEYWORD: nojail

. /etc/rc.subr

name=laggpf
desc="Wait for network devices or the network being up"
rcvar=laggpf_enable

start_cmd="${name}_start"
stop_cmd=":"

load_rc_config $name
: ${laggpf_enable:=no}
: ${laggpf_msg="Nothing started."}

laggpf_start()
{
    service netif restart lagg0
    service pf restart
}

run_rc_command "$1"

Code:
/etc/rc.conf

Code:
laggpf_enable="YES"

make sure the script is executable
job done
 
Back
Top