Creating Separate WAN Interfaces: Instance ID Issues in InternetGatewayDevice Configuration

I am encountering an issue with creating instances for multiple WAN interfaces. Specifically, I have the following paths already set up for the first WAN interface via DHCP:

InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANEthernetLinkConfig.*
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.*

I need to create a second WAN interface with a similar structure, but I do not know the exact instance ID (denoted as n) for the new instances. The desired paths are:

InternetGatewayDevice.WANDevice.1.WANConnectionDevice.n.WANEthernetLinkConfig.*
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.n.WANPPPConnection.1.*

It is crucial to create these two instances without interfering with the existing ones for the first WAN interface. In my attempts to create the second WAN interface, I receive errors when using different values for n.

Using n = 1 results in the new interface being linked to the first instance instead of being separate:

InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.*
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.*
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANEthernetLinkConfig

Second WAN interface gets created, but since there is only one instance for WANEthernetLinkConfig, it becomes impossible to have separate VLANs for IPoE and PPPoE.

Any other values for n (2,3,…) lead to the following internal errors:

faultCode: "9003"
faultString: Invalid arguments
setParameterValuesFault: 
  - parameterName: InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Enable
    faultCode: "9002"
    faultString: Internal error

Which after the provision is repeated end up being these errors:

faultCode: "9003"
faultString: Invalid arguments
setParameterValuesFault: 
  - parameterName: InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.9.Enable
    faultCode: "9002"
    faultString: Internal error

The interface with this setup does not get created.

How can I create the second WAN interface correctly without referencing n?

The setup I have now:

if (is_tplink){
  
let values_pppoe = {
      ConnectionTrigger: "AlwaysOn",
      ConnectionType: "IP_Routed",
      NATEnabled: true,
      Name: "pppoe_eth_3740_1_d",
      PPPAuthenticationProtocol: "AUTO_AUTH",
      Password: pppoe_password,
      TransportType: "PPPoE",
      Username: pppoe_username,
      X_TP_FirewallEnabled: true,
      X_TP_IfName: "ppp0",
      X_TP_L2IfName: "eth0.3740_1",
      Enable: true,
};
  
declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.[]", null, {path: 2});
let base_path_pppoe = "InternetGatewayDevice.WANDevice.1.WANConnectionDevice.n"
const path_pppoe = base_path_pppoe + '.WANPPPConnection.[' + Object.keys(values_pppoe).map(key => key + ':' + values_pppoe[key]).join(',') + ']';
declare(path_pppoe, {path: 1}, {path: 1});

let values_pppoe_vlan = {
	EthernetLinkStatus: "Up",
	X_TP_IfName: "eth0.3740",
	X_TP_VID: 3740,
	X_TP_VLanEnabled: true,
	Enable: true,
};
declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.n.WanEthernetLinkConfig.*", null, {path: 2});
const path_pppoe_vlan = base_path_pppoe + '.WANEthernetLinkConfig.[' + Object.keys(values_pppoe_vlan).map(key => key + ':' + values_pppoe_vlan[key]).join(',') + ']';
declare(path_pppoe_vlan, {path: 1});
commit();
  
declare("Tags.PROVISIONED", {value: now}, {value: true});
declare("Reboot", null, {value: now}); }}

Any other number gives me internal errors

faultCode: "9003"
faultString: Invalid arguments
setParameterValuesFault: 
  - parameterName: InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Enable
    faultCode: "9002"
    faultString: Internal error
faultCode: "9003"
faultString: Invalid arguments
setParameterValuesFault: 
  - parameterName: InternetGatewayDevice.WANDevice.1.WANConnectionDevice.3.WANPPPConnection.1.Enable
    faultCode: "9002"
    faultString: Internal error

which after code is repeated end up being this errors:

faultCode: "9003"
faultString: Invalid arguments
setParameterValuesFault: 
  - parameterName: InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.9.Enable
    faultCode: "9002"
    faultString: Internal error

and

faultCode: "9001"
faultString: Request denied
setParameterValuesFault: null

I’ve been down this path before with WANConnectionDevice instances. It was fraught with peril.

It is much easier to pre-configure the CPEs with all the possible interfaces. And then enable/disable them as needed. In my use case, I had DSL routers that I needed to be able to use both routed and bridged.

I do the same. I have a management interface already configure and I add an additional WAN for every other service via GenieACS.

Factory reset your device, refresh the whole tree, download the csv file, do your WAN config via the CPE GUI or CLI, refresh the tree again, download the CSV and compare those 2. It will provide you the expected config of the CPE vendor.

On linux CLI, I use awk and grep to clean up both file of non writable values with following command

cat downloadedFile1.csv | awk -F ',' '$2 == "false" && $4 == "true" {print $1" = "$6}' | grep -v Tags. > newFile1.txt

Then, I use compare plugin on notepad++ to find out what is the difference in between the 2 files. You will be able to find out what is the difference in between both config (before and after creating the WANs).