Switching wlan hotspot to custom IP address range



  • These are the steps I did to use 192.168.7.0/24 instead of the default 10.42.0.0/16 address range.

    IMPORTANT NOTES:

    • The IP range is hardcoded in network-manager-1.2.x branch, which is used in UBports 16.04 (xenial). Therefore one have to rebuild the package! A good tool is to perform the rebuild on an x86 or x86_64 PC under Ubuntu is sbuild. Setup an environment for xenial-armhf, login there, and perform a normal debuild for the package.

    • The latest version of network-manager in Xenial is network-manager-1.2.6. This is compatible with the original 1.2.2.

    SETTING THE CUSTOM IP RANGE:

    1. Open the file src/devices/nm-device.c
      Somewhere at the line 4834 (nm version 1.2.6) find the line like this:
    guint32 start = (guint32) ntohl (0x0a2a0001); /* 10.42.0.1 */
    

    The hex value is just calculated from the gateway's dotted decimal IP address of the desired network.
    See this:

    0a = 10
    2a = 42
    00 = 0
    01 = 1
    

    Calculate your desired IP. Use 1, as the gateway, or read the code further how to adjust the netmask if you want another gw address. Mine is now 192.168.7.1:

    192 = c0
    168 = 80
    7 = 07
    1 = 01
    

    My modified line is like this now:

    guint32 start = (guint32) ntohl (0xc0a80701); /* 192.168.7.1 */
    

    Now locate debian/rules file, and remove everything under override_dh_auto_test: line. Tests break in a chrooted environment. So it should look like this:

    override_dh_auto_test:
    
    
    

    You can also modify the configure part to avoid building any tests. Change the line:

    --with-tests \
    

    into:

    --without-tests \
    

    Simple enough, ready!

    Now rebuild your package. You will get several deb files after a successful build, but you need only network-manager-1.2.x.deb. Deploy it on the phone. Reboot, and enjoy the new hotspot network!



  • Does this also apply to RNDIS? I assume yes since hotspot and RNDIS share the same IP range at the moment.


Log in to reply