The administration and maintenance of Microsoft Exchange Server to ensure secure, reliable, and efficient email and collaboration services across an organization.
Depending on Exchange Version:
2019:
2013/2016:
https://blog.expta.com/2018/10/how-to-block-external-access-to.html
This will affect OWA
Or look at:
https://www.codetwo.com/admins-blog/how-to-disable-external-access-to-ecp/