LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Router DHCP and Linux Hostname (https://www.linuxquestions.org/questions/linux-networking-3/router-dhcp-and-linux-hostname-9041/)

ccpirate 11-21-2001 02:31 PM

Router DHCP and Linux Hostname
 
Ok, I apologize if this has been covered somewhere, but I swear I have been up one side of the Net and down the other looking for the answer to this question.

I have a Netgear314 router that works great for Windows and Linux. It is doing NAT for my home network and basic firewalling. It gets a static IP from my @Home provider, and then generates DHCP addresses for my internal network. These addresses are of the form 192.168.0.x

When I installed RH7.2, I specified the correct ethx device and selected DHCP. Since I have network connectivity on the linux box, it appears that it is indeed getting a DHCP lease from the router and that is working ok. However, the issue is that the hostname is somehow default assigned as DHCCP2 or somesuch. How do I change this hostname and still have everything work? (Incidentally lpd complains about this hostname when I shutdown, which may have something to do with why I can't get my USB printer to work, but I digress).

From others posts, it seems as if I should be able to name this thing "monster.mynetwork" or whatever I want and have it work, but I can't seem to get it to work. If I name it, then it loses network connectivity. If I don't name it, then I get this stupid hostname and lpd complains.

Anyone know what I need to do to fix this?

Thanks in advance.

Chris

ccpirate 11-25-2001 02:42 PM

No help huh? Come on, someone has to know something! Someone has this same or similar setup! At least tell me to RTFM!!!!

finegan 11-25-2001 03:05 PM

Redhat's netconfig basically creates a cute little gui-esque frontend for either changing an rc file (if you're running statics), or invoking dhcpcd if you're using dhcp.

Unfortunately, netconfig keeps you from being able to pass arguments to dhcpcd if you're indeed using that.

Check the man page on dhcpcd. I think you want to use the -R or -D option, but I'm not entirely sure from your post... and well, I have to run to lunch.

You can invoke dhcpcd on startup by sticking the line in /etc/rc.d/rc.local btw.

Luck,

Finegan

krquinby 11-26-2001 02:09 PM

In the /etc/sysconfig/network-scripts directory there is a file for each interface called ifcfg-eth0 (or what ever interface you have). For an interface that recieves its network information via dhcp, there will be a line that looks like this:

BOOTPROTO=dhcp

Put the following lines in to see if it fixes your problem:

DHCP_HOSTNAME=yourhostname
DHCP_DOMAINNAME=youdomainname

Obviously, if you don't have an DNS domain you are using on your internal netowrk the domainname line is not required.

Kris

ccpirate 11-27-2001 07:45 AM

Ok, this last suggestion didn't work. I changed etc/sysconfig/network-scripts/ifcfg-eth1 to include DHCP_HOSTNAME = myhostname and nothing happened after rebooting (eth1 is where my card is at, I don't use the built in card at eth0). My machine is still named dhcppc2.

Any other suggestions?

finegan 11-27-2001 11:46 AM

eth1 is using dhcpcd to get its lease from the router. Under normal operation dhcpcd is built to not over-write the hostname with one sent by the router. This means that either:
A) Redhat's script is annoying. or,
B) Your router is really grouchy.

To find out which, boot the machine like normal, log in as root, and then bring down the eth1 interface and kill the dhcpcd lease with:

dhcpcd -k (-k is for kill the connection and clear all the dhcp cache)

The lease created by the Redhat init script is now dead.

change the name of the machine back to what its supposed to be. (This is assuming that the name stuck when the dhcp cache was killed. Hopefully it will revert.)

Open another terminal and try: tail -f /var/log/syslog
(this will give you a running log of what is happening)

In the first terminal try:

dhcpcd -d eth1 (-d is for it to log everything to syslog, and if the device isn't eth0, you have to give the device as an argument.)

try ifconfig to see if you have an IP.

If the hostname of your box is what it should be, then it was RedHat's init script. If it got re-named... look at that running log and see what the router forced it to do. If it force-fed dhcpcd a hostname, you'll probably have to poke around the config settings of the router.

Hope that helps,


Finegan

mcleodnine 11-27-2001 12:13 PM

Try to find RedHat's script for dhcpcd (in my SuSE box it's /etc/init.d/dhclient) and look for the line that starts the client up. Make sure that there is no '-H' option when starting the client as that will force the client to use the hostname supplied by the dhcp server. You can get more info with 'man dhcpcd'

ccpirate 11-28-2001 08:48 AM

Well, when I run /sbin/dhcpcd -k I get:

**** /sbin/dhcpcd: not running

hence /sbin/dhcpcd -d doesn't do much either.

Incidentally, I don't have a file called /var/log/syslog
Is this bad?

I can't seem to find RedHat's init file unless it is: /etc/sysconfig/network-scripts/ifup

I did find a dhcpcd -H in there. I removed that and ran /sbin/ifup eth1, but nothing seemed to happen.

I'll try to reboot and see what happens.... sigh.

finegan 11-28-2001 11:52 AM

Quote:

Incidentally, I don't have a file called /var/log/syslog. Is this bad?
Yeah, it means that its been so long since I played with a Redhat machine that I forgot where they stick their version of syslog. That seemed right...

RedHat's init file is going to be somewhere in /etc/rc.d/ probably in init.d, or xinet.d (sp?) if its new... somewhere around run level 5 is my guess.

Sorry that's vague. I moved mostly to Slackware a while ago and they use a BSD-ish init, while RedHat (and most of the rest of the world) use SysV.

Okay... I guess the way to make sure that everything isn't demented is to try to get a lease from the ground up. Make sure that eth1 is down with ifconfig. Also make sure the machine's hostname is set to what you want it to. Then try:

dhcpcd eth1

That should ask the router for an IP, a pair of nameservers, a gateway address and nothing else.

when you cut dhcpcd -H out of /etc/sysconfig/network-scripts/ifup, did you cut out dhcpcd -H, or just the -H? Also, when you say that this didn't work... could you get a connection at all after changing ifup, or do you mean the router still shafted you with a crap hostname?

-Finegan

ccpirate 11-28-2001 02:27 PM

When I cut dhcpcd -H out of /etc/sysconfig/network-scripts/ifup, I just cut out the -H and changed it to -h "monster"

I got a connection when I brought up ifup, but it was still dhccp2 the crap hostname. At least, I couldn't ping monster and the command line still said username@dhccp2

I'll try the rest of your suggestions tonight.

Is it just me, or should this not be easier? :)

mcleodnine 11-28-2001 04:37 PM

Have a look at /var/state/dhcp/dhcp-eth1.info or /var/lib/dhcpcd/dhcpcd-eth0.info (not too sure where RH keeps that stuff. It should contain the data recieved from the dhcp server after the lease negotiation.

ccpirate 11-29-2001 08:37 AM

Ok, I took the interface down with ifdown eth1. Confirmed it was down by making sure I couldn't ping. ran hostname monster

Then I tried /sbin/dhcpcd and got the below from /etc/dhcpc/dhcpcd-eth1.info (slightly modified to avoid hackers).

As you can see my hostname for dhcp is still dhcppc2

Tried it also as /sbin/dhcpcd -h monster eth1 and /sbin/dhcpcd eth1 -h monster and still got the same thing below. Any thoughts?

IPADDR=192.168.0.3
NETMASK=255.255.255.0
NETWORK=192.168.0.0
BROADCAST=192.168.0.255
GATEWAY=192.168.0.1
HOSTNAME=dhcppc2
DOMAIN=potlnd1.or.home.com
DNS=24.0.48.33,24.0.48.34
DHCPSID=192.168.0.1
DHCPGIADDR=0.0.0.0
DHCPSIADDR=192.168.0.1
DHCPCHADDR=00:01:02:4B:E6:13
DHCPSHADDR=00:30:AB:04:5D:0B
DHCPSNAME=c119XXXX-X
LEASETIME=4294967295
RENEWALTIME=2147483647
REBINDTIME=3758096377

mcleodnine 11-29-2001 03:05 PM

OK. When sending a request for a DHCP address to most cable ISPs, you usually need to send the client-identifier (given to you when you signed up for the service). That is what the '-h' directive is used for. Sending '-h monster' won't do much for you as I doubt their server will see that as a valid client-id. If the '-H' is used, your dhcp client will set the hostname sent from the dhcp server. Use the client-id supplied by your ISP (dhcpcd eth1 -h your_client_id) Don't use the '-H' and all should be well.

...

carp!

I re-read the thread from the beginning. Your netgear router is giving out the IP address. Better read up on the netgear setup. The above applies for the negtiation between the router and your ISP. dhcpcd with no options should give you the correct results unless the router is forcing the hostname (doubt it).

mjakob 11-29-2001 04:19 PM

How's about just setting up the linux box with a static IP? Is it just a matter of pride to get the DHCP leases working or is there some other reason?

-Mark

finegan 11-29-2001 04:56 PM

You could try a static, although it probably won't work because these home routers typically won't forward unless you've gotten a lease from them.

Yeah, I'm with mcleodnine, your router is force-feeding your box that hostname. There has to be a way to disable that.

-cheers,

Finegan

mjakob 11-29-2001 05:06 PM

Sure you can disable it. The netgear routers are very flexible. I went to the netgear site and took a look at the reference manual. He could simply reserver an address out of the routers pool and assign it to the linux box as a static address. Or, he could completely turn of the dhcp server on the router altogether. If there is a reason he needs or wants dhcp, I would recommend setting up the dhcp server on the linux box. Then static addresses can be assigned by mac address.

-Mark

ccpirate 11-29-2001 11:52 PM

Yes, I could set it up for static, but my Windoze boxes have a tendency to whine then....

As far as I can tell, there is really no reason I shouldn't be able to get this to work right with DHCP. Hell, my router recognizes my Win2000 box's hostname, why not my linux box!?

Anyway, I will continue to play with this and see what I can figure out....

Thanks for the help.

WindozBytes 11-30-2001 03:13 PM

If you don't have everything working yet, try making the following changes:

/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes

/etc/sysconfig/network
change: localhost.localdomain
to: YourDesiredHostName

/etc/hosts
add: YourDesiredHostName
between 127.0.0.1 and localhost.localdomain

execute the following command:
service network restart

Good luck

VicF 12-08-2001 05:27 PM

DHCP & router, and Printer Working yet?
 
I can't seem to get my usb printer working either. I do have a Prestige 314 router which should be about the same as you netgear. I have DHCP on a group of about 50 ip #'s and run my Linux box on a static IP no problem.

Did you ever get the USB printer working? If so what was it?

DavidPhillips 12-09-2001 07:58 AM

You seem to be ok on the connection but you want to change the hostname.


The /etc/sysconfig/network-scripts/ifcfg-eth? file

must have the DHCP_HOSTNAME=your@homename

you have this ok from what I can tell

Now, the file /etc/sysconfig/network

HOSTNAME=whateveryouwant

this will set the hostname

also you can set it by using

hostname monsterwhatever

if the network file don't do the trick, which would surprise me if it didn't, then put the hostname monster command in /etc/rc.d/rc.local

I have never seen one where it was necessary though, just put it in the network file.


dhcpcd does not write the network file

WindozBytes 12-09-2001 03:05 PM

I believe the

DHCP_HOSTNAME=cz999999-b

line would only be required if the system were connected directly to the internet; however, in this case, the linux box is behind a router and would get its dhcp lease from the router and not from the ISP.

DavidPhillips 12-10-2001 04:52 AM

that's correct

I missed that part of the info,

so just put the hostname command in your start up scripts or disable the router from being a netbios-name server

ISMajor 01-20-2002 11:35 AM

dhcpp2
 
I have the same issue. I have a Netgear RT314 and I just loaded a fresh box install of 7.2 on a Dell PowerEdge 2300 for learning purposes. I am taking a Unix I class at Northlake college and I just want to get the damn thing configured at something above 640X480 resolution and be able to connect to the frickin Internet. I want to be able to SSH into the school's Unix server to practice my labs. Anyway, my guess is the problem lies with Redhat's built in Firewall which I enabled my eth0 and selected dhcp. I can ping my router 192.168.0.1 and my PowerEdge has an IP 192.168.0.3. I found this article:

Ipchains and Firewall Configuration

Ipchains rules can be activated by any lokkit-based firewall configuration tool or by hand under Red Hat Linux distrobutions 7.0-7.2.

Iptables is the default firewall mechanism under the 2.4 kernel, but it cannot be used if ipchains are already running. This is because ipchains take precedence over iptables. At boot time, the kernel activates ipchains before attempting to activate iptables. If ipchains are present, the kernel will issue an error and fail to start iptables.


I am guessing this is causing my issue. When I startx I see a blip saying unknown Hostname or something and then this error:

Could not look up Internet address for Dhcppc2. This will prevent Gnome from operating correctly. It may be possible resolve by adding dhcppc2 to the /etc/hosts file.

I'm screwed. My email is sageadvice21@attbi.com

:(

VicF 01-20-2002 01:55 PM

check your netgear config first. If your netmask is 255.255.255.0 as it should be then your poweredge is on the wrong subnet. 192.168.0.1 and 192.168.3.1 are 2 different subnets. The poweredge needs to be at 192.168.0.XX

DavidPhillips 01-20-2002 02:17 PM

If you set it up with dhcp and firewall on install, it will take care of the firewall.

To rule out any firewall issue try this

ipchains -F

to flush the rules

ISMajor 01-20-2002 10:07 PM

DHCPPC2
 
My router is 192.168.0.1 the poweredge is 0.3, win2k machine .0.4 and winxp machine 0.2. I don't have any 1.3 anything. I they are all on 192.168.0.x. My concern was having the Netgear built in nat/firewall fighting with Linux firewall. I will try to flush the rules as discussed.

Sanjog 07-04-2003 01:08 AM

I am having exactly the same problem
 
So what was the final solution that worked ccpirate ?

Can anybody please summarize this in step by step mode for my benefit ?

regards.

Sanjog 07-04-2003 01:19 AM

I am having exactly the same problem
 
So what was the final solution that worked ccpirate ?

Can anybody please summarize this in step by step mode for my benefit ?

regards.

DavidPhillips 07-04-2003 06:53 PM

Sanjog

This info is over a year old. You should start a new thread and give all info on what you have.

arnold 07-04-2003 08:03 PM

i run mandrake - the file /etc/sysconfig/network contains:
NETWORKING=yes
FORWARD_IPV4=false
DHCP_HOSTNAME=my_computer_name
HOSTNAME=my_computer_name
DOMAINNAME=localdomain

my_computer_name is, of course, my computer name

DavidPhillips 07-05-2003 12:18 AM

how about the network script file


cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes


All times are GMT -5. The time now is 07:11 AM.