Solution 1:

You can use PowerShell to configure your network. You can use these combinations to manually set addresses and reset them to automatic:

Get-NetAdapter -Name "Your_Network_Adapter_Name" | Set-DnsClientServerAddress -ServerAddresses 8.8.8.8,8.8.4.4

Get-NetAdapter -Name "Your_Network_Adapter_Name" | Set-DnsClientServerAddress -ResetServerAddresses

You should add some conditional statements to determine which network you're connecting to.

How to run them automatically when you connect? You can use system events log and Windows scheduler. I can't provide you every needed information (whole solution) but I can give you some starting points.

This is how you run PowerShell scripts with Windows scheduler.

This is how you determine if you connected to network using events log.

You should setup scheduler job to run when triggered by event.

I'm assuming that you have intermediate knowledge about computers, because you're changing DNS settings for your needs. If you don't, just change adapter settings to "automatic".