Ubiquiti AirMax – Set radio to use DHCP from command line

Gain access to radio via ssh

ssh ubnt@192.168.1.20

open up the /tmp/system.cfg

vi /tmp/system.cfg

Delete the following line. To move the cursor to the following line and type “dd” and vi will delete the whole line.

dhcpc.status=disabled   

Add the following 5 lines. Hit “i” to enter vi insert mode.
br0 should be correct interface in most scenarios.

dhcpc.1.devname=br0          
dhcpc.1.fallback=192.168.1.20
dhcpc.1.fallback_netmask=255.255.255.0
dhcpc.1.status=enabled
dhcpc.status=enabled

Save the file by hitting esc and then “:wq” followed by Return/Enter

Save the config changes and reboot the radio so it pulls an address.

/usr/etc/rc.d/rc.softrestart save && reboot

Helpful EdgePoint commands

Initial setup from command line

initial-setup 

show interfaces

ubnt@ubnt:~$ show interfaces
 Codes: S - State, L - Link, u - Up, D - Down, A - Admin Down
 Interface    IP Address                        S/L  Description                 
 ---------    ----------                        ---  -----------                 
 br0          10.2.2.1/24                  u/u  Local Bridge                
 br0.73       -                                 u/u                              
 br0.75       -                                 u/u                              
 eth0         192.168.99.1/24                   u/u  Internet                    
 eth1         -                                 u/u  Local Bridge                
 eth2         -                                 u/D  Local Bridge                
 eth3         -                                 u/u  eth3-pc1      
 eth4         -                                 u/u  eth4-printer         
 eth5         -                                 u/u  eth5-pc3 
 eth6         -                                 u/u  eth6-rotuer         
 eth7         -                                 u/u  eth7-extra                 
 lo           127.0.0.1/8                       u/u                              
              ::1/128                          
 ubnt@ubnt:~$

Double tab in session to show more commands

wsubnt@ubnt:~$ 
 Possible completions:
   add           Add an object to a service
   clear         Clear system information
   configure     Enter configure mode
   connect       Establish a connection
   copy          Copy data
   debug         Enable debugging of specified routing protocol
   delete        Delete a file
   disconnect    Take down a connection
   generate      Generate an object 
   initial-setup Enter initial configuration dialog
   no            Disable or reset operational variable
   ping          Send Internet Control Message Protocol (ICMP) echo request
   ping6         Send IPv6 Internet Control Message Protocol (ICMP) echo request
   reboot        Reboot the system
   release       Release specified variable
   rename        Re-name something.
   renew         Renew specified variable
   reset         Reset a service 
   restart       Restart a service
   set           Set system or shell options
   show          Show system information
 ubnt@ubnt:~$ ws

EdgePoint – set IP configuration to DHCP via command line

Change eth0 to the interface you would like to change.

SSH into EdgePoint and type in configure to get into a configuration prompt

configure

Now set interface eth0 to dhcp

set interfaces ethernet eth0 address dhcp

Delete the static IP address on eth0 if needed

delete interfaces ethernet eth0 address 192.168.1.1/24

Save changes

commit

Ubiquiti AirOS – applying changes over ssh

When applying changes over ssh you’ll need to “write” or “save” the changes. Usually you’ll edit the /tmp/system.cfg config file and then save the changes with one of the following commands.

/usr/etc/rc.d/rc.softrestart save
or
cfgmtd -f /tmp/system.cfg -w && reboot

rc.softrestart has some advantages. It does not require the radio to reboot when making changes to things like SNMP or the device name.

It does seem to have issues sometimes with certain changes. The following happened when attempting to replace the whole /tmp/system.cfg with a previous backup config.

XM.v6.1.8# XM.v6.1.8# /usr/etc/rc.d/rc.softrestart save
]--- /tmp/.running.cfg.972
+++ /tmp/.system.cfg.972
@@ -1,110 +1,256 @@
... more random stuff ...
Fast system script build Success.
Fast syslog script build Success.
Fast users script build Success.
Fast poepass script build Success.
Fast resolv script build Success.
do_radio_fast_script: rname wifi0
Unsuported change in radio.1.dfs.status for fast update
Fast radio script build failed
Fixup Startup_list …Done.
Welcome back!
[ubnt@localhost] > 

If you have issues applying changes with the softrestart, you can try it with cfgmtd. Downside is the radio does reboot.

cfgmtd -f /tmp/system.cfg -w && reboot 

You could potentially take the reboot off the end of the above command, but have had random issues in the past where the only way to fix it was a physical reboot. Having the radio reboot after applying the config seems to resolve the issue

Ubiquiti AirOS – “test” changes from command line

The following is a method to recover from a command that may inadvertenly make a radio go offline.

The idea is to launch a process in the background that sleeps for 5 minutes and then reboots the radio, so any changes not saved will be reverted. If the changes were successful, you’ll just need to log back in and kill the background process to keep the device from rebooting.

This can be helpful if your changing networking settings using ifconfig, trying to change routes, or something went wrong while trying to apply a system.cfg setting.

Commands

sleep 300 && reboot &

Execute whatever command you need to. i.e.

ifconfig 192.168.1.100

If your command worked you can log back into the device and search for the process id of the sleep command and kill it so the radio doesn’t reboot.

ps | grep sleep

Example output

2XC.v8.5.12# ps | grep sleep
412 admin 1636 S sleep 500
414 admin 1640 S grep sleep
2XC.v8.5.12#

Kill the pid

kill 412

TFTP firmware to Ubiquiti radio

Boot up radio in tftp mode by pressing the reset button for ~20seconds or till you get the crossing blinky lights.

Enable TFTP
In Windows, search for
“turn windows features on or off”
Open up and select tftp client. Then hit OK.

That should install the tftp client

Flash firmware
To flash the firmware, open up a command prompt and run the tftp command

tftp -i 192.168.1.20 PUT "\Users\bob\Downloads\XM.v6.1.3.31939.171117.1238.bin"

Configure AirOS SNMP settings over ssh

In this post we’ll see how we can configure AirOS SNMP settings from the command line.

ubntmod command with save without rebooting.

./ubntmod.sh -i 192.168.1.20 -s "private;monitor@incredigeek.com;[30.69636, -88.04811]" -X '/usr/etc/rc.d/rc.softrestart save'

Alternative manual method.

ssh ubnt@192.168.1.20

Open config file

vi /tmp/system.cfg

Find the SNMP settings and modify as needed. Example below

snmp.community=private
snmp.contact=monitor@incredigeek.com
snmp.location=[30.69636, -88.04811]

Save and exit file with :x

Apply settings

/usr/etc/rc.d/rc.softrestart save

Errors Renewing Lets Encrypt Certificate for UniFi-Video

Had an issue with the Lets Encrypt cert for a UniFi-Video server.  When renewing the cert and reimporting it into the UniFi-Video keystore, the certification was showing out of date.

Issue ended up being something with certbot.

When certbot runs it generates a new cert.pem, chain.pem, fullchain.pem and privkey.pem and puts them in the “/etc/letsencrypt/live/unifi.domain.com/” directory.

The privkey.pem and cert.pem are used to create the keys.p12 file which gets imported into the UniFi-Video keystore.

Apparently the .pem files in “/etc/letsencrypt/live/unifi.domain.com/” are symbolic links to files in “/etc/letsencrypt/archive/unifi.domain.com/”

Upon inspection of the archive directory, multiple cert.pem and privkey.pem files were found with the names cert1.pem, cert2.pem, cert3.pem etc.  Looking at the creation date of the file revealed the symbolic link was referring to an old “cert1.pem” file.

Work around was to stop the unifi-video service and reimport the cert using the latest .pem files in the archive directory.

echo ubiquiti | openssl pkcs12 -export -inkey /etc/letsencrypt/archive/unifi.yourdomain.com/privkey2.pem -in /etc/letsencrypt/archive/unifi.yourdomain.com/cert2.pem -name airvision -out /usr/lib/unifi-video/data/keys.p12 -password stdin
echo y | keytool -importkeystore -srckeystore /etc/letsencrypt/archive/unifi.yourdomain.com/keys.p12 -srcstoretype pkcs12 -destkeystore /usr/lib/unifi-video/data/keystore -storepass ubiquiti -srcstorepass ubiquiti

Remove the old ufv-truststore and start the service.

mv /usr/lib/unifi-video/data/ufv-truststore{,.old}
systemctl start unifi-video

Worked like a charm.