3 min read
How to change the internal IP address on a Ubiquiti UCG Max or Ultra using the CLI
Sometimes the web interface is not an option. Here is how to move the internal network of a UCG gateway to a different range over SSH, step by step.
There are situations where configuring a Ubiquiti device through the graphical interface simply isn't an option. Sometimes you need to connect directly to the device and make the required changes from the command line.
One example is changing the internal IP address. Using the CLI allows you to bypass the web interface and modify the configuration directly on the device.
In this example, we'll use the Ubiquiti UCG Max, but the same steps work on the UCG Ultra as well. With minor differences in the configuration, the general approach also applies to other similar Ubiquiti gateways.
Connect to the device via SSH
First, connect to the UCG Max using SSH and its current internal IP address.
If the device is using a default 192.168.1.0/24 network, the gateway might be available at:
192.168.1.1
Once connected, you should get a shell similar to:
ubnt@ubnt:~$
Use the credentials currently configured on your device.
Switch to root
To make changes to the configuration, we need root privileges. Switch to the root user with:
sudo su -
The prompt should then change to something similar to:
root@ubnt:~#
Find the correct interface
Before changing anything, we need to determine which interface currently has the internal IP address assigned to it.
Run:
ip a
Look through the output for the current address, for example:
192.168.1.1/24
Depending on the device and its configuration, the address may be assigned to a different Ethernet interface. It's therefore better to verify the interface rather than simply assuming it is eth0.
Set the new IP address
Enter configuration mode:
configure
You can then assign the new IP address to the appropriate interface. For example, if we wanted to move the internal network to 10.10.10.1/24:
set interfaces ethernet eth0 address 10.10.10.1/24
Replace the IP address and interface with the values appropriate for your configuration.
We also need to remove the old IP address from the interface:
delete interfaces ethernet eth0 address 192.168.1.1/24
Apply the changes
Once the configuration has been updated, apply the changes with:
commit
At this point, the current SSH session will be disconnected because the device is no longer using its old IP address.
Move your computer to the new network range if necessary, and then reconnect to the UCG Max using its new IP address.
A useful CLI command
When working with the command line, it can sometimes be difficult to remember the exact syntax for a particular configuration option.
A useful command is:
show configuration commands
This displays the current configuration as a list of commands and can be very helpful when trying to understand how a particular part of the device is configured.
Final thoughts
The process itself is fairly straightforward: connect via SSH, identify the correct interface, configure the new IP address, remove the old one, and commit the changes.
The main advantage of using the CLI is that you can bypass the graphical interface and work directly with the device configuration.
And while this example uses the UCG Max, the general concept isn't limited to this particular device. The UCG Ultra behaves the same way, and with some differences in the underlying configuration, similar CLI-based changes can be performed on other comparable Ubiquiti gateways too.