When no dhcp server answer, how can I force dhclient to use the static lease from dhclient.conf instead of a...
I have a piece of equipment I would like to default to a specific IP address when no dhcp servers are available.
I have set the following static lease in /etc/dhcp/dhclient.conf:
timeout 30;
lease {
interface "eth0";
fixed-address 192.168.1.254;
option subnet-mask 255.255.255.0;
option routers 127.0.0.1;
expire never;
}
It works, but eth0 will only get this IP when dhclient.eth0.leases and dhclient.leases in /var/lib/dhcp/ are empty.
Unless you guys have a good reason to advise against it, I would prefer if the static lease from dhclient.conf was assigned when a dhcp server doesn't reply instead of using old leases. It would make the troubleshooting process easier and allow some way to reach the equipment which is only accessible via ssh and has no display to print out the current ip.
I read through the dhclient manual and a lot of google search results but couldn't find a built in way or any suggestions on how to do this.
Solutions I thought of:
1-Empty dhclient.leases and set permissions so it can't be modified
2-Link dhclient.leases to /dev/null and set permissions so it can't be modified
3-Same as #1 but instead of setting up the static lease in dhclient.conf, manually add it to dhclient.leases before setting permissions.
Of course I will try those but please advise.
Thank you.
debian ubuntu raspbian dhcp dhclient
bumped to the homepage by Community♦ 1 hour ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
I have a piece of equipment I would like to default to a specific IP address when no dhcp servers are available.
I have set the following static lease in /etc/dhcp/dhclient.conf:
timeout 30;
lease {
interface "eth0";
fixed-address 192.168.1.254;
option subnet-mask 255.255.255.0;
option routers 127.0.0.1;
expire never;
}
It works, but eth0 will only get this IP when dhclient.eth0.leases and dhclient.leases in /var/lib/dhcp/ are empty.
Unless you guys have a good reason to advise against it, I would prefer if the static lease from dhclient.conf was assigned when a dhcp server doesn't reply instead of using old leases. It would make the troubleshooting process easier and allow some way to reach the equipment which is only accessible via ssh and has no display to print out the current ip.
I read through the dhclient manual and a lot of google search results but couldn't find a built in way or any suggestions on how to do this.
Solutions I thought of:
1-Empty dhclient.leases and set permissions so it can't be modified
2-Link dhclient.leases to /dev/null and set permissions so it can't be modified
3-Same as #1 but instead of setting up the static lease in dhclient.conf, manually add it to dhclient.leases before setting permissions.
Of course I will try those but please advise.
Thank you.
debian ubuntu raspbian dhcp dhclient
bumped to the homepage by Community♦ 1 hour ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
I tested option #1 and set attributes using {chattr -i} which caused dhclient to give out errors about being unable to write to the dhcp.eth0.leases file but it wrote to it anyways even though the wait it read it seemed it wouldnt!
– TCZ8
Dec 15 '15 at 17:55
Just tested option #2 but didn't change its attributes as dhclient doesn't seem to care about respecting these. The good thing is It works and doesn't give errors. My only concern is making sure the soft link doesn't get replaced when dhclient decides it's time to rotate the file. I couldn't find any info on what triggers the file to be replaced. So I have no clue what and when it will happen. How am I going to test this? Is waiting and hoping for the best my only option?
– TCZ8
Dec 15 '15 at 18:01
I meant, I gave no clue if and when it will happen. So far so good.
– TCZ8
Dec 21 '15 at 14:32
add a comment |
I have a piece of equipment I would like to default to a specific IP address when no dhcp servers are available.
I have set the following static lease in /etc/dhcp/dhclient.conf:
timeout 30;
lease {
interface "eth0";
fixed-address 192.168.1.254;
option subnet-mask 255.255.255.0;
option routers 127.0.0.1;
expire never;
}
It works, but eth0 will only get this IP when dhclient.eth0.leases and dhclient.leases in /var/lib/dhcp/ are empty.
Unless you guys have a good reason to advise against it, I would prefer if the static lease from dhclient.conf was assigned when a dhcp server doesn't reply instead of using old leases. It would make the troubleshooting process easier and allow some way to reach the equipment which is only accessible via ssh and has no display to print out the current ip.
I read through the dhclient manual and a lot of google search results but couldn't find a built in way or any suggestions on how to do this.
Solutions I thought of:
1-Empty dhclient.leases and set permissions so it can't be modified
2-Link dhclient.leases to /dev/null and set permissions so it can't be modified
3-Same as #1 but instead of setting up the static lease in dhclient.conf, manually add it to dhclient.leases before setting permissions.
Of course I will try those but please advise.
Thank you.
debian ubuntu raspbian dhcp dhclient
I have a piece of equipment I would like to default to a specific IP address when no dhcp servers are available.
I have set the following static lease in /etc/dhcp/dhclient.conf:
timeout 30;
lease {
interface "eth0";
fixed-address 192.168.1.254;
option subnet-mask 255.255.255.0;
option routers 127.0.0.1;
expire never;
}
It works, but eth0 will only get this IP when dhclient.eth0.leases and dhclient.leases in /var/lib/dhcp/ are empty.
Unless you guys have a good reason to advise against it, I would prefer if the static lease from dhclient.conf was assigned when a dhcp server doesn't reply instead of using old leases. It would make the troubleshooting process easier and allow some way to reach the equipment which is only accessible via ssh and has no display to print out the current ip.
I read through the dhclient manual and a lot of google search results but couldn't find a built in way or any suggestions on how to do this.
Solutions I thought of:
1-Empty dhclient.leases and set permissions so it can't be modified
2-Link dhclient.leases to /dev/null and set permissions so it can't be modified
3-Same as #1 but instead of setting up the static lease in dhclient.conf, manually add it to dhclient.leases before setting permissions.
Of course I will try those but please advise.
Thank you.
debian ubuntu raspbian dhcp dhclient
debian ubuntu raspbian dhcp dhclient
edited Dec 21 '15 at 14:31
TCZ8
asked Dec 15 '15 at 16:48
TCZ8TCZ8
5393820
5393820
bumped to the homepage by Community♦ 1 hour ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community♦ 1 hour ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
I tested option #1 and set attributes using {chattr -i} which caused dhclient to give out errors about being unable to write to the dhcp.eth0.leases file but it wrote to it anyways even though the wait it read it seemed it wouldnt!
– TCZ8
Dec 15 '15 at 17:55
Just tested option #2 but didn't change its attributes as dhclient doesn't seem to care about respecting these. The good thing is It works and doesn't give errors. My only concern is making sure the soft link doesn't get replaced when dhclient decides it's time to rotate the file. I couldn't find any info on what triggers the file to be replaced. So I have no clue what and when it will happen. How am I going to test this? Is waiting and hoping for the best my only option?
– TCZ8
Dec 15 '15 at 18:01
I meant, I gave no clue if and when it will happen. So far so good.
– TCZ8
Dec 21 '15 at 14:32
add a comment |
I tested option #1 and set attributes using {chattr -i} which caused dhclient to give out errors about being unable to write to the dhcp.eth0.leases file but it wrote to it anyways even though the wait it read it seemed it wouldnt!
– TCZ8
Dec 15 '15 at 17:55
Just tested option #2 but didn't change its attributes as dhclient doesn't seem to care about respecting these. The good thing is It works and doesn't give errors. My only concern is making sure the soft link doesn't get replaced when dhclient decides it's time to rotate the file. I couldn't find any info on what triggers the file to be replaced. So I have no clue what and when it will happen. How am I going to test this? Is waiting and hoping for the best my only option?
– TCZ8
Dec 15 '15 at 18:01
I meant, I gave no clue if and when it will happen. So far so good.
– TCZ8
Dec 21 '15 at 14:32
I tested option #1 and set attributes using {chattr -i} which caused dhclient to give out errors about being unable to write to the dhcp.eth0.leases file but it wrote to it anyways even though the wait it read it seemed it wouldnt!
– TCZ8
Dec 15 '15 at 17:55
I tested option #1 and set attributes using {chattr -i} which caused dhclient to give out errors about being unable to write to the dhcp.eth0.leases file but it wrote to it anyways even though the wait it read it seemed it wouldnt!
– TCZ8
Dec 15 '15 at 17:55
Just tested option #2 but didn't change its attributes as dhclient doesn't seem to care about respecting these. The good thing is It works and doesn't give errors. My only concern is making sure the soft link doesn't get replaced when dhclient decides it's time to rotate the file. I couldn't find any info on what triggers the file to be replaced. So I have no clue what and when it will happen. How am I going to test this? Is waiting and hoping for the best my only option?
– TCZ8
Dec 15 '15 at 18:01
Just tested option #2 but didn't change its attributes as dhclient doesn't seem to care about respecting these. The good thing is It works and doesn't give errors. My only concern is making sure the soft link doesn't get replaced when dhclient decides it's time to rotate the file. I couldn't find any info on what triggers the file to be replaced. So I have no clue what and when it will happen. How am I going to test this? Is waiting and hoping for the best my only option?
– TCZ8
Dec 15 '15 at 18:01
I meant, I gave no clue if and when it will happen. So far so good.
– TCZ8
Dec 21 '15 at 14:32
I meant, I gave no clue if and when it will happen. So far so good.
– TCZ8
Dec 21 '15 at 14:32
add a comment |
2 Answers
2
active
oldest
votes
Then there is AVAHI whose primary purpose is to assign an IP address when all else fails.
AVAHI should hand out an impractical 169.254.x.x address.
RFC 5735 specifies 169.254.0.0/16 as the ""link local"" block as described in RFC3927. This is the address range to be used by hosts' auto-configuration, such as when a DHCP server cannot be found.
https://help.ubuntu.com/community/HowToZeroconf
add a comment |
I've created '/etc/sysconfig/network-scripts/ifcfg-eth0:0' :
DEVICE=eth0:0
BOOTPROTO=none
ONBOOT=yes
NETWORK=192.168.222.0
NETMASK=255.255.255.0
IPADDR=192.168.222.22
USERCTL=no
This just binds a 2nd static IP to the NIC, using an alias. Not really what I wanted, but will work until I figure out the dhclient.conf stuff.
Alternatively, you can hook up a second network interface card for that static purpose.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f249527%2fwhen-no-dhcp-server-answer-how-can-i-force-dhclient-to-use-the-static-lease-fro%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Then there is AVAHI whose primary purpose is to assign an IP address when all else fails.
AVAHI should hand out an impractical 169.254.x.x address.
RFC 5735 specifies 169.254.0.0/16 as the ""link local"" block as described in RFC3927. This is the address range to be used by hosts' auto-configuration, such as when a DHCP server cannot be found.
https://help.ubuntu.com/community/HowToZeroconf
add a comment |
Then there is AVAHI whose primary purpose is to assign an IP address when all else fails.
AVAHI should hand out an impractical 169.254.x.x address.
RFC 5735 specifies 169.254.0.0/16 as the ""link local"" block as described in RFC3927. This is the address range to be used by hosts' auto-configuration, such as when a DHCP server cannot be found.
https://help.ubuntu.com/community/HowToZeroconf
add a comment |
Then there is AVAHI whose primary purpose is to assign an IP address when all else fails.
AVAHI should hand out an impractical 169.254.x.x address.
RFC 5735 specifies 169.254.0.0/16 as the ""link local"" block as described in RFC3927. This is the address range to be used by hosts' auto-configuration, such as when a DHCP server cannot be found.
https://help.ubuntu.com/community/HowToZeroconf
Then there is AVAHI whose primary purpose is to assign an IP address when all else fails.
AVAHI should hand out an impractical 169.254.x.x address.
RFC 5735 specifies 169.254.0.0/16 as the ""link local"" block as described in RFC3927. This is the address range to be used by hosts' auto-configuration, such as when a DHCP server cannot be found.
https://help.ubuntu.com/community/HowToZeroconf
answered Oct 16 '18 at 17:22
Egbert SEgbert S
1837
1837
add a comment |
add a comment |
I've created '/etc/sysconfig/network-scripts/ifcfg-eth0:0' :
DEVICE=eth0:0
BOOTPROTO=none
ONBOOT=yes
NETWORK=192.168.222.0
NETMASK=255.255.255.0
IPADDR=192.168.222.22
USERCTL=no
This just binds a 2nd static IP to the NIC, using an alias. Not really what I wanted, but will work until I figure out the dhclient.conf stuff.
Alternatively, you can hook up a second network interface card for that static purpose.
add a comment |
I've created '/etc/sysconfig/network-scripts/ifcfg-eth0:0' :
DEVICE=eth0:0
BOOTPROTO=none
ONBOOT=yes
NETWORK=192.168.222.0
NETMASK=255.255.255.0
IPADDR=192.168.222.22
USERCTL=no
This just binds a 2nd static IP to the NIC, using an alias. Not really what I wanted, but will work until I figure out the dhclient.conf stuff.
Alternatively, you can hook up a second network interface card for that static purpose.
add a comment |
I've created '/etc/sysconfig/network-scripts/ifcfg-eth0:0' :
DEVICE=eth0:0
BOOTPROTO=none
ONBOOT=yes
NETWORK=192.168.222.0
NETMASK=255.255.255.0
IPADDR=192.168.222.22
USERCTL=no
This just binds a 2nd static IP to the NIC, using an alias. Not really what I wanted, but will work until I figure out the dhclient.conf stuff.
Alternatively, you can hook up a second network interface card for that static purpose.
I've created '/etc/sysconfig/network-scripts/ifcfg-eth0:0' :
DEVICE=eth0:0
BOOTPROTO=none
ONBOOT=yes
NETWORK=192.168.222.0
NETMASK=255.255.255.0
IPADDR=192.168.222.22
USERCTL=no
This just binds a 2nd static IP to the NIC, using an alias. Not really what I wanted, but will work until I figure out the dhclient.conf stuff.
Alternatively, you can hook up a second network interface card for that static purpose.
edited Oct 16 '18 at 17:25
answered Oct 16 '18 at 17:19
Egbert SEgbert S
1837
1837
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f249527%2fwhen-no-dhcp-server-answer-how-can-i-force-dhclient-to-use-the-static-lease-fro%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I tested option #1 and set attributes using {chattr -i} which caused dhclient to give out errors about being unable to write to the dhcp.eth0.leases file but it wrote to it anyways even though the wait it read it seemed it wouldnt!
– TCZ8
Dec 15 '15 at 17:55
Just tested option #2 but didn't change its attributes as dhclient doesn't seem to care about respecting these. The good thing is It works and doesn't give errors. My only concern is making sure the soft link doesn't get replaced when dhclient decides it's time to rotate the file. I couldn't find any info on what triggers the file to be replaced. So I have no clue what and when it will happen. How am I going to test this? Is waiting and hoping for the best my only option?
– TCZ8
Dec 15 '15 at 18:01
I meant, I gave no clue if and when it will happen. So far so good.
– TCZ8
Dec 21 '15 at 14:32