LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices

Reply
 
Search this Thread
Old 03-17-2006, 12:12 AM   #1
Arodef
Member
 
Registered: Apr 2004
Distribution: Centos, Fedora
Posts: 122

Rep: Reputation: 16
Problem with router assigning hostnames


Our old router (Netgear) would not change the hostnames for Linux computers connected to it. So when I logged on to any Linux PC connected to that router, where the hostname was left at the default (localhost), and where it was assigned an IP via DHCP, my command line prompt would be for example:

[root@localhost root] #

Using our new Linksys router, it is setting the hostnames to those same Linux PCs to new-host-1, new-host-2,etc. so at a prompt I would now get:

[root@new-host-1 root] #

This hostname was not set by me anywhere in the Linux configuratio. It is NOT in the /etc/hosts file for example.

I'm seeing much slower performance and hanging during tasks seemingly unrelated to network such as compiling a program. I know it's network related since as soon as I disable the network, it runs at full speed. I tried adding new-host-# to the /etc/hosts file and that seems to fix the weird issues I'm getting as well.


How can I have Linux properly update the necessary files with the router assigned hostname? What other files need to be updated?

BTW I'm trying to figure out how to turn off this automatic hostnaming from the router as well but it doesn't look like you can. Thanks for any help!

Last edited by Arodef; 03-17-2006 at 12:32 AM.
 
Old 03-17-2006, 04:11 AM   #2
pcweirdo
Member
 
Registered: Oct 2004
Location: Melbourne-ish, Australia
Distribution: Gentoo, Windows XP Pro
Posts: 58

Rep: Reputation: 15
Quote:
Originally Posted by Arodef
I tried adding new-host-# to the /etc/hosts file and that seems to fix the weird issues I'm getting as well.

How can I have Linux properly update the necessary files with the router assigned hostname? What other files need to be updated?

BTW I'm trying to figure out how to turn off this automatic hostnaming from the router as well but it doesn't look like you can. Thanks for any help!
You might have seen the crap I wrote earlier, and noticed its irrelevancy. This post will address first the issue of updating your files to fix the slowness, and then the issue of hostname assignment.

Please tell me the model of the router, so that I can hunt down its family and kill it. Possibly before or after spanking the router. Bam, yeah, take that you bad router. Or maybe I'm just not smart enough for this particular router.

PART A: Or, I AM A WANKER, BUT HOPEFULLY THIS IS HOW YOU FIX THE INTERNETS.

I understand (though I could be wrong, because I am stupid) that the hostname displayed in your shell prompt comes from the hostname command. You could have a script somewhere add
127.0.0.1 localhost `hostname`
to your /etc/hosts .
I haven't seen your hosts file, but I'm sure its pretty. I'd like to see it if this post doesn't fix your issues.

PART B: Or, HEY GUYS, WOULDN'T IT BE COOL IF WE DIDN'T HAVE THE WACKY HOSTNAME ASSIGNMENT HAPPENING?

I'm guessing that your router is running a DHCP server like every good router I've ever used, but is "crossing the line" by assigning hostnames. If you cannot disable this function on the router, you will need to command the client to stand up for its rights, and keep its own hostname. From the dhcpcd man page:
Quote:
Code:
       -H     Forces dhcpcd to set hostname of the host to the hostname option
              supplied  by  DHCP server.  By default dhcpcd will NOT set host-
              name of the host to  the  hostname  option  received  from  DHCP
              server.
What kind of Linux are you running, what options is dhcpcd taking, is dhcpcd running, are you wearing lacy panties, and would you like to win a free iPod?

$ ps aux | grep dhcpcd
might be fun, but hey, I run Windows, what do I know? Hell you could even run with static IP addresses if the router and dhcpcd make it that hard for you.

-pcweirdo.

Sources:
http://www.unix.org.ua/orelly/networ...ip/ch09_05.htm (search the text for "assign each client the hostname")
$ man dhcpcd
Tartar sour- I mean sauce. Ahem.

Last edited by pcweirdo; 03-17-2006 at 04:19 AM.
 
Old 03-17-2006, 05:15 PM   #3
Arodef
Member
 
Registered: Apr 2004
Distribution: Centos, Fedora
Posts: 122

Original Poster
Rep: Reputation: 16
Quote:
Please tell me the model of the router, so that I can hunt down its family and kill it. Possibly before or after spanking the router. Bam, yeah, take that you bad router. Or maybe I'm just not smart enough for this particular router.
The culprit is the Linksys RV082 10/100 8 port VPN Router:
http://www.linksys.com/servlet/Satel...VisitorWrapper



