How to set a new ip address to the device every time you connect to wifi

Hello. I have two AP. They have different local interfaces with different subnets 192.168.99.0/24 and 192.168.55.0/24. When i connect phone to first AP - i get ip 192.168.99.*. Next when i reconnect to second AP - i have old ip until i reboot my router. I need to change device local ip immediately when switching wifi hotspots. Help me please, how i can do it?

use random MAC on the phone

2 Likes

If you have configured the APs as "dumb APs", they should be on the same network; otherwise, they are acting as routers. The phone should detect it has connected to a new network, and request a new DHCP lease; I wonder why that is not happening.

I think we need to know how is each device configured exactly.

config interface 'loopback'                    
        option device 'lo'                     
        option proto 'static'                  
        option ipaddr '127.0.0.1'              
        option netmask '255.0.0.0'             
                                               
config globals 'globals'                       
        option packet_steering '1'             
        option ula_prefix 'fd7b:1504:d175::/48'
                                      
config device                         
        option name 'br-lan'          
        option type 'bridge'          
        list ports 'lan1'             
        list ports 'lan2'             
        list ports 'lan3'

config interface 'lan'                                                          
        option device 'br-lan'                                                  
        option proto 'static'                                                   
        option netmask '255.255.255.0'                                          
        option ip6assign '60'                                                   
        option ipaddr '192.168.99.1'                                            
                                                                                
config interface 'wan'                                                          
        option device 'wan'                                                     
        option proto 'dhcp'                                                     
                                                                                
config interface 'wan6'                                                         
        option device 'wan'                                                     
        option proto 'dhcpv6'                                                   
                                                                                
config interface 'wwan'                                                         
        option proto 'dhcp'                                                     
                                                                                
config interface 'OpenVPN'                                                      
        option proto 'none'                                                     
        option device 'tun0'                                                    
                                                                                
config interface 'lan2'                                                         
        option proto 'static'                                                   
        option device 'br-lan'                                                  
        option ipaddr '192.168.55.1'                                            
        option netmask '255.255.255.0'

lan - first AP, lan2 - second AP. When i reconnect to different AP's from phone, notebook or pc. IP don't change until i reboot my router or forget AP from device. Need too assign new ip always when connect to AP

And this is wireless config

config wifi-iface 'default_radio0'                                      
        option device 'radio0'                                          
        option mode 'ap'                                                
        option ssid 'CER_2Ghz'                                          
        option encryption 'psk2'                                                                          
        option network 'lan2' 

config wifi-iface 'default_radio1'                                      
        option device 'radio1'                                          
        option network 'lan'                                            
        option mode 'ap'                                                
        option ssid 'CER_5Ghz'                                          
        option encryption 'psk2'                                                                        
                                                                        
config wifi-iface 'wifinet2'                                            
        option device 'radio1'                                          
        option mode 'sta'                                               
        option network 'wwan'                                           
        option ssid 'Sirius_5G'                                         
        option encryption 'psk2'

You have two "lan" interfaces with static network range and DHCP server in the same "br-lan" device, which doesn't make sense at all. If you need to have them separated, you actually need to separate them, both "physically" and in firewall zones.

As it stands right now, there is probably a game of chance for any device which DHCP server answers first and gives them an IP. And since IPs are given out based on MAC addresses, a device will have a 50% chance of getting the same IP again.

2 Likes

Thank you. I created a second physical device br-lan2, created firewall zone for lan2. Configured it right and now i get new ip from true subnets always when reconnect to different AP's.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.