www.centos.org Forum Index CentOS 6 - Networking Support [SOLVED] Avahi not "self aware"
|
Bottom Previous Topic Next Topic |
| |
|
|
|---|
| Poster | Thread |
|---|
|
Re: Avahi not "self aware" | #2 |
|
|---|---|---|---|
|
Moderator
![]()
Joined: 2006/12/13
From Tidewater, Virginia, North America
Posts: 18773
|
Not quite following what you are trying to accomplish, and I don't know how to implement the fullback you want. You can certainly specify a HOSTNAME in /etc/sysconfig/network.
The key to correct name resolution seems to be in a correct DHCP/DNS server. Perhaps this article may help, but that does not account for situations where it is not correctly handled. |
||
|
_________________
Phil Recommended reading: FAQ & Readme first ; Search hint: google "your topic site:centos.org"; Smart Questions |
|||
Posted on: 2012/3/26 23:40
|
|||
|
Re: Avahi not "self aware" | #3 |
|
|---|---|---|---|
|
Newbie
![]()
Joined: 2012/3/12
From
Posts: 5
|
The problem I have is that this system moves from location to location and can be on any variance of DHCP servers with absolutely no guarantee that I will have valid DNS at any given time. Normally this wouldn't be a problem, but one of the main pieces of software that is being used uses a web based UI and needs to know its own name and calls itself using gethostname(). If there is no valid DNS, the system falls back onto whatever hostname is set in /etc/sysconfig/network. The only problem here is that this hostname needs to have the .local extension added to it for avahi to work in absence of any DNS, so simply setting the hostname from "hostname" to "hostname.local" makes everything work.
I've written a little perl script that runs at boot time that checks to see if there is valid DNS (host against the IP), and if not it changes /etc/hosts as well as calls the hostname directive to rename the host from "hostname" to "hostname.local". I need this avahi resolving address in place before I start the service for the other web based tool (it runs at the end of sysv, so this is fine). If there is valid DNS from DHCP, we just let the hostname stay what it is and all is well in the world. The only remaining issue I have now is that running /bin/hostname in my init script for some reason does not seem actually set the hostname, yet running it immediately after login seems to work just fine. I would just change the /etc/sysconfig/network hostname setting beforehand, but considering that I need networking to actually be up and running before I can do my tests, that wouldn't make much sense. The end goal is that I want this CentOS box to run like my Mac on DHCP. In absence of good DNS, I want it to have a valid .local hostname that it is aware of and can address itself over. Right now all the other systems on the network can actually address it with a bad hostname set (Windows 7, Mac OS X, other Linux), but it can't see itself. |
||
Posted on: 2012/4/4 4:24
|
|||
|
Re: Avahi not "self aware" | #4 |
|
|---|---|---|---|
|
Moderator
![]()
Joined: 2006/12/13
From Tidewater, Virginia, North America
Posts: 18773
|
Your needs are clear but I don't completely understand where your script approach is failing. My guess is that the hostname you set is somehow getting clobbered when subsequent services start. You could try setting it in /etc/rc.d/rc.local which should run last, but that presumably requires some logic to test what your perl script has done earlier.
|
||
|
_________________
Phil Recommended reading: FAQ & Readme first ; Search hint: google "your topic site:centos.org"; Smart Questions |
|||
Posted on: 2012/4/4 14:51
|
|||
|
Re: Avahi not "self aware" | #5 |
|
|---|---|---|---|
|
Newbie
![]()
Joined: 2012/3/12
From
Posts: 5
|
Quote:
Phil, thanks for the advice on rc.local, I will give that a try today and report back. I did double check rc.local to make sure that the hostname isn't getting set in there already (it isn't), but I can move that section of the script out into rc.local and maybe just do a test against a file in /tmp if the first portion of the script runs correctly. |
||
Posted on: 2012/4/5 18:54
|
|||
|
Re: Avahi not "self aware" | #6 |
|
|---|---|---|---|
|
Newbie
![]()
Joined: 2012/3/12
From
Posts: 5
|
Adding the hostname directive to the rc.local file worked and properly switched the hostname.
I am still really perplexed as to why it works in rc.local, but not when run during the normal boot process when every other command I run in the script runs without issue. It is really confusing to me, but it is another problem for another day. |
||
Posted on: 2012/4/9 3:37
|
|||
|
Re: [SOLVED] Avahi not "self aware" | #7 |
|
|---|---|---|---|
|
Moderator
![]()
Joined: 2006/12/13
From Tidewater, Virginia, North America
Posts: 18773
|
Quote:
Thanks for reporting back. Marking this thread [SOLVED] for posterity. Quote:
Because something that runs after your first script in the boot process overwrites what you did. The usual way to handle that would be to set the hostname to the desired value, but your requirements seem to preclude that approach as the hostname is not known a priori. |
||
|
_________________
Phil Recommended reading: FAQ & Readme first ; Search hint: google "your topic site:centos.org"; Smart Questions |
|||
Posted on: 2012/4/9 15:00
|
|||
Top Previous Topic Next Topic |
|



Topic options
Print Topic
Threaded
Newest First
szumlins




You cannot start a new topic.
You can view topic.