OHHHHH, NOW I understand.
I thought you wanted to redirect traffic from your computer outbound to a.b.com to 127.0.0.1. I didn't know you wanted external incoming connections to also go there.
This is an external router issue. Yeah, you'd need to register the subdomain to point to your public IP address with the DNS server that handles incoming requests on b.com (in your example). Then, I'm assuming you're using a router, you need to configure external requests on those ports with UDP to be forwarded to your local machine.