Click to See Complete Forum and Search --> : Prevent hostname change by ISP


swoodnj
10-25-2002, 07:38 AM
Without getting into the nasty details...I have what you could consider a part time connection to the internet. I am in the midst of trying to troubleshoot why Gnome/Nautilus go out to lunch using this part time connection. I have a zillion questions, but for now I will only ask one:
How can I prevent my hostname from being changed by my ISP?
Thanks!

Steve W

BTW, I'm running RH 8.

cowanrl
10-25-2002, 08:28 AM
In Red Hat, the host name is determined by what's in the "HOSTNAME=" line in /etc/sysconfig/network. If that line doesn't exist, is blank or says HOSTNAME=localhost, then the machine will use a hostname assigned via DHCP or by doing a reverse DNS lookup on it's assigned IP address.
To stop this you can do one of two things.

Assign a hostname of your choice in the HOSTNAME= line in /etc/sysconfig/network. If you do this and you are getting your IP address via DHCP, be sure to modify the line in your /etc/hosts file that looks like this:

127.0.0.1 localhost localhost.localdomain yourhostname

You would add whatever you put in the HOSTNAME= line to the line for 127.0.0.1 in /etc/hosts. If you don't do this, you'll have all kind of problems.

You can also add the line "PEERDNS = no" to your /etc/sysconfig/network-scripts/ifcfg-eth0 file or possibly the /etc/sysconfig/network-scripts/ifcfg-ppp0 file if you are using PPP. That forces the machine to ignore the hostname it receives via DHCP. If the HOSTNAME= line in /etc/sysconfig/network is blank or says localhost, the system hostname will stay at localhost.

swoodnj
10-25-2002, 08:41 AM
Thank you so much, that is exactly what I was looking for!
I do use eth0, it's a Hybrid cable modem. After disconnecting from the internet gnome goes crazy...apps take minutes to load, etc. I'm doing my best to try and figure it out myself...funny thing is Suse 8 didn't have a problem with this same setup. My focus has been on DHCP and DNS. I'm trying to prevent Gnome and/or Nautilus from trying to look to the internet when I'm off-line. Even disabling eth0 via neat hasn't helped, that's when I started suspecting the hostname.
Again, many thanks, can't wait to get home and try it!

Steve W

cowanrl
10-25-2002, 08:50 AM
One other important thing I forgot to mention. If you do use the PEERDNS setting, it will also ignore the DNS server info it gets via DHCP.
If you are getting the DNS server info via DHCP, you would then need to enter the information manually in your /etc/resolv.conf file or do it using neat.

swoodnj
10-25-2002, 09:36 AM
Hmm...not sure how to handle this then. When I first boot up I don't want to use any "outside" DNS...then I connect to the internet and get everything through DHCP. Then when I get off-line I essentially want to revert back to the "local only" settings. Is there a way to automate this?
Since I get the same two DNS server IPs every time maybe I could put them in /etc/resolv.conf? But then would the system try and use them when I'm off-line?
Sorry to beat this to death, this is the one thing that is standing in the way of me having a trouble free Linux setup.
Many thanks!

Steve W

PS. Rumour has it that my ISP is going to two way cable in the next couple of months, so I guess at that point all of this will no longer apply!

cowanrl
10-25-2002, 10:42 AM
The problem can be resolved. But first, do you have another ethernet card that connects you to an internal network? Or, if you're not online to the Internet, then you have no network connectivity at all?

swoodnj
10-25-2002, 11:00 AM
Thanks for sticking with me on this one!
It is a stand alone machine with one NIC only. Besides the cable modem there is no other network...no routers, nothing.
I've been searching like crazy, there are quite a few threads regarding DNS/DHCP...My head is spinning!

Steve W

cowanrl
10-25-2002, 12:28 PM
If you don't need to have the hostname assigned by your ISP when you log on, here's what I'd do.

Assign yourself a hostname and set up an entry in your /etc/hosts file as I described above. Then, check your /etc/host.conf file and be sure it says:

order hosts,bind

That will make it look in your /etc/hosts file for the hostname lookup before it tries a DNS server.
That should prevent any delays that would be caused by waiting for a DNS lookup on your hostname to time out.

Depending on how you disconnect your connection to your cable service, the DNS server settings in your /etc/resolv.conf file could be deleted when you disconnect.

This is what transpires on a Red Hat system when an Ethernet interface is brought up that uses DHCP:

- /etc/resolv.conf is renamed to /etc/resolv.conf.sv
- DNS settings from DHCP server are written to a new /etc/resolv.conf

When you down the Ethernet interface, the opposite happens:

- /etc/resolv.conf is deleted
- /etc/resolv.conf.sv is renamed to /etc/resolv.conf

