Configuring a static IP address

Version 1

    Usually, the Wi-Fi connection is configured through the command: configure_edison --wifi. It will guide us through the required steps of selecting the network and entering the network password. After the process, our Edison will get an IP address assigned through DHCP. However, depending on our application requirements (or just because we want it), we might need to configure the Wi-Fi connection using a static IP address instead of one assigned through DHCP. The following steps will help you in order to configure a static IP address for Edison.


    Connecting to the network


    • We are going to use connman to configure the Wi-Fi connection. Run the following commands to start the connman service and to enable it:
    systemctl start connman
    systemctl enable connman


    • We have entered in the connman interactive mode. Run the following commands to enable Wi-Fi and to scan the available networks:
    enable wifi
    scan wifi


    • When the message "Scan completed for wifi" appears, then run the following command to display the networks scanned:


    • The networks available will be displayed in the following format: <network_name> <service_name>. The service name is a long string that you will need to connect to the desired network. Select and connect to the desired network by running the following commands:
    agent on
    connect <service_name>


    • Then enter the network password when the command prompt asks for it. At this point you should be connected to the network selected. Exit the connman interactive mode by running the following command:


    Gathering network information


    We are going to need the gateway, netmask and broadcast information to set the static IP address. With the following commands we will get the necessary information:

    • For gateway information: netstat –nr
    • For netmask and broadcast information: ifconfig wlan0


    Setting the static IP address


    • With the netmask and gateway information, run the following command to set the static IP address:
    connmanctl config <service_name> --ipv4 manual <ip_address> <netmask> <gateway>


    • Now the Edison should have the static IP address set.


    Maintaining the static IP address after reboot


    • At this point the static IP address is set, but it will be erased after reboot. In order to maintain it after reboot, the interfaces file must be created and configured. To create the interfaces file, the directory /etc/network must be created first. The following command creates this directory:
    mkdir /etc/network


    • Then, create and edit the /etc/network/interfaces file by running the following commands:
    echo auto wlan0 >> /etc/network/interfaces
    echo iface wlan0 inet static >> /etc/network/interfaces
    echo address <ip address> >> /etc/network/interfaces
    echo netmask <netmask> >> /etc/network/interfaces
    echo broadcast <bcast> >> /etc/network/interfaces
    echo gateway <gateway> >> /etc/network/interfaces
    echo dns-nameservers >> /etc/network/interfaces
    echo wpa-ssid <network name> >> /etc/network/interfaces
    echo wpa-psk <network password> >> /etc/network/interfaces



    If the process is done properly, Edison should maintain the static IP address set even after reboot.