ssh raspi should work inside the LAN and on the public Internet.
To do this you need to make sure that the name resolves to the internal IP on the LAN, and the public IP from outside.
First, you should obtain a domain name such as
raspi.yourdomain.com. Check out http://freedns.afraid.org/ for free domains for hobby use. Point the domain at your public IP
For the LAN, I recommend running DNSMasq. The open DD-WRT firmware tightly integrates with DNSMasq, using it for DHCP and DNS. You just have to tell it your search domain ("yourdomain.com") and it will auto-assign DNS names based on each client's requested name. To make this work, raspi's /etc/hostname should read
Once this is set up, raspi.yourdomain.com should resolve to the local IP on your LAN (just make sure you're using the local DNS on all your machines).
Now, you probably don't want to expose port 22 to the public internet, because you will get a ton of sniffer traffic. So you may have your router exposing raspi:22 as some other port, say 1234. To use the same port on both public and internal networks, you can add a port redirect rule to raspi. On Linux:
sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 1234 -j REDIRECT --to-port 22
sudo sh -c 'iptables-save > /etc/iptables/iptables.rules'
(change eth0 to the name of your network interface as shown by
ip link or
ifconfig, and 1234 to your public port)
Now you can
ssh -p 1234 raspi.yourdomain.com from both public and LAN.
You can add an entry to ~/.ssh/config on your client machine to shorten this to just
ssh raspi, as mentioned by @DopeGhoti.
If you want to expose additional machines' SSH ports on the same public IP, just repeat the process with another DNS name and public port. Cheers!