You can make this happen if you use the commands:

ifup eth0

and

ifdown eth0

However, if you use:

ifconfig eth0 down

it does not change resolv.conf.sv back to resolv.conf.

I'm not sure what happens if you use some kind of an Internet Connection Wizard in Red Hat to bring the interface up and down though, I've never tried it.

The next time you bring your cable connection up, look for /etc/resolv.conf.sv. When you disconnect from your cable connection, see if it disappears. If not, you may just want to execute "ifdown eth0" just to clear things out.

swoodnj
10-25-2002, 12:38 PM
Wow, thank you ever so much, that answers a lot and gives me a lot to work with.
I know at some point I used "ifconfig eth0 down", so I will try the alternate ifdown eth0. I also tried using neat to bring eth0 down.
At this point I don't care if I have to manually down eth0 each time I get off-line as long as I can maintain a usable system afterwards.
Will let you know how it goes tonight and will be sure to post some (hopefully) positive results for the benefit of others.
I guess there''s something specific to Gnome and/or Nautilus that causes this....

Steve W

cowanrl
10-25-2002, 12:46 PM
Yes, it can mess a lot of services up, not just Gnome and Nautilus. Basically, they need to resolve their hostname to an IP address. If they can't do it, they won't run properly or won't start at all.

shadowrider
10-25-2002, 10:19 PM
i have a question.
i have changed my /etc/hosts:

127.0.0.1 localhost localhost.localdomain [myhostname]

then i have "order hosts,bind" in /etc/host.conf

but still doesn't work. it still gives the default which is something like x1-6-00-04-e2-17-99-ea .

anything else i can try?
this is in gnome2 btw.

shadowrider
10-25-2002, 10:21 PM
also i'm using suse 8.1.
and i couldn't find the line HOSTNAME = ...
from /etc/sysconfig/network
the "HOSTNAME = " is in what file?
if i should create one, what should i name the file?
thx

cowanrl
10-26-2002, 04:50 AM
I think the /etc/sysconfig/network file may be something use by Red Hat and those distributions based on Red Hat. I'm not familiar Suse at all.

You may try putting the hostname you want to assign to your computer in a file named /etc/hostname. Many distributions use that. In fact, it will even work on Red Hat, but the /etc/sysconfig/network file seems to be the standard for Red Hat.

If that doesn't help any, you may want to start your own thread and see if you can get help from someone who knows more about Suse.

swoodnj
10-26-2002, 08:56 AM
Ok, tried all of the above and here is where things stand:

1. I created my own hostname and made the appropriate change in /etc/sysconfig/network.
2. Did not do the PEERDNS thing, left that as is.
3. So far, and I've only tried it several times, the machine stays responsive after getting off line. HOWEVER, nothing at all happens with resolv.conf. It keeps the entries it gets from the DHCP server, and a .sv file is never created, even when using ifdown eth0.
Should I perhaps come up with a script to wipe out the entries in resolv.conf, or if the machine works fine just leave well enough alone?
I wonder if this has something to do with RH 8 using dhclient instead of dhcpcd? Here's what my resolv.conf looks like:

; generated by /sbin/dhclient-script
search nwnj01.nj.comcast.net
nameserver 68.47.128.5
nameserver 68.47.128.6

At any rate, I will beat on this all weekend and if it continues to behave I'll just leave things as they are. I will post the results here in case there are others having the same problem.
Thanks again!

Steve W

cowanrl
10-26-2002, 09:10 AM
If it works, I wouldn't fool with it.

In versions of Red Hat previous to 8.0, the networking scripts would first try dhcpcd. If that wasn't available, they would then try pump.
I was looking through the scripts in 8.0 last night and I see that they will try to use dhclient first, then dhcpcd, then pump. I'll have to do some investigation on dhclient to see how it works.

If you wanted the functionality of dhcpcd, you could try renaming /sbin/dhclient to /sbin/olddhclient. Then use ifdown and ifup. It should use dhcpcd then. See what results you get. If you don't like it or it makes no difference, rename /sbin/olddhclient back to dhclient.

swoodnj
10-26-2002, 11:47 AM
I may experiment, but for now I've got a working system, so I may leave well enough alone...
Many, many thanks for your help, this was driving me nuts, now I can look forward to using the system and learning lots about Linux.

Steve W

swoodnj
10-27-2002, 08:03 AM
Only thing I've noticed: After I disconnect and then re-connect at some point later my speed is ridiculously slow. I've found that releasing and renewing my IP fixes that, although I hope I don't have to do it all the time. I use dhclient -r and dhclient -1 to do the refresh.
Hoping that we go to two way cable soon....

SteveW