Connecting to Wifi using static IP on BrainyPi

Connecting to Wifi using static IP on BrainyPi Method 1

This method uses Network Manager configuration file, to connect to Wifi using static IP.

Step1 : Configure Network Manager

  1. Create a new config file for the Wifi connection, by running command

    sudo nano /etc/NetworkManager/system-connections/Wireless1.nmconnection
    
  2. In the configuration file, add the following lines:

    [connection]
    id=Wireless1
    type=wifi
    interface-name=p2p0
    permissions=
    
    [wifi]
    mac-address-blacklist=
    mode=infrastructure
    ssid=<WIFI_SSID_HERE>
    
    [wifi-security]
    key-mgmt=wpa-psk
    psk=<WIFI_PASSWORD_HERE>
    
    [ipv4]
    address1=<STATIC_IP_HERE>,<GATEWAY_IP_HERE>
    dns=<DNS_SERVER_IP_HERE>;
    dns-search=
    method=manual
    
    [ipv6]
    addr-gen-mode=stable-privacy
    dns-search=
    method=auto
    
    [proxy]
    

    Replace the placeholders (<WIFI_PASSWORD_HERE>, <WIFI_PASSWORD_HERE>, etc…) with the appropriate values.

    Sample configuration should look like this

    [connection]
    id=Wireless1
    type=wifi
    interface-name=p2p0
    permissions=
    
    [wifi]
    mac-address-blacklist=
    mode=infrastructure
    ssid=MyWifi
    
    [wifi-security]
    key-mgmt=wpa-psk
    psk=12345678
    
    [ipv4]
    address1=10.0.2.110/24,10.0.2.1
    dns=1.1.1.1;8.8.8.8;
    dns-search=
    method=manual
    
    [ipv6]
    addr-gen-mode=stable-privacy
    dns-search=
    method=auto
    
    [proxy]
    
  3. Set correct permissions for config file.

    sudo chmod 600 /etc/NetworkManager/system-connections/Wireless1.nmconnection
    
  4. Configuration done.

Step2: Apply configuration

  1. Restart Network Manager

    sudo systemctl restart NetworkManager
    
  2. That’s it! Your WiFi connection should now be using the static IP address you specified in the configuration file.

  3. If it does not connect automatically, then run the command,

    sudo nmcli con up "Wireless1"
    
1 Like

Connecting to Wifi using static IP on BrainyPi Method 2

This method uses Network Manager nmcli command, to connect to Wifi using static IP.

Replace the placeholders in the command below and run it in the terminal

sudo nmcli con add con-name "Wireless1" type wifi ifname p2p0 ssid "<WIFI_SSID_HERE>" wifi-sec.key-mgmt wpa-psk wifi-sec.psk "<WIFI_PASSWORD_HERE>" ipv4.method manual ipv4.address <STATIC_IP_HERE> ipv4.dns <DNS_SERVER_IP_HERE> ipv4.gateway <GATEWAY_IP_HERE>

sudo nmcli con up "Wireless1"

Example command should look like this,

sudo nmcli con add con-name "Wireless1" type wifi ifname p2p0 ssid "MyWifi" wifi-sec.key-mgmt wpa-psk wifi-sec.psk "12345678" ipv4.method manual ipv4.address 10.0.2.110/24 ipv4.dns 1.1.1.1,8.8.8.8 ipv4.gateway 10.0.2.1

These command have to be run just once and next time the BrainyPi will automatically connect to Wifi using Static IP.

1 Like