Why not set ACLs and restrict remote access to specific IP addresses? This is how we accomplish this.
Here is a provision script that will set the ACLs. Fill in the values as necessary for your env. This provision script handles Zyxel CPEs using TR-181, SmartRG and Comtrend CPEs using TR-069.
/* global log:false, declare:false */
log('ACLs');
const now = Date.now();
let model = declare('VirtualParameters.Model', {value: 1}).value[0];
log('ACLs - Model', {model: model});
createAcls();
declare('Tags.HasACLs', null, {value: true});
return;
function createAcls() {
/*
* Clear all existing ACL rules. Because everything is done in one transaction,
* if there are no actual changes, then nothing will actually be removed by GenieACS
*/
declare('InternetGatewayDevice.X_SMARTRG_COM_MgmtAcl.*', {value: now, path: now});
declare('InternetGatewayDevice.X_COMTREND_COM_AccessibleIPAddress.*', {value: now, path: now});
declare('InternetGatewayDevice.X_SMARTRG_COM_MgmtAcl.[]', null, {path: 0});
declare('InternetGatewayDevice.X_COMTREND_COM_AccessibleIPAddress.IPAddressEntry.[]', null, {path: 0});
declare('InternetGatewayDevice.X_BROADCOM_COM_IPAddrAccCtrl.X_BROADCOM_COM_IPAddrAccCtrlListCfg.[]', null, {path: 0});
declare('Device.X_ZYXEL_RemoteManagement.TrustDomain.[]', null, {path: 0});
[
{ip: '192.168.1.0', maskBits: 24, interface: 'lan', notes: 'Local LAN'},
{ip: '8.8.8.8', maskBits: 32, interface: 'wan', notes: 'Office'},
{ip: '8.8.4.4', maskBits: 32, interface: 'wan', notes: 'Another remote office'},
].forEach((acl) => {
log('ACLs - Adding mgmt acl', acl);
declare('InternetGatewayDevice.X_SMARTRG_COM_MgmtAcl.[SrcAddress:' + acl.ip + '/' + acl.maskBits + ']', {path: 1}, {path: 1});
//Comtrend
declare('InternetGatewayDevice.X_COMTREND_COM_AccessibleIPAddress.IPAddressEntry.[ipaddr:' + acl.ip +
',Subnet:' + createNetmaskAddr(acl.maskBits) + ',Interface:' + acl.interface + ']', {path: 1}, {path: 1});
//SR555
declare('InternetGatewayDevice.X_BROADCOM_COM_IPAddrAccCtrl.X_BROADCOM_COM_IPAddrAccCtrlListCfg.[SourceIPAddress:' +
acl.ip + ',SourceNetMask:' + createNetmaskAddr(acl.maskBits) + ']', {path: 1}, {path: 1});
declare('Device.X_ZYXEL_RemoteManagement.TrustDomain.[IPAddress:' + acl.ip + ',SubnetMask:' + acl.maskBits + ',Enable:true]', {path: 1}, {path: 1});
});
//Enable the ACLs for the SR555ac and the Comtrend
declare('InternetGatewayDevice.X_BROADCOM_COM_IPAddrAccCtrl.Enable', {path: 1}, {value: true});
declare('InternetGatewayDevice.X_COMTREND_COM_AccessibleIPAddress.Enable', {path: 1}, {value: true});
}
function createNetmaskAddr(bitCount) {
let mask = [];
for (let i = 0; i < 4; ++i) {
let n = Math.min(bitCount, 8);
mask.push(256 - Math.pow(2, 8 - n));
bitCount -= n;
}
return mask.join('.');
}