Can we add Multiple IP's to a Listener in same subnet- SQL 2016 Alwayson AG

  • currently, I have 3 nodes in WSFC with a file share witness. However, Node A and NOde B- 2 nodes are in the same subnet and another 3rd node -NODE-C is in another subnet.

    I am running the below T-sql to add another IP to the LISTENER - however I was able to create the listener using two IP's which are in different subnet (i.e one for NOde A  and one from Node-C, but when I try to add another IP which is in the same subnet as NodeA then I am getting below error.

    ALTER AVAILABILITY GROUP AGDBA MODIFY LISTENER N'poc-ag-test' (ADD IP (N'10.19.16.xx','10.19.16.xx'))

    Msg 19451, Level 16, State 0, Line 4
    '10.19.16.xxx' and '10.19.16.xxx' belong to the same subnet. Only one IPv4 and/or one IPv6 address from each subnet is allowed. For an advanced configuration, see the Windows Server Failover Clustering (WSFC) administrator to create a customized configuration through the Cluster Manager

    ----------------

    Also, do I need to make any changes at WSFC end to make it happen?

  • You should add ip from the second subnet. Why are you adding ip from the same subnet?

  • I think the error is pretty obvious. Can you explain what is the end goal and why you are trying to do what you're intending to do.

  • Apologies for posting in an old thread, but in the event someone else is trying to do this, I just completed this setup of 4 servers in an AG/Cluster, with 2 different subnets, 2 ips in each subnet.

    Yes! You can have multiple IPs from the same subnet in an AG listener, but at least as of sql 2022 ssms v21, it is considered non conforming configuration and you have to manage the resources from the Failover Cluster manager at the windows level.

    You HAVE to ensure that from within Failover Cluster Manager that the IP resources attached to the AG role can ONLY be owned by the server that the IP is associated with, otherwise the cluster tries to bring the IP resource online on whichever node it can, which in this case COULD be any of the other servers in the same subnet. This results in an error that the IP address is already in use on the network.

    The next thing you need to do is ensure that any of the AG Role cluster objects can be owned by all the servers in the cluster. There is a cluster group object, and two cluster resource objects associated with an AG in windows failover cluster manager, all 3 need to be able to be owned any of the servers in the cluster. There is some handy PowerShell out there to help you with this

    # Who can own the AG role?
    Get-ClusterGroup "ag-name-infci" | Get-ClusterOwnerNode

    # Ensure all four nodes are set as owners (and order if you like)
    Set-ClusterOwnerNode -Group "ag-name-infci" -Owners "ag-node-a","ag-node-b","ag-node-c","ag-node-d"

    $agRes = Get-ClusterResource | Where-Object {
    $_.ResourceType -eq "SQL Server Availability Group" -and $_.OwnerGroup -eq "ag-name-infci"
    }
    $agRes | Get-ClusterOwnerNode
    Set-ClusterOwnerNode -InputObject $agRes -Owners "ag-node-a","ag-node-b","ag-node-c","ag-node-d"

    $lnn = Get-ClusterResource "ag-name-infci" # the Network Name resource for the listener
    $lnn | Get-ClusterOwnerNode
    Set-ClusterOwnerNode -InputObject $lnn -Owners "ag-node-a","ag-node-b","ag-node-c","ag-node-d"

    The other issue that I encountered configuring an AG this way was that I had to from within windows failover cluster manager take the active online IP resource associated with the AG Role offline, then attempt to bring the newly added IP resource online. It won't come online, at least from my experience, but according to what limited literature I could find this takes the resource out of a cluster managed "back-off" window. Once you have attempted to do that, restart the last known good IP address resource, restart the AG role, and then re-validate the cluster object ownership that you did in the first two steps.

    Once you've jumped through all these hoops you should be able to fail over your listener to any of the servers/ips that are in the listener (unless you encounter some other absurd issue like DNS registration... )

    Hope this helps someone else!

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply