Linux/Ubuntu2016. 10. 5. 18:18

dhclient.conf에서 lease를 이용하면 된다고 한다.


timeout 10;

lease {

interface "eth0";

fixed-address 10.0.0.10;

option subnet-mask 255.255.255.0;

renew 2 2022/1/1 00:00:01;

rebind 2 2022/1/1 00:00:01;

expire 2 2022/1/1 0:00:01;


or you can assign a second IP to the interface like /etc/network/interfaces


auto lo

iface lo inet loopback

iface eth0 inet dhcp


auto eth0:1

iface eth0:1 inet static

address 10.10.10.2

netmask 255.255.255.0

[링크 : http://stackoverflow.com/questions/12727175/set-static-ip-if-not-obtained-from-dhcp-script]


The timeout statement


timeout time ;


The timeout statement determines the amount of time that must pass between the time that the client begins to try to determine its address and the time that it decides that it's not going to be able to contact a server. By default, this timeout is sixty seconds. After the timeout has passed, if there are any static leases defined in the configuration file, or any leases remaining in the lease database that have not yet expired, the client will loop through these leases attempting to validate them, and if it finds one that appears to be valid, it will use that lease's address. If there are no valid static leases or unexpired leases in the lease database, the client will restart the protocol after the defined retry interval.Lease Declarations



The lease declaration


lease { lease-declaration [ ... lease-declaration ] }


The DHCP client may decide after some period of time (see PROTOCOL TIMING) that it is not going to succeed in contacting a server. At that time, it consults its own database of old leases and tests each one that has not yet timed out by pinging the listed router for that lease to see if that lease could work. It is possible to define one or more fixed leases in the client configuration file for networks where there is no DHCP or BOOTP service, so that the client can still automatically configure its address. This is done with the lease statement.


NOTE: the lease statement is also used in the dhclient.leases file in order to record leases that have been received from DHCP servers. Some of the syntax for leases as described below is only needed in the dhclient.leases file. Such syntax is documented here for completeness.


A lease statement consists of the lease keyword, followed by a left curly brace, followed by one or more lease declaration statements, followed by a right curly brace. The following lease declarations are possible:

[링크 : https://linux.die.net/man/5/dhclient.conf]


odroid 설정파일

$ vi /etc/dhcp/dhclient.conf

# Configuration file for /sbin/dhclient, which is included in Debian's

#       dhcp3-client package.

#

# This is a sample configuration file for dhclient. See dhclient.conf's

#       man page for more information about the syntax of this file

#       and a more comprehensive list of the parameters understood by

#       dhclient.

#

# Normally, if the DHCP server provides reasonable information and does

#       not leave anything out (like the domain name, for example), then

#       few changes must be made to this file, if any.

#


option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;


#send host-name "andare.fugue.com";

send host-name = gethostname();

#send dhcp-client-identifier 1:0:a0:24:ab:fb:9c;

#send dhcp-lease-time 3600;

#supersede domain-name "fugue.com home.vix.com";

#prepend domain-name-servers 127.0.0.1;

request subnet-mask, broadcast-address, time-offset, routers,

        domain-name, domain-name-servers, domain-search, host-name,

        dhcp6.name-servers, dhcp6.domain-search,

        netbios-name-servers, netbios-scope, interface-mtu,

        rfc3442-classless-static-routes, ntp-servers,

        dhcp6.fqdn, dhcp6.sntp-servers;

#require subnet-mask, domain-name-servers;

#timeout 60;

#retry 60;

#reboot 10;

#select-timeout 5;

#initial-interval 2;

#script "/etc/dhcp3/dhclient-script";

#media "-link0 -link1 -link2", "link0 link1";

#reject 192.33.137.209;


#alias {

#  interface "eth0";

#  fixed-address 192.5.5.213;

#  option subnet-mask 255.255.255.255;

#}


#lease {

#  interface "eth0";

#  fixed-address 192.33.137.200;

#  medium "link0 link1";

#  option host-name "andare.swiftmedia.com";

#  option subnet-mask 255.255.255.0;

#  option broadcast-address 192.33.137.255;

#  option routers 192.33.137.250;

#  option domain-name-servers 127.0.0.1;

#  renew 2 2000/1/12 00:00:01;

#  rebind 2 2000/1/12 00:00:01;

#  expire 2 2000/1/12 00:00:01;

#} 


어? odroid에 해봤는데 안되네.. 머지??!?!

아무튼.. dhcp는 link가 탐지되어야 하니 최소한 랜은 꽂혀서 hub에 연결은 되어야 dhcp client가 가동된다.


+

$ sudo vi /etc/dhcp/dhclient-enter-hooks.d/debug

RUN="yes"

                                echo "$var='${!var}'" >> /tmp/dhclient-script.debug 


[링크 : https://lists.debian.org/debian-user/2010/10/msg00375.html]

위의 내용을 바꾸면 /tmp/dhclient-script.debug 에 로그가 쌓이는데


Wed Oct 5 21:23:43 KST 2016: entering /sbin, dumping variables.

reason='PREINIT'

interface='eth0'

--------------------------

Wed Oct 5 21:23:54 KST 2016: entering /sbin, dumping variables.

reason='FAIL'

interface='eth0'

--------------------------

Wed Oct 5 21:24:10 KST 2016: entering /sbin, dumping variables.

reason='PREINIT'

interface='eth0'

--------------------------

Wed Oct 5 21:24:11 KST 2016: entering /sbin, dumping variables.

reason='TIMEOUT'

interface='eth0'

new_ip_address='192.168.219.130'

new_network_number='192.168.219.0'

new_subnet_mask='255.255.255.0'

new_broadcast_address='192.168.219.255'

new_routers='192.168.219.1'

new_domain_name_servers='1.214.68.2 61.41.153.2'

--------------------------

Wed Oct 5 21:24:14 KST 2016: entering /sbin, dumping variables.

reason='FAIL'

interface='eth0'

--------------------------

Wed Oct 5 21:27:14 KST 2016: entering /sbin, dumping variables.

reason='FAIL'

interface='eth0'

--------------------------

Wed Oct 5 21:27:40 KST 2016: entering /sbin, dumping variables.

reason='PREINIT'

interface='eth0'

--------------------------

Wed Oct 5 21:27:41 KST 2016: entering /sbin, dumping variables.

reason='BOUND'

interface='eth0'

new_ip_address='192.168.219.130'

new_network_number='192.168.219.0'

new_subnet_mask='255.255.255.0'

new_broadcast_address='192.168.219.255'

new_routers='192.168.219.1'

new_domain_name_servers='1.214.68.2 61.41.153.2'

old_ip_address='192.168.219.130'

old_network_number='192.168.219.0'

old_subnet_mask='255.255.255.0'

old_broadcast_address='192.168.219.255'

old_routers='192.168.219.1'

old_domain_name_servers='1.214.68.2 61.41.153.2'

-------------------------- 


운 좋게(?) timeout 한번나서 설정되었지만.. 내가 의도한 녀석은 아니고..

정상적으로 dhcp를 통해 받아와서야 BOUND로 표기되었다...

lease는 그냥 timeout 인건가.. 아니면 timeout을 길게줘야하나?



내용에 의하면.. 내가 원하는... DHCP 값을 못 받아 올 경우

기본 값으로 설정하는 용도로는 맞지 않다는 거군....

Expire

The DHCP client has failed to renew its lease or acquire a new one, and the lease has expired. The IP address must be relinquished, and all related parameters should be deleted, as in RENEW and REBIND.


Fail

The DHCP client has been unable to contact any DHCP servers, and any leases that have been tested have not proved to be valid. The parameters from the last lease tested should be deconfigured. This can be handled in the same way as EXPIRE.


Timeout

The DHCP client has been unable to contact any DHCP servers. However, an old lease has been identified, and its parameters have been passed in as with BOUND. The client configuration script should test these parameters and, if it has reason to believe they are valid, should exit with a value of zero. If not, it should exit with a nonzero value.

The usual way to test a lease is to set up the network as with REBIND (since this may be called to test more than one lease) and then ping the first router defined in $routers. If a response is received, the lease must be valid for the network to which the interface is currently connected. It would be more complete to try to ping all of the routers listed in $new_routers, as well as those listed in $new_static_routes, but current scripts do not do this.


[링크 : https://linux.die.net/man/8/dhclient-script]

[링크 : https://www.freebsd.org/cgi/man.cgi?dhclient-script(8)]


[링크 : http://elinux.org/RPi_Setting_up_a_static_IP_in_Debian]

'Linux > Ubuntu' 카테고리의 다른 글

ubuntu php4 설치  (0) 2016.10.06
ubuntu apt를 통해 자동 업데이트 되지 않도록 하기  (0) 2016.10.05
proprietary driver on lubuntu  (0) 2016.09.09
gnome-disks 벤치마크  (0) 2016.09.05
lynx 마우스 사용하기  (0) 2016.08.18
Posted by 구차니