How to Change Hostname in Unix FreeBSD

We have interesting hostname for our all our servers. Some of it is using Football Team like Manchester, Liverpool, Chelsea, Arsenal. Part of it is striker name like Rooney, Ronaldo and etc. We also have like meganfox, milla, jessicaalba for those “hot” “steamy” servers. Occasionally if the football team is not perform well, we will change the hostname for the server to other football team, for example Manchester to Chelsea. Yea.. We are not loyal support, we only support the no. 1 team.

Joking aside, how to change server hostname in Unix FreeBSD? There are 2 ways to do it, one is the easy way another is the geeky way. Depend on yourself, if you want to show your elite skills, do it with the text editor, or make the change with Sysinstall.

Change Hostname in Unix FreeBSD with Sysinstall

  • In command line, type: sysinstall
  • Select Configure
  • Select Networking
  • Select Interfaces
  • Select your Network Interface Card (em0 em1 fxp0)
  • No IPV6 (Select yes if you are running on ipv6)
  • No DHCP (Select yes if you are running on dhcp)
  • host: should be your server name like chelsea
  • domain: should be your own domain like takizo.com
  • Select Ok
  • Exit, Exit, Exit
  • In command shell, type: hostname chelsea.takizo.com

This will update your new hostname in Unix FreeBSD box. But please take note you will have extra junk in /etc/rc.conf. So it’s recommend to change your hostname in Unix FreeBSD with following method.

Change Hostname in Unix FreeBSD in “Clean” Way

  • In command shell, type: hostname chelsea.takizo.com
  • Edit /etc/hosts with vi, change the existing hostname to your new hostname
  • Edit /etc/rc.conf with vi, on the “hostname” variable change the existing hostname to your new hostname

This is the better approach in order to organize your /etc/rc.conf clean and clear.