Wifi switches my 2.4 ghz connection to ipv6
I'm having trouble with my iMac's wifi connection to the internet.
My router works fine. I can connect to it with a hard-wired connection or by wifi on either the 2.4 or 5 ghz connection. However, when I try to connect my Mac to the 2.4 connection, it connects to the wifi but cannot get on the internet. My iPhone and Macbook can connect to the same router with no problem on either the 2.4 or 5, so I think the problem is with my Mac.
When I looked more closely, I noticed that the Mac is giving out the ipv4 address for my 5ghz but gives a ipv6 address for the 2.4 ghz (the one that doesn't work). On the Macbook, both these connections have an ipv4 address.
I tried changing the ipv6 setting to "link-local only" (from automatically), but that didn't work.
Any ideas on why this is happening and how to solve it?
iMac, macOS Sierra (10.12)