<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Technology &#8211; Blue Elysium</title>
	<atom:link href="https://blueelysium.net/category/technology/feed/" rel="self" type="application/rss+xml" />
	<link>https://blueelysium.net</link>
	<description></description>
	<lastBuildDate>Thu, 11 Dec 2025 00:23:21 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0</generator>

<image>
	<url>https://blueelysium.net/wp-content/uploads/2023/03/small_fields._ethereal_03.png</url>
	<title>Technology &#8211; Blue Elysium</title>
	<link>https://blueelysium.net</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>UDMPro Managing Lists</title>
		<link>https://blueelysium.net/2025/12/11/udmpro-managing-lists/</link>
					<comments>https://blueelysium.net/2025/12/11/udmpro-managing-lists/#respond</comments>
		
		<dc:creator><![CDATA[ffortunato]]></dc:creator>
		<pubDate>Thu, 11 Dec 2025 00:23:21 +0000</pubDate>
				<category><![CDATA[Technology]]></category>
		<guid isPermaLink="false">https://blueelysium.net/?p=943</guid>

					<description><![CDATA[Ever needed to manually edit lists outside of the ubiquiti interface. I had several long lists of IPs that I want to deny. I update this list based on IPs I gather from my router logs each month. Rather cutting and pasting them each time I wanted to upload a file. The lists are json [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">Ever needed to manually edit lists outside of the ubiquiti interface.</p>



<p class="wp-block-paragraph">I had several long lists of IPs that I want to deny. I update this list based on IPs I gather from my router logs each month. Rather cutting and pasting them each time I wanted to upload a file. The lists are json files that are managed by mongodb. Here is how you can interact with them (insert / update / delete)</p>


<h2>Connection</h2>
<p>Access your ubiquiti router via ssh.</p>
<h3>SSH Access</h3>
<pre><code class="language-bash">ssh root@&lt;udm-ip&gt;</code></pre>
<h3>MongoDB Connection</h3>
<pre><code class="language-bash">mongo --port 27117</code></pre>
<p>MongoDB runs on port 27117 (not default 27017).</p>
<h3>Select Database</h3>
<pre><code class="language-javascript">use ace</code></pre>
<p>The UniFi database is named <code>ace</code>.</p>
<h2>Querying Data</h2>
<h3>View Firewall Groups</h3>
<pre><code class="language-javascript">// All firewall groups
db.firewallgroup.find().pretty()

// IP address groups only
db.firewallgroup.find({"group_type": "address-group"}).pretty()

// Port groups only
db.firewallgroup.find({"group_type": "port-group"}).pretty()

// IPv6 groups only
db.firewallgroup.find({"group_type": "ipv6-address-group"}).pretty()

// Summary view (names and members only)
db.firewallgroup.find({}, {name: 1, group_type: 1, group_members: 1, _id: 0}).pretty()</code></pre>
<h3>View Other Collections</h3>
<pre><code class="language-javascript">// User/Client groups
db.usergroup.find().pretty()

// Network configurations
db.networkconf.find().pretty()

// List all collections
show collections

// List all databases
show dbs</code></pre>
<h3>One-liner Queries (from SSH)</h3>
<pre><code class="language-bash">mongo --port 27117 ace --eval "db.firewallgroup.find().pretty()"</code></pre>
<h2>Updating Data</h2>
<h3>Basic Update Operations</h3>
<h4>Replace Array</h4>
<pre><code class="language-javascript">db.firewallgroup.updateOne(
  { "name": "YourGroupName" },
  { $set: { "group_members": ["192.168.1.10", "192.168.1.20", "192.168.1.30"] } }
)</code></pre>
<h4>Update Multiple Fields</h4>
<pre><code class="language-javascript">db.firewallgroup.updateOne(
  { "name": "YourGroupName" },
  { $set: { 
      "group_members": ["192.168.1.10", "192.168.1.20"],
      "group_members_ipv6": []
    } 
  }
)</code></pre>
<h4>Add Single Item to Array</h4>
<pre><code class="language-javascript">db.firewallgroup.updateOne(
  { "name": "YourGroupName" },
  { $addToSet: { "group_members": "192.168.1.50" } }
)</code></pre>
<h4>Add Multiple Items to Array</h4>
<pre><code class="language-javascript">db.firewallgroup.updateOne(
  { "name": "YourGroupName" },
  { $addToSet: { "group_members": { $each: ["192.168.1.50", "192.168.1.51"] } } }
)</code></pre>
<h4>Remove Item from Array</h4>
<pre><code class="language-javascript">db.firewallgroup.updateOne(
  { "name": "YourGroupName" },
  { $pull: { "group_members": "192.168.1.10" } }
)</code></pre>
<h3>MongoDB Update Operators</h3>
<table>
<thead>
<tr>
<th>Operator</th>
<th>Function</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>$set</code></td>
<td>Set field value(s)</td>
</tr>
<tr>
<td><code>$unset</code></td>
<td>Remove field</td>
</tr>
<tr>
<td><code>$addToSet</code></td>
<td>Add to array (no duplicates)</td>
</tr>
<tr>
<td><code>$push</code></td>
<td>Add to array (allows duplicates)</td>
</tr>
<tr>
<td><code>$pull</code></td>
<td>Remove from array</td>
</tr>
<tr>
<td><code>$inc</code></td>
<td>Increment number</td>
</tr>
</tbody>
</table>
<h2>Workflow</h2>
<h3>Recommended Update Sequence</h3>
<pre><code class="language-javascript">// 1. Backup current document
var backup = db.firewallgroup.findOne({"name": "YourGroupName"})
printjson(backup)

// 2. Verify query matches exactly one document
db.firewallgroup.find({"name": "YourGroupName"})

// 3. Execute update
db.firewallgroup.updateOne(
  { "name": "YourGroupName" },
  { $set: { "group_members": ["192.168.1.10", "192.168.1.20"] } }
)

// 4. Verify update result
// Look for: { "acknowledged": true, "matchedCount": 1, "modifiedCount": 1 }

// 5. Confirm changes
db.firewallgroup.findOne({"name": "YourGroupName"})</code></pre>
<h3>Backup Database</h3>
<pre><code class="language-bash">mongodump --port 27117 --db ace --out /root/backup-$(date +%Y%m%d)</code></pre>
<h3>Restart UniFi Service</h3>
<pre><code class="language-bash">systemctl restart unifi</code></pre>
<p>Restart required for controller to reload database changes.</p>
<h2>Notes</h2>
<ul>
<li>Enable SSH in Settings → System → Advanced</li>
<li>Direct database modifications may be overwritten by controller</li>
<li>Backup before modifications</li>
<li>Verify query scope before executing updates</li>
<li>Check update result for matchedCount and modifiedCount</li>
</ul>]]></content:encoded>
					
					<wfw:commentRss>https://blueelysium.net/2025/12/11/udmpro-managing-lists/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
