Static wifi ip address

  • Hi, I am new to LE. I tried to configure a static ip under a wifi ssid. The device settings did not persist. So every time I rebooted the device it would come back without connecting to the wireless network.

    I then found the /storage/.cache/connman/ directory where I was able to add the following..

    mywifi.config

    cat mywifi.config

    [service_wifi_mywifi]

    Type = wifi

    Name = mywifi

    Name=ssid-name

    SSID=6275726e79642d32

    Favorite=true

    AutoConnect=true

    Passphrase=my-passprase

    Favorite=true

    IPv4.method=manual

    IPv4.netmask_prefixlen=24

    IPv4.local_address=192.168.4.222

    IPv4.gateway=192.168.4.254

    Nameservers=8.8.8.8;

    Timeservers=0.pool.ntp.org;1.pool.ntp.org;2.pool.ntp.org;

    I need it to persist the ip address of 192.168.4.222 but anytime I play with this file I can watch it on the screen it will fail :(

    If I reboot it will just pick another dhcp address. Any help would be great.

    Thanks,

  • I'm not that familiar with the whole connman setup in LE, but isn't it easier anyway to fixate any IP addresses via your router, using MAC addresses? I do this for all necessary network devices in my LAN, it is simply much easier and faster to set up.

  • Connman persists connection data against the interface MAC address and you probably have a cheap USB dongle (or Android box) where the MAC address isn't preset in the factory (as the manufacturer was too cheap to buy an address range) and when there is no preset MAC most kernel drivers assign a random MAC, thus on each boot the persisted connection data doesn't match the current MAC and you need to create a "new" config again. You must also configure connman via the settings addon GUI or the connmanctl command line client. Manual edits to those files have to be made with connman stopped (in which case you will have no network) else connman can update/overwrite the files at any time.

    Code
    (
    sleep 10
    /usr/sbin/ip link set dev wlan0 down
    /usr/sbin/ip link set dev wlan0 address aa:bb:cc:dd:ee:ff  <= set a MAC address
    /usr/sbin/ip link set dev wlan0 up
    )&

    If my hunch is correct, adding ^ that to /storage/.config/autostart.sh will overwrite the random MAC with a persistent one of your choosing on each boot. You may need to delay Kodi start in LE settings to allow for the network going down/up during startup.

  • Yes this makes sense if there is no oui for the mac address. Looking through that conman directory I see a bunch of wifi_abcd124 etc where abc124 would be the mac address of wlan0 at the time of reboot so what you are saying makes a lot of sense thanks chewitt

    So if I understand you correctly if I put that shell script in there to give wlan0 mac address to be the same with a combination of the conman file I currently have it should keep that static IP I put in there... I might have to add some more logic in there using connmanctl within the shell script?

    Thanks again!