Network via LAN

vince66

Well-Known Member

Thanks: 10
Messages: 394

#1
Hello guys,
I've installed FreeBSD on a USB stick avoiding to use the guided configuration procedure of any network (LAN and WIFI).

Successively I've used dhclient to dinamically set up the DHCP.

Please, can you tell me which files are updated using dhclient ?

Thanks very much.
 

jiml8

Member

Thanks: 2
Messages: 28

#2
You will find the lease files in /var/db. If the dhclient defaults do not work for you (they should) then you will need to edit /etc/dhclient.conf.
 
OP
OP
vince66

vince66

Well-Known Member

Thanks: 10
Messages: 394

#3
Who fills the /var/db/dhclient.leases.xxx (xxx is the name of the card).

Does dhclient read the leases file to set-up the LAN ?

In which a way the LAN can ne set-up at boot, insted Evert time manually invoking dhclient ?
 

`Orum

Active Member

Thanks: 14
Messages: 121

#4
Most of this is covered in the handbook, but the leases file is both written and read by dhclient, depending on the circumstances. It's written when it receives a new lease, and it's read if it can't contact a DHCP server (as a fallback if the lease is still valid and the DHCP server is down).

Read the "11.5.2. Configuring the Network Card" section of the handbook for how to get DHCP at boot.
 

kpa

Beastie's Twin

Thanks: 1,776
Messages: 6,286

#5
You need to read on how DHCP works. The client will try to use an existing lease from /var/db/dhclient.leases.xxx if it hasn't yet expired, that sole purpose of the file is to keep the lease information so that is survives reboots. If the file has no valid leases dhclient(8) will start the DHCP server discovery and lease negotiation from scratch.
 
OP
OP
vince66

vince66

Well-Known Member

Thanks: 10
Messages: 394

#6
leases file is both written and read by dhclient
The client will try to use an existing lease from /var/db/dhclient.leases.xxx
My question is:

If I change network, is dhclient able to over-write the file /var/db/dhclient.leases.xxx updating the info inside it and connecting the machine to the new network ?

Or .... what can I do ? ..... (my apologize .... I'm asking the question before I did a test).
 

kpa

Beastie's Twin

Thanks: 1,776
Messages: 6,286

#7
If you change to another network dhclient will first try to use the old lease but the DHCP server in the new network will reject the request to use the old lease and the negotiation returns to the state where the client has no lease.
 

sko

Well-Known Member

Thanks: 206
Messages: 407

#8
If I change network, is dhclient able to over-write the file /var/db/dhclient.leases.xxx updating the info inside it and connecting the machine to the new network ?
Have you actually looked at the file and its manpage dhclient.leases(5)?
The very first 4 sentences in the description already answer your question:
The Internet Software Consortium DHCP client keeps a persistent database
of leases that it has acquired that are still valid. The database is a
free-form ASCII file containing one valid declaration per lease. If more
than one declaration appears for a given lease, the last one in the file
is used. The file is written as a log, so this is not an unusual
occurrence.
Re your initial question:
Please, can you tell me which files are updated using dhclient ?
dhclient(8):
In order to keep track of leases across system reboots and server
restarts, dhclient keeps a list of leases it has been assigned in the
/var/db/dhclient.leases.IFNAME file.
Or .... what can I do ?
Reading the manpages of the tools/files you want to understand. If this doesn't answer all your questions, go through the other manpages and RFCs mentioned in the "SEE ALSO" section.
 
OP
OP
vince66

vince66

Well-Known Member

Thanks: 10
Messages: 394

#9
The very first 4 sentences in the description already answer your question
If you like and enjoy, can you also search for the answer to the following my question.
I prefer to discuss the problem and ask what I don't know.


If you change to another network dhclient will first try to use the old lease but the DHCP server in the new network will reject the request to use the old lease and the negotiation returns to the state where the client has no lease.

I came back home from work, Ive connected the PC to to the LAN cable , I've run the dhclient re0 command and the PC did not connect anymore.

Why ?
Nothing I've changed.
I've tried with the follow commands:

service netif restart

ifconfig re0 down
ifconfig re up
dhclient re0

but ping google.com doesn't work.

Tips are welcome.
 
Top