I've added my computer to my router's DMZ so all opened ports are accessible from the internet. I have a couple of Samba shares that currently have public read permission. I want all other computers on the local network to be able to access my Samba shares without a password. The moment someone tries to access them from outside the LAN, a password should be requested. Can someone help me with this?
As an experienced (>15 years) system/network administrator, I'd put to you that the idea of having SAMBA files world accessible strikes me as being an EXTREMELY bad one.
I suspect its not the answer you were looking for, but I'd suggest considering setting up a VPN (either on the SAMBA server or router, depending on your requirements), and only allowing SAMBA access from known IP's - including those on your VPN. (OpenVPN is relatively easy to set up, secure, and works with most OS's). [ If you need further flexibility, possibly run a web server on your SAMBA box and use .htpassword or a similar mechanism to limit access - but that will provide read-only access unless you focus effort on a more complex web setup ]
If you do want to go about having your computer/network permanently targeted by hackers through having SAMBA exposed to the world I'm reasonably sure that you could set up shares which are only accessible internally (no password), and another set of shares accessible externally (pointing to the same location and requiring a password)