Solved Making switch. Wlan and ethernet ports bridging. The right way.

Hi there. So I said I am making a switch but that is not completely true but that describes it well. I have an RPI. ethernet on it used to connect to the internetses.
Rpi has two usb adapters - WiFi and Ethernet. I am sharing network to this adapters, nat, pf. WiFi is a AP. That is where things get complicated
I want the adapters to share the subnet, let's say 192.168.2.0/24 so create a bridge0 and add them to the bridge
ifconfig bridge0 addm ue1 addm wlan0
I give bridge0 an IP
ifconfig bridge0 inet 192.168.2.1 netmask 255.255.255.0
I bring all the interfaces up. Everything seems to work
I run dhcpd on bridge0 since it is the only interface with subnet definition.

Now, the part I don't understand: When I connect a client to ethernet adapter, immediately ue1 gets an IP address from dhcpd range as well as client getting an IP address. It doesn't seem to affect anything at the moment however I understand that something is misconfigured and will cause some problems in the future. Hence I wanted to find out what.

That said, another glitch I observed was that device on wifi and another device on ethernet had the same IP address but that happened once and didn't reproduce so I thing it is ust glitched because of the setup testing and it might have had an arp record etc.

Any way, please let me know if I missed some details. I would appreciate any help I can get.
 
Hi,

maybe you have ue1 configured in rc.conf with "DHCP" option? When you connect a network cable to the nic, the adapter comes up and request a ip address as any other client.
This is my rc.conf with a similar setup:

Code:
wlans_ath0="wlan0"
create_args_wlan0="wlanmode hostap ssid xxxx channel 11"
hostapd_enable="YES"

cloned_interfaces="bridge0"
ifconfig_bridge0="inet xx.xx.xx.x/24 addm igb0 addm igb1 addm wlan0 up"
ifconfig_igb0="up"
ifconfig_igb1="up"
ifconfig_wlan0="up"
 
Ok I figured out why it was getting IP. There was a small default entry in /etc/rc.conf
Code:
ifconfig_DEFAULT="DHCP inet6 accept_rtadv"
Which cause it to try and acquire IP address by means of dhcp. It would fail it on start cause it wasdoing it before dhcpd would start but when I connect a client to it - it would try again and succeed.

Still question remains if the way I set up is correct.
 
According to your description, this is supposed to be an internet router. The question is what your performance requirements are. Of course, it won't be great with USB adapters, especially between the two USB adapters, wlan0 and the usb-nic. The double ip-address could be caused by a configuration problem with the lease times in combination with the ping check from dhcpd and a non-responding client (windows firewall) or another client which doesn't answer on ping's. Take a look at these configurations. But otherwise the configuration seems to be ok, an external interface, internally a bridge with several member interfaces, in between the pf which also handles NAT and dhcpd connected to the bridge for the internal client's.
 
Hi,

maybe you have ue1 configured in rc.conf with "DHCP" option? When you connect a network cable to the nic, the adapter comes up and request a ip address as any other client.
This is my rc.conf with a similar setup:

Code:
wlans_ath0="wlan0"
create_args_wlan0="wlanmode hostap ssid xxxx channel 11"
hostapd_enable="YES"

cloned_interfaces="bridge0"
ifconfig_bridge0="inet xx.xx.xx.x/24 addm igb0 addm igb1 addm wlan0 up"
ifconfig_igb0="up"
ifconfig_igb1="up"
ifconfig_wlan0="up"
Yeah, I posted below that was exactly the problem. I forgot this small detail. I create the config automatically through the app I’m writing and I left the default entries and forgot about them. Now it seems to be working as expected.

Thank you
 
According to your description, this is supposed to be an internet router. The question is what your performance requirements are. Of course, it won't be great with USB adapters, especially between the two USB adapters, wlan0 and the usb-nic. The double ip-address could be caused by a configuration problem with the lease times in combination with the ping check from dhcpd and a non-responding client (windows firewall) or another client which doesn't answer on ping's. Take a look at these configurations. But otherwise the configuration seems to be ok, an external interface, internally a bridge with several member interfaces, in between the pf which also handles NAT and dhcpd connected to the bridge for the internal client's.
Performance is terrible, naturally. Wifi adapter gives maximum 20mbps and Ethernet is around 60 but that is fine for my purposes. In the future I might build a different solution with gateway and separate switch but so far rpi is enough.

Thank you for your reply
 
Back
Top