Re: auto add usb network to bridge

2023-09-25 Thread Petric Frank
Hello Reco,

the "allow-hotplug ..." and "up /sbin/ip ..." what what i was missing. Works
like a charm.

Thanks for your and others support.

regards
  Petric

Am Montag, 25. September 2023, 11:50:32 CEST schrieb Reco:
>   Hi.
>
> On Mon, Sep 25, 2023 at 11:35:50AM +0200, Petric Frank wrote:
> > My /etc/network/interfaces reads like this:
> > -- cut 
> > auto lo
> > iface lo inet loopback
> >
> > # onloard device
> > iface ens18 inet manual
> >
> > # usb device (not always there)
> > iface enx0 inet manual
> >
> > auto br0
> > iface br0 inet static
> >
> >   address 10.10.10.1/24
> >   bridge-ports ens18 enx0
> >   bridge-stp off
> >   bridge-fd 0
> >
> > -- cut 
> >
> > This works as long the usb device is plugged in at boot time.
> >
> > Connecting it later the usb network device appears but will not be
> > attached to  the bridge.
> You have to do it differently, like this:
>
> auto lo
> iface lo inet loopback
>
> # onloard device
> iface ens18 inet manual
>
> # usb device (not always there)
> allow-hotplug enx0
> iface enx0 inet manual
> up /sbin/ip link set $IFACE master br0
>
> auto br0
> iface br0 inet static
>   address 10.10.10.1/24
>   bridge-ports ens18
>   bridge-stp off
>   bridge-fd 0
>
> What that does is forces udev to execute "ifup enx0" on USB device
> detection, which in turn causes the network interface to attach to br0.
>
> Reco






Re: auto add usb network to bridge

2023-09-25 Thread Reco
Hi.

On Mon, Sep 25, 2023 at 11:35:50AM +0200, Petric Frank wrote:
> My /etc/network/interfaces reads like this:
> -- cut 
> auto lo
> iface lo inet loopback
> 
> # onloard device
> iface ens18 inet manual
> 
> # usb device (not always there)
> iface enx0 inet manual
> 
> auto br0
> iface br0 inet static
>   address 10.10.10.1/24
>   bridge-ports ens18 enx0
>   bridge-stp off
>   bridge-fd 0
> -- cut 
> 
> This works as long the usb device is plugged in at boot time.
> 
> Connecting it later the usb network device appears but will not be attached 
> to  the bridge.

You have to do it differently, like this:

auto lo
iface lo inet loopback

# onloard device
iface ens18 inet manual

# usb device (not always there)
allow-hotplug enx0
iface enx0 inet manual
up /sbin/ip link set $IFACE master br0

auto br0
iface br0 inet static
address 10.10.10.1/24
bridge-ports ens18
bridge-stp off
bridge-fd 0

What that does is forces udev to execute "ifup enx0" on USB device
detection, which in turn causes the network interface to attach to br0.

Reco



Re: auto add usb network to bridge

2023-09-25 Thread Nicolas George
Petric Frank (12023-09-25):
> a special problem. I have a debian (12) machine which has an onboard network
> card. This machine acts as dhcp-server also.
> 
> Now i want to add a usb network device. But this is not always there. It is
> plugged in when needed. And it should serve the same network as the onboard
> one.
> 
> My idea was to create a bridge and attach the host network interface to it.
> The problem now is how to get the usb network card attached to the bridge when
> plugged in.

Hi.

I used to do just that to bridge my two wlan adapters (until a reboot
where the mt76x2u started to refuse to believe it was not in China and
to use the 5 GHz band; I switched to stand-alone mesh access points).
Here is my config:

auto wlanA
iface wlanA inet static
address 10.0.128.1
netmask 255.255.255.0
network 10.0.128.0
broadcast 10.0.128.255
bridge_ports none
post-up systemctl try-reload-or-restart isc-dhcp-server.service

iface wlan0 inet manual
post-up iw dev wlan0 set 4addr on || true
post-up ip link set dev wlan0 master wlanA
post-up systemctl start hostapd@wlan0.service
pre-down systemctl stop hostapd@wlan0.service

iface wlan1 inet manual
post-up iw dev wlan1 set 4addr on || true
post-up ip link set dev wlan1 master wlanA
post-up systemctl start hostapd@wlan1.service
pre-down systemctl stop hostapd@wlan1.service

I think the lines that will be of use for you are “bridge_ports none”
and “post-up ip link set dev wlan* master”.

Regards,

-- 
  Nicolas George



auto add usb network to bridge

2023-09-25 Thread Petric Frank
Hello,

a special problem. I have a debian (12) machine which has an onboard network
card. This machine acts as dhcp-server also.

Now i want to add a usb network device. But this is not always there. It is
plugged in when needed. And it should serve the same network as the onboard
one.

My idea was to create a bridge and attach the host network interface to it.
The problem now is how to get the usb network card attached to the bridge when
plugged in.

My /etc/network/interfaces reads like this:
-- cut 
auto lo
iface lo inet loopback

# onloard device
iface ens18 inet manual

# usb device (not always there)
iface enx0 inet manual

auto br0
iface br0 inet static
  address 10.10.10.1/24
  bridge-ports ens18 enx0
  bridge-stp off
  bridge-fd 0
-- cut 

This works as long the usb device is plugged in at boot time.

Connecting it later the usb network device appears but will not be attached to
the bridge.

Any hints ?

regards
  Petric