LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-02-2017, 09:23 AM   #1
taylorkh
Senior Member
 
Registered: Jul 2006
Location: North Carolina
Distribution: CentOS 6, CentOS 7 (with Mate), Ubuntu 16.04 Mate
Posts: 1,921

Rep: Reputation: 158Reputation: 158
Question How often does a computer need to access a DHCP server?


This might belong in networking but it is so simple (I should know the answer but don't) that I am posting it here...

I have a PC setup as a VPN sharing box and a DHCP server. A few minutes ago I took the box down to do a semi-annual backup image of the drive. I realize that this would kill my Internet access until it was back on line and connected to the VPN provider. No problem. However...

When I place the box back in operation I found that my PC could not connect to it. ifconfig on the PC showed NO IP address on the Ethernet NIC. The NIC is configured to get its IPv4 address by "Automatic (DHCP)". Stopping and starting the Ethernet connection of course brought back the IP address to the PC. Which makes me wonder...

I understand that a DHCP server issues an IP address with a "lease time" perhaps an hour. During that time if the recipient of the IP address drops off the network and then returns the recipient will get that same address. After the lease period the recipient might find that the address has been given to a different requester. That is well and good. However, why does the recipient forget its assigned address while it is still connected to the network and the DHCP server is temporarily down?

TIA,

Ken
 
Old 07-02-2017, 09:35 AM   #2
Rickkkk
Senior Member
 
Registered: Dec 2014
Location: Montreal, Quebec, CANADA
Distribution: Arch
Posts: 1,113

Rep: Reputation: 421Reputation: 421Reputation: 421Reputation: 421Reputation: 421
Hi Ken,

Since you say that bringing down your DHCP server for maintenance would interrupt Internet access, could it be that the computer you are using as a DHCP server is also the default gateway (your description of your setup seems to suggest this ...) ? If a client computer loses its default gateway, it might behave the way you have described.

Cheers,

Last edited by Rickkkk; 07-02-2017 at 09:36 AM.
 
Old 07-02-2017, 10:25 AM   #3
taylorkh
Senior Member
 
Registered: Jul 2006
Location: North Carolina
Distribution: CentOS 6, CentOS 7 (with Mate), Ubuntu 16.04 Mate
Posts: 1,921

Original Poster
Rep: Reputation: 158Reputation: 158
Thanks Rickkkk,

Yes, the DHCP box is also the default gateway. However, it is my understanding that the gateway is necessary to connect to a different subnet. For example, my LAN is on 10.42.0.nnn. In its gateway role the DCHP box will route traffic to the VPN network (e.g. 162.210.192.159).

If I hard code an address into two machines on my LAN on 10.42.0.nnn and plug them into a switch they should be able to talk to each other without benefit of a gateway. Perhaps I will try that and see what happens.

Ken
 
Old 07-02-2017, 12:22 PM   #4
brebs
Member
 
Registered: May 2013
Posts: 88

Rep: Reputation: Disabled
Quote:
Originally Posted by taylorkh View Post
why does the recipient forget its assigned address while it is still connected to the network and the DHCP server is temporarily down?
I expect the DHCP lease expired, during that "temporary" period. So, could consider it bad timing.

However, there's different ways that DHCP clients can operate. I reckon the 3 main client strategies, in order of complexity, are:

Do a DHCP lookup & get a connection at bootup, then:
1. Forget about DHCP, i.e. don't monitor DHCP further.
2. At lease expiry time, ask for a DHCP update, and check for changes.
3. Set the IP configuration to timeout (as shown by "ip addr" on the Linux client), and require a DHCP update at every lease expiry.

I'd say that option 3 would usually be needlessly excessive.
 
Old 07-02-2017, 02:22 PM   #5
taylorkh
Senior Member
 
Registered: Jul 2006
Location: North Carolina
Distribution: CentOS 6, CentOS 7 (with Mate), Ubuntu 16.04 Mate
Posts: 1,921

Original Poster
Rep: Reputation: 158Reputation: 158
Thanks brebs,

ip addr showed
Code:
2: enp0s31f6: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 48:4d:7e:e7:bd:1b brd ff:ff:ff:ff:ff:ff
    inet 10.42.0.120/24 brd 10.42.0.255 scope global dynamic enp0s31f6
       valid_lft 586sec preferred_lft 586sec
    inet6 fe80::4a4d:7eff:fee7:bd1b/64 scope link 
       valid_lft forever preferred_lft forever
This was just after bringing up the Ethernet connection so I suspect the time period in question is 10 minutes or 600 seconds.

What I SHOULD have done instead of setting up a DHCP server (it was too much fun and a good learning experience :-) was to hard code the IP address in each of my handful of machines. I have IP addresses for each device specified in the DHCP configuration and I have a /etc/hosts file on each machine for machine to machine lookup. I configured the IP manually on the machine from which the above example produced. ip addr now shows
Code:
2: enp0s31f6: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 48:4d:7e:e7:bd:1b brd ff:ff:ff:ff:ff:ff
    inet 10.42.0.120/24 brd 10.42.0.255 scope global enp0s31f6
       valid_lft forever preferred_lft forever
    inet6 fe80::4a4d:7eff:fee7:bd1b/64 scope link 
       valid_lft forever preferred_lft forever
I tested by manually configuring a second machine then unplugging the DHCP server from the LAN. The two machines could communicate fine and their IP addresses did not disappear. I will leave the DHCP server running for some occasionally used virtual machines and manually configure the physical machines. That would appear to be a SIMPLE answer.

Thanks again,

Ken
 
Old 07-02-2017, 03:11 PM   #6
brebs
Member
 
Registered: May 2013
Posts: 88

Rep: Reputation: Disabled
That's 3 bad things:

* Very short DHCP lease timeout
* A DHCP client which adds the lease expiry to the IP address
* Unnecessary use of ipv6, which is easy to fix, with e.g. "options ipv6 disable_ipv6=1" in /etc/modprobe.d/call-it-whatever.conf
 
Old 07-02-2017, 03:11 PM   #7
JeremyBoden
Senior Member
 
Registered: Nov 2011
Location: London, UK
Distribution: Debian
Posts: 1,559

Rep: Reputation: 316Reputation: 316Reputation: 316Reputation: 316
If you buy one additional machine, you will have to update all your existing machines.

Good luck if you want to access your wifi connection on your mobile.

BTW I've set my DHCP lease time to 24 hours.
 
Old 07-04-2017, 02:56 AM   #8
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 1,642

Rep: Reputation: 277Reputation: 277Reputation: 277
Lightbulb

Quote:
Originally Posted by taylorkh View Post
Thanks Rickkkk,

Yes, the DHCP box is also the default gateway. However, it is my understanding that the gateway is necessary to connect to a different subnet. For example, my LAN is on 10.42.0.nnn. In its gateway role the DCHP box will route traffic to the VPN network (e.g. 162.210.192.159).

If I hard code an address into two machines on my LAN on 10.42.0.nnn and plug them into a switch they should be able to talk to each other without benefit of a gateway. Perhaps I will try that and see what happens.

Ken
For the machines to communicate between each other you need to have a router, a switch is unable to route packets unless of course it is a smart switch that supports routing.

If your DHCP box is a Linux box. You can temporarily create the DHCP on your router, is this for your home network or office network?

Whatever network it is just purchase a cheap router and make it as a DHCP server while taking down your current DHCP. Make sure of course that all configuration is the same especially the IP Address that is lease to the network. I think users won't be able to able to tell that current DHCP is down, if another DHCP is ready to take the role.

Good luck!
 
Old 07-04-2017, 07:46 AM   #9
michaelk
Moderator
 
Registered: Aug 2002
Posts: 19,048

Rep: Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893
For two devices to communicate with each other using static IP addresses on the same LAN/subnet all you need is an ethernet cable connecting them together.

With many current distributions the network adapters and the DHCP client are controlled by NetworkManager. As stated there could be several reason why it might loose its IP address. Without knowing anything about your network configuration a fourth reason might be that NetworkManager sensed eth0 lost link.

I have never tried but you could (assuming your systems are using dhclient) preload a static IP lease. I've never tired it and do not know if it works with NetworkManager.
 
Old 07-04-2017, 10:56 AM   #10
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 9,078
Blog Entries: 4

Rep: Reputation: 3177Reputation: 3177Reputation: 3177Reputation: 3177Reputation: 3177Reputation: 3177Reputation: 3177Reputation: 3177Reputation: 3177Reputation: 3177Reputation: 3177
Most home routers provide DHCP services in addition to routing. If your computer got its DHCP assignment from the router, then the router always knows where your computer (MAC Address) is.

DHCP assignments are called "leases" and they do customarily have a timeout period after which they are renewed through automatic re-negotiation with the server.
 
  


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
DHCP server different computer model Juako666 Linux - Server 7 10-06-2011 02:38 AM
how a computer determine dhcp server ? password636 Linux - Networking 3 12-09-2010 04:06 AM
New DHCP Server triggers a Printer and XP computer to Power Cycle pawprint_net Linux - Networking 12 11-17-2009 12:39 PM
how does my computer tell its name to the DHCP server ? theinfidel Linux - Networking 14 12-31-2007 03:31 PM
unauthorized client cant access my DHCP server selfnet Linux - Networking 2 04-28-2005 05:21 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:20 PM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration