My new iMac connects to my router, but not to the internet. How to fix?
You are connecting your Mac to the router via WiFi.

The first thing to check is that your Mac is asking for an IP address and your router is giving it one.

Open System Preferences > Network and select "Wi-Fi" in the left hand pane. On the right is should say "Wi-Fi is connected to [router name] and has the IP address [IP address]"

If it does you have a deeper problem, if it doesn't say that but instead says it has a self-assigned address that start with 169 then you have a DHCP problem.

Click on the "Advanced…" button at bottom right and in the Advanced pane click on "TCP/IP". Make sure that "Configure IPv4" is set to "Using DHCP" and then click on "Renew DHCP Lease" and see if you now get a good address.

if you are getting a good address from your router then try something simple, run "ping -c 5 google.com" on the command line and you should see ping send and receive 5 packets.

If neither of those work then please run ifconfig at the command line and you will see a number of blocks starting with an interface name of "en" followed by a number. Your wireless is probably "en1" or "en0". Paste this output into your question and we will have a look at it.