user5081013
user5081013

Reputation:

Android: Change gateway address of hot-spot

Is there a way to change the gateway address of the AP hot-spot feature of Android from 192.168.43.1 to something else such as 192.168.43.3 without recompiling anything? I have a rooted Android device.

Upvotes: 0

Views: 9921

Answers (1)

Sahil Bahl
Sahil Bahl

Reputation: 591

You are trying to change the settings that have been hardcoded for android hotspot.

This is from https://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.0.1_r1/android/net/wifi/WifiStateMachine.java -

private boolean startTethering(ArrayList<String> available) {                                 
 
    boolean wifiAvailable = false;                                                            
 
    checkAndSetConnectivityInstance();                                                         
 
    String[] wifiRegexs = mCm.getTetherableWifiRegexs();                                      
 
    for (String intf : available) {                                                           
        for (String regex : wifiRegexs) {                                                     
            if (intf.matches(regex)) {                                                        
 
                InterfaceConfiguration ifcg = null;                                           
                try {                                                                          
                    ifcg = mNwService.getInterfaceConfig(intf);                               
                    if (ifcg != null) {                                                       
                        /* IP/netmask: 192.168.43.1/255.255.255.0 */                           
                        ifcg.setLinkAddress(new LinkAddress(                                  
                                NetworkUtils.numericToInetAddress("192.168.43.1"), 24));       
                        ifcg.setInterfaceUp();                                                
 
                        mNwService.setInterfaceConfig(intf, ifcg);                            
                    }                                                                          
                } catch (Exception e) {                                                       
                    loge("Error configuring interface " + intf + ", :" + e);                  
                    return false;                                                              
                }                                                                              
 
                if(mCm.tether(intf) != ConnectivityManager.TETHER_ERROR_NO_ERROR) {           
                    loge("Error tethering on " + intf);                                       
                    return false;                                                              
                }                                                                              
                mTetherInterfaceName = intf;                                                  
                return true;                                                                   
            }                                                                                  
        }                                                                                      
    }                                                                                          
    // We found no interfaces to tether                                                        
    return false;                                                                              
}

Try check out this question: https://android.stackexchange.com/questions/46499/how-configure-the-dhcp-settings-of-wifi-tetheringhotspot-in-android

Upvotes: 0

Related Questions