Problem with setting host name

bobrof

New Member


Messages: 4

#1
I have a problem with FreeBSD 7.1.
To set up host name, a line was added to /etc/rc.conf:
Code:
# -- sysinstall generated deltas -- # Wed Jul  1 15:59:06 2009
# Created: Wed Jul  1 15:59:06 2009
# Enable network daemons for user convenience.
# Please make all changes to this file, not to /etc/defaults/rc.conf.
# This file now contains just the overrides from /etc/defaults/rc.conf.
keymap="ru.koi8-r"
moused_enable="YES"
defaultrouter="192.168.0.1"
ifconfig_ral0="WPA DHCP"
postgresql_enable="YES"
accf_http_load="YES"
hostname="aaa.bb"
apache22_enable="YES"
apache22_http_accept_enable="YES"
After the boot process, I check host name with "hostname" command, but get empty line.
Setting hostname with "#hostname mt-note" works well, but after reboot host name is still empty.

My uname:
Code:
FreeBSD aaa.bb 7.1-RELEASE FreeBSD 7.1-RELEASE #0: Thu Jan  1 14:37:25 UTC 2009     [email]root@logan.cse.buffalo.edu[/email]:/usr/obj/usr/src/sys/GENERIC  i386
Can anyone please help with setting host name? Thanks in advance.
 

graudeejs

Son of Beastie

Thanks: 687
Messages: 4,612

#2
To avoid freebsd complaining about unqualified hostname, I set it to my IP

for example:
Code:
hostname="192.168.0.100" # works without problem
 

vivek

Aspiring Daemon

Thanks: 194
Messages: 805

#4
Add rc.conf
Code:
hostname="server.example.com"
At shell type:
Code:
hostname server.example.com
Finally, add it /etc/hosts
Code:
echo '192.168.0.2 server.example.com'  >>/etc/hosts
Replace 192.168.0.2 and server.example.com with actual names you want. It is possible that DHCP creating some problem and erasing hostname.
 
OP
OP
B

bobrof

New Member


Messages: 4

#5
I tried
Code:
#rc.conf:
hostname="home.vezde.biz"

hostname home.vezde.biz

#/etc/hosts
127.0.0.1 home.vezde.biz
But still after reboot I have empty hostname. May be it is really DHCP. If it is so, how can I solve it?
 

vivek

Aspiring Daemon

Thanks: 194
Messages: 805

#6
Yes, that is what dhcp does. What you can do is set hostname to empty in rc.conf:
Code:
hostname=""
Your DHCP server isn't sending the hostname back at all. Is it wi-fi router or dhcpd server running on UNIX / Linux?

To solve your problem just create you *own* script using the dhclient-exit-hooks which sets hostname. Under freebsd create a file /etc/dhclient-exit-hooks and add the following code to setup hostname:
Code:
#!/bin/sh
check_hostname(){
 hostname you.example.com
}
And set perms:
Code:
chmod +x /etc/dhclient-exit-hooks
Try it out and let me know. Once done try restarting the system. If above fails use /etc/dhclient-enter-hooks instead of /etc/dhclient-exit-hooks with same shell code:
 
Top