Well it definitely seems to be a DNS issue as changing it stops all sites working. Unfortunately none of the ones you suggested worked, I'm no expert on DNS so is it even possible a different DNS address will work on a public network?
Hmm, any DNS server that is legit should work. Where are you located?
DNS is used to resolve host names,
www.google.com is a host name for a server with the address of 74.125.28.99. But, it is far easier to remember the google.com than the actual address. Without DNS, nothing works unless you know the numeric addresses, DNS does the work for you.
Start with the IP Address you get when you connect to the train WiFi. If you are getting an address like 169.x.x.x, then the DHCP server on that WiFi network is not giving your Mac a valid address. If it is something close to the address you get on mobile devices, then it is something else.
Your Mac's WiFi Advanced Settings should have the IPV4 and IPV6 (on the TCP/IP tab) set to Using DHCP and Automatic. On the DNS tab, remove anything in the DNS Server list and toggle WiFi off\on to retry if you make any changes. With DHCP enabled, the DHCP server should be giving your Mac at least one DNS server in the negotiation. Go back to these settings to see what the DHCP server gives the Mac and then open Terminal and type "ping [DNS Server IP]" (for example, ping 75.75.75.75, if successful, then "ping
www.google.com". If either ping test fails, you cannot connect to anything on the web.
Does the Train WiFi require you to go through a web page when you first connect? If so, maybe try turning off pop up blocker on your default browser before connecting, to ensure the WiFi authentication page displays properly. Many public networks have these authentication pages just to make you acknowledge terms of use if not use an actual signon.
Next, on WiFi Advanced Properties, click the Proxies tab and make sure it is either set to Auto Proxy Discovery, or everything unchecked. If proxies are required at some locations like work, you will fail if it is used on public networks as they will be unable to reach the proxy server. This is when Location profiles are useful, they allow you to have different settings for different environments.
Finally, if you can ping
www.google.com but can't connect with your browser, check your browser network settings. Safari and Chrome use the Mac Network settings, but Firefox can be configured with it's own Proxy settings. So, try another browser if ping works but your default browser doesn't.