Quote:
I understand (though I could be wrong, because I am stupid) that the hostname displayed in your shell prompt comes from the hostname command. You could have a script somewhere add
127.0.0.1 localhost `hostname`
to your /etc/hosts .
I haven't seen your hosts file, but I'm sure its pretty. I'd like to see it if this post doesn't fix your issues.

Good idea, I guess I would also have to have that script check for old hostnames since the router can reassign IPs/hostnames after a power outage for example. If I place such a script command in /etc/rc.local would I need to restart the network service for the change to take effect?


Quote:
What kind of Linux are you running, what options is dhcpcd taking, is dhcpcd running, are you wearing lacy panties, and would you like to win a free iPod?
I'm running the ancient Fedora Core 1 for reasons too long to go into.

No processes with dhcpd in its name are running after I grepped ps aux. BTW you know alot for Windows guy!

Thanks for the reply!

Last edited by Arodef; 03-17-2006 at 05:22 PM.
 
Old 03-18-2006, 09:42 PM   #4
pcweirdo
Member
 
Registered: Oct 2004
Location: Melbourne-ish, Australia
Distribution: Gentoo, Windows XP Pro
Posts: 58

Rep: Reputation: 15
Please note the difference between dhcpcd and dhcpd, which I often confuse with my bad typing. One is for the client, the other for the server, and sometimes you even run both, but that's far too kinky for a public forum (THERE COULD BE CHILDREN WATCHING).



Quote:
Originally Posted by Arodef
Good idea, I guess I would also have to have that script check for old hostnames since the router can reassign IPs/hostnames after a power outage for example. If I place such a script command in /etc/rc.local would I need to restart the network service for the change to take effect?
I assume you mean to check for old hostnames to avoid your hosts file bloating out of control with 800 lines of the same thing? Depending on what is in your hosts file, you could have a script totally rewrite it every time the network service comes up. This might be achieved by an /etc/rc.local script (to run at system startup) or by modifying /etc/rc.something/something-to-do-with-eth0-up. I had FC2 but I didn't play with it enough to know how this works exactly. Do you have a file like /etc/init.d/eth0-up?

On all the computers I have ever controlled, /etc/hosts contains localhost's entry, and that's it. Once I put in my family's computer, but then its IP address changed so I just got bitter about static IPs. My /etc/hosts thus looks like this:
Code:
127.0.0.1       localhost       baghdad
and a bunch of crap about ipv6, which scares the shit out of me.

If I was using your router, I'd do this:
* Have a nap.
* Add the following script to the end of eth0-up (where eth0 is your relevant LAN card) or some kind of network service startup script
Code:
echo 127.0.0.1 localhost `hostname` > /etc/hosts
BUT I cannot stress enough that you may have something important in your hosts file that you don't want to overwrite. You might like
Code:
(echo '# I love my hosts';\
echo 127.0.0.1 localhost `hostname`;\
echo '# MUMMY, WHERE ARE YOU?';\
echo 10.100.200.7 mom;\
echo '# HOSTS END' ) > /etc/hosts
instead. I would like to see your hosts (if there's nothing compromising in it, or course!).

This way, when your computer starts up the network service and activates eth0, /etc/hosts will be rewritten. Since you say fixing the hosts file manually fixed the slowness, this approach should make everybody happy.

-pcweirdo.

PS. I have dispatched a Self-Righteous Angry Nerd Special Forces squad to eliminate Cisco. Bastards!
 
Old 03-25-2006, 07:39 AM   #5
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 230Reputation: 230Reputation: 230
DHCP clients

Vis-a-vis dhcpcd, don't forget that it is only 1 of 3 DHCP clients in common GNU/Linux use. The other two are: dhclient & pump.

pump is the oldest & I don't see it much except in Knoppix (drat, I can't remember if Klaus finally switched to dhclient in ver. 5).

dhclient is the newest.

If you don't know which you have (& you should have only 1), try this: at a root prompt (#) type "dhc" & press <Tab>. If you have either of the newer DHCP clients, bash should tab complete w/ its name. If bash doesn't tab complete, then try pump. I have yet to encounter a Linux box (doesn't mean I won't ...) where this doesn't work.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Assigning Static IP Problem canuck_barlow Linux - Newbie 5 01-06-2006 02:54 PM
problem resolving hostnames natm Linux - Networking 5 07-09-2005 05:16 PM
Netgear wg311 v2 problem assigning IP maximyus Linux - Wireless Networking 3 01-20-2005 05:05 PM
resolving hostnames problem! meshmesh Linux - Networking 2 01-25-2004 10:08 AM
ans to problem on hostnames: toxic53 Linux - Newbie 2 10-04-2001 02:40 AM


All times are GMT -5. The time now is 07:28 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration