The Ethernet Shield 2 uses the W5500 Ethernet controller chip instead of the W5100 chip on the Ethernet Shield. The Ethernet library is not compatible with the W5500 so if you’re using the Ethernet library then that is probably the cause of your problem. If you’re using the arduino.org IDE then you can just change the line:
If you’re using the arduino.cc (this website) IDE, which I would highly recommend, then you only need to install an Ethernet library that supports the W5500. There are a few choices:
Ethernet2 library - this is the same library included with the arduino.org IDE
EthernetMod W5x00 branch - This supports W5100, W5200, and W5500 without needing any modifications
GitHub - per1234/EthernetMod at W5x00 follow the installation instructions on that page, you don’t need to make any changes to your current sketch.
Wiznet Ethernet Library - GitHub - Wiznet/WIZ_Ethernet_Library: WIZnet Ethernet Library this is already set up to support the W5500 but unlike the other two libraries you need to do a manual installation so let me know if you want to use that one and need help with installation.