Mac terminal prompt's machine name becomes "bogon" after using traceroute
By some searching I found a solution to this problem.

First, change the DNS address in your network configurations to a better one, like google's 8.8.8.8.
Second, run sudo hostname theMachineNameYouWant in terminal.

The reason for this:

They say that when you are doing DNS lookup/reverse lookup, the DNS server can give your machine a host name, this function should be turned off for public DNS servers, but I don't know why the DNS server of my local ISP has it on.

Since my machine uses a router, so it has a IP like 192.168.0.x in LAN, I don't know why but when using traceroute, this IP will be sent to the DNS server for a reverse lookup, and since it is a reserved IP address, the DNS server returns a hostname as bogon, thus, changes my machine's hostname.

So what is bogon? Bogon means the type of IP addresses that should not appear in a traceroute, like a reserved IP address.

bogon on wikipedia.