You are not logged in.

#1 2005-08-17 17:41:48

koyi
Member
From: Osaka, Japan
Registered: 2005-08-15
Posts: 37

[SOLVED]DHCP ip address changes too often

Hi, I am facing a little problem here.

I set my eth0 to use dhcp.
But every time I reboot my computer(or by running /etc/rc.d/network restart), the ip address changes despite the leash time of the DHCP server(a router) is set to 72 hours. The network itself works flawlessly, though. Since I am running some services for my own sake on this computer(ssh, cvs pserver, etc), I would like the ip address to be more "stable". I don't have this problem in other distros like debian, and other OSes like WIndows and Mac OS X.

Is there any argument I can pass to the network start script so that the ip address has a longer life span?

Currently, I am using a fixed ip as a workaround.
My /etc/rc.conf looks like this now:

eth0="eth0 192.168.0.2 netmask 255.255.255.0 broadcast 192.168.0.255"
...
gateway="default gw 192.168.0.1"
ROUTES=(gateway)

Thanks.

Offline

#2 2005-08-17 19:17:52

rhfrommn
Member
From: Minnesota
Registered: 2005-01-13
Posts: 99

Re: [SOLVED]DHCP ip address changes too often

Maybe you could tell your router to always give a certain address to the mac address associated with your machine.

I had to do this for my printer.  I have a printer with a network card in it, but every power cycle it got a different IP so my computers couldn't find it.  I have a linksys 4-port router at home so I went into the admin program for that and found I could assign the same address (192.168.1.150) to that printer every time.  That fixed my problem.  Should work for you too.

Edit:  I just noticed you said you are using a fixed IP for a workaround.  I'm not sure if you mean that you changed the arch box to use a static IP instead of dhcp, or if you assigned a permanent address from your dhcp range to the arch box like I described above.  You should be able to have the arch box set up for dhcp but have the router make sure it always gets the same leased address I believe.

Offline

#3 2005-08-17 20:12:45

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: [SOLVED]DHCP ip address changes too often

I really don't understand why people have this issue... dhcp is made for dynamic addresses... if you want to use dhcp, then don't use the IPs directly - if you're using the IP then make a static one, it's really not hard.  DHCP is *NOT* for static IPs.

Offline

#4 2005-08-17 20:40:54

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: [SOLVED]DHCP ip address changes too often

Mostly true, phrak, but the DHCP spec does include provisions for allocating a specified IP address to a particular machine, as suggested by rhfrommn. It's an equally valid solution to the problem - apart from that printer scenario, I use it so that my laptop gets a particular address when I'm at home, and a "normal" dynamic address when I'm anywhere else - without any rc.conf editing.

Offline

#5 2005-08-18 00:21:24

koyi
Member
From: Osaka, Japan
Registered: 2005-08-15
Posts: 37

Re: [SOLVED]DHCP ip address changes too often

Thanks for your replies guys.

First, let me elaborate more on my problem.

I was talking about my home network.

1. It is small and it has to be dynamic since I am sharing the network with other friends. I don't know when they are going to plug in another computer into the network so I can't use totally static IP solutions.

2. The router I am using is in fact built into the ADSL modem. So, it is lacking in functions. I have thought of the solution of allocating static IP for certain MAC addresses. But I couldn't find the function in the admin screen of the router/modem.

3. When I said I am using a fixed IP for a workaround. I meant that I am setting Arch as if it is using a static address, like in the rc.conf I showed above in my first post. But in fact, the IP is assigned via DHCP. I am not very sure about it. I dual-boot my computer with Windows and Arch. So the IP address is assigned to Windows. Before it changes, I suppose that setting Arch to use that same assigned IP should work.

So I am now thinking of the following ways to get through this problem.

1. Spend some money to buy a real router.
2. Occassionally put into Windows to let the modem assign the same IP to the box and live with it.

3. Continue to reasearch for a way to request for an IP address from a DHCP server. I read somewhere that if a computer request for an IP address and if it is not already taken, it will be assigned to it. Since the network is small, this should work but I just don't know how.

Thanks.

Offline

#6 2005-08-18 01:34:41

koyi
Member
From: Osaka, Japan
Registered: 2005-08-15
Posts: 37

Re: [SOLVED]DHCP ip address changes too often

I found the solution to the problem. I hope this time I have got the more appropriate one.

First, it seems that Arch uses dhcpcd as the DHCP client.
dhcpcd, when invoked, request an IP address from the DHCP server.

From the man page of dhcpcd:

-s [ipaddr]
              Sends  DHCP_INFORM  message  to  DHCP  server using ipaddr.  The
              optional ipaddr parameter must be in the  form  xxx.xxx.xxx.xxx.
              If  no ipaddr parameter is given on the command line dhcpcd will
              use the IP address currently  assigned  to  the  interface.   If
              there  is  no  IP  address  currently  assigned to the interface
              dhcpcd will use previously obtained IP address stored  in  <Con-
              figDir>/dhcpcd-<interface>.cache file.

And it seems that when started, /etc/rc.d/network rm /etc/dhcpc/dhcpcd-<interface>.cache together with its pid file(/etc/dhcpc/dhcpcd-<interface>.pid). So that every time the network is set up, it request for a new IP address.

I commented out the line which does that and replace it with another one in /etc/rc.d/network like this:

#       rm -f /etc/dhcpc/dhcpcd-${1}.{pid,cache} >/dev/null 2>&1
                rm -f /etc/dhcpc/dhcpcd-${1}.pid >/dev/null 2>&1

Now, I always get the last IP I got before I reboot.

p.s. if there is anything wrong with this solution, please point it out.

Thanks for the replies.

Offline

#7 2005-08-18 10:51:47

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: [SOLVED]DHCP ip address changes too often

Well, you've customised an element of Arch's initscripts. Remember to add

NoUpgrade = /etc/rc.d/network

to /etc/pacman.conf, otherwise your change will be overwritten every time the initscripts get upgraded.

Now, maybe I can clear up some misunderstandings in your earlier post.

koyi wrote:

I am sharing the network with other friends. I don't know when they are going to plug in another computer into the network so I can't use totally static IP solutions.

Can you specify the DHCP range on your router? If so, set the range to e.g. 192.168.1.101 - 192.168.1.200, and then you can safely set static IPs from 192.168.1.100 down without any conflict.

koyi wrote:

I am setting Arch as if it is using a static address, like in the rc.conf I showed above in my first post. But in fact, the IP is assigned via DHCP.

No, it's one or the other. When the network script sees static ip info in rc.conf, it does not call dhcpcd.

koyi wrote:

I dual-boot my computer with Windows and Arch. So the IP address is assigned to Windows. Before it changes, I suppose that setting Arch to use that same assigned IP should work.

The two OSes behave completely independently, and as you have configured them i.e. DHCP for Windows, static for Arch. The fact that you have decided to use the same address for Arch's static assignment does not change that.

koyi wrote:

Spend some money to buy a real router.

If you can set the range as described above, it shouldn't be necessary.

koyi wrote:

Occassionally put into Windows to let the modem assign the same IP to the box and live with it.

Irrelevant - see above.

What make/model is your router, by the way?

Offline

#8 2005-08-18 12:55:36

vacant
Member
From: downstairs
Registered: 2004-11-05
Posts: 816

Re: [SOLVED]DHCP ip address changes too often

My cheapo ADSL modem/router acts as a DHCP server but since you can tell it to allocate a range of addresses, I've told it to allocate 10.0.0.3 to 10.0.0.15 for "guests" I plug in, while our fixed PCs have static IP outside that address range (I'm 10.0.0.16 etc).

As three of us may be all running bittorrent or edonkey simultaneously, we need to use the virtual server function of the router to forward ports - but that facility uses IP addresses, hence the need for a static IP for our permanent PCs. Of course, each PC has it's P2P client configured for a different TCP port.

Offline

#9 2005-08-18 14:34:28

koyi
Member
From: Osaka, Japan
Registered: 2005-08-15
Posts: 37

Re: [SOLVED]DHCP ip address changes too often

First, tomk, thanks for your explanations. smile

tomk wrote:

Well, you've customised an element of Arch's initscripts. Remember to add

NoUpgrade = /etc/rc.d/network

to /etc/pacman.conf, otherwise your change will be overwritten every time the initscripts get upgraded.

Thanks for this info. I think I will need it, now or in the future.

tomk wrote:

Can you specify the DHCP range on your router? If so, set the range to e.g. 192.168.1.101 - 192.168.1.200, and then you can safely set static IPs from 192.168.1.100 down without any conflict.

Ya I think I can.

tomk wrote:
koyi wrote:

I am setting Arch as if it is using a static address, like in the rc.conf I showed above in my first post. But in fact, the IP is assigned via DHCP.

No, it's one or the other. When the network script sees static ip info in rc.conf, it does not call dhcpcd.

I don't really get this. In fact, I don't really understand how static IP work when a DHCP server is present. Does this mean that when I set eth0 statically, the router/modem, which acts as a DHCP server, will know that the IP is set to the arch box? If not, how does it know which box to forward to when packages arrived for that static IP?

tomk wrote:

What make/model is your router, by the way?

I think it is only available in Japan.
It is the Flashwave 2040 M1 made by Fujitsu.
Again, thanks.

Added: I tried your method and it works flawlessly now smile thanks a lot!

Offline

#10 2005-08-18 16:24:58

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: [SOLVED]DHCP ip address changes too often

tomk wrote:

Mostly true, phrak, but the DHCP spec does include provisions for allocating a specified IP address to a particular machine, as suggested by rhfrommn. It's an equally valid solution to the problem - apart from that printer scenario, I use it so that my laptop gets a particular address when I'm at home, and a "normal" dynamic address when I'm anywhere else - without any rc.conf editing.

Well, yeah that works fine and all, but it seems a bit "kludgy" to me - that's why we need the roaming network profiles in the testing init scripts!

Laptops are always a special situation.

Offline

#11 2005-08-18 21:43:16

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: [SOLVED]DHCP ip address changes too often

koyi wrote:

First, tomk, thanks for your explanations. smile

No problem.

koyi wrote:

I don't really get this. In fact, I don't really understand how static IP work when a DHCP server is present. Does this mean that when I set eth0 statically, the router/modem, which acts as a DHCP server, will know that the IP is set to the arch box? If not, how does it know which box to forward to when packages arrived for that static IP?

The router learns which IP address belongs to which machine in two ways - either by assigning the address via DHCP, or by receiving packets from a statically-assigned IP. DHCP is designed to coexist with static addressing, as long as they don't overlap - that's why you specify a DHCP range, and set your static IPs outside that range.

koyi wrote:

Added: I tried your method and it works flawlessly now smile thanks a lot!

Anytime. smile

Offline

Board footer

Powered by FluxBB