Setting IP address if DHCP server fails at bootup











up vote
0
down vote

favorite












Is there a way to set default eth0 setup in linux. I know I can give it a default static IP at boot up with sudo ip route add default via 10.0.0.1 dev eth0. Is there a way to change it to DHCP at bootup. AND if it's in DHCP but I do NOT have my ethernet cable connected to the network, I want it to be set to an IP address so that it always has a way to be able to connect to it at bootup without any extra commands from the terminal. So.... a default IP address if a DHCP address is not found. Is this possible? and how?



Backstory: I'm writing a c++ console application that is listening from a socket. The end user connects to my linux device (via Windows PC usually) and can then send commands. Everything work as of now, but I want the end user to have the option of setting the default to static of dynamic at startup. They can only connect to the application if there is an IP address present. I want to add this just in case the user forgets to connect to the server if it is in dhcp mode at startup.










share|improve this question






















  • Related SO Q&A: stackoverflow.com/q/12727175/1531971
    – jdv
    3 hours ago










  • Thanks! But is there a way to have dhcp as default if I've already made static my default? A toggle between both that I can add to my code. For static default, I send the command in my question. For dynamic, is there a terminal command to do the same?
    – miceandmon
    3 hours ago










  • There is a fixed Ask Ubuntu networking page somewhere that may answer that.
    – jdv
    3 hours ago












  • oh ok. Got it. Thank you!!
    – miceandmon
    3 hours ago










  • If you find an actual answer to your question (or if it is answered elsewhere) make sure circle back here and let us know so future folks can benefit...
    – jdv
    2 hours ago















up vote
0
down vote

favorite












Is there a way to set default eth0 setup in linux. I know I can give it a default static IP at boot up with sudo ip route add default via 10.0.0.1 dev eth0. Is there a way to change it to DHCP at bootup. AND if it's in DHCP but I do NOT have my ethernet cable connected to the network, I want it to be set to an IP address so that it always has a way to be able to connect to it at bootup without any extra commands from the terminal. So.... a default IP address if a DHCP address is not found. Is this possible? and how?



Backstory: I'm writing a c++ console application that is listening from a socket. The end user connects to my linux device (via Windows PC usually) and can then send commands. Everything work as of now, but I want the end user to have the option of setting the default to static of dynamic at startup. They can only connect to the application if there is an IP address present. I want to add this just in case the user forgets to connect to the server if it is in dhcp mode at startup.










share|improve this question






















  • Related SO Q&A: stackoverflow.com/q/12727175/1531971
    – jdv
    3 hours ago










  • Thanks! But is there a way to have dhcp as default if I've already made static my default? A toggle between both that I can add to my code. For static default, I send the command in my question. For dynamic, is there a terminal command to do the same?
    – miceandmon
    3 hours ago










  • There is a fixed Ask Ubuntu networking page somewhere that may answer that.
    – jdv
    3 hours ago












  • oh ok. Got it. Thank you!!
    – miceandmon
    3 hours ago










  • If you find an actual answer to your question (or if it is answered elsewhere) make sure circle back here and let us know so future folks can benefit...
    – jdv
    2 hours ago













up vote
0
down vote

favorite









up vote
0
down vote

favorite











Is there a way to set default eth0 setup in linux. I know I can give it a default static IP at boot up with sudo ip route add default via 10.0.0.1 dev eth0. Is there a way to change it to DHCP at bootup. AND if it's in DHCP but I do NOT have my ethernet cable connected to the network, I want it to be set to an IP address so that it always has a way to be able to connect to it at bootup without any extra commands from the terminal. So.... a default IP address if a DHCP address is not found. Is this possible? and how?



Backstory: I'm writing a c++ console application that is listening from a socket. The end user connects to my linux device (via Windows PC usually) and can then send commands. Everything work as of now, but I want the end user to have the option of setting the default to static of dynamic at startup. They can only connect to the application if there is an IP address present. I want to add this just in case the user forgets to connect to the server if it is in dhcp mode at startup.










share|improve this question













Is there a way to set default eth0 setup in linux. I know I can give it a default static IP at boot up with sudo ip route add default via 10.0.0.1 dev eth0. Is there a way to change it to DHCP at bootup. AND if it's in DHCP but I do NOT have my ethernet cable connected to the network, I want it to be set to an IP address so that it always has a way to be able to connect to it at bootup without any extra commands from the terminal. So.... a default IP address if a DHCP address is not found. Is this possible? and how?



Backstory: I'm writing a c++ console application that is listening from a socket. The end user connects to my linux device (via Windows PC usually) and can then send commands. Everything work as of now, but I want the end user to have the option of setting the default to static of dynamic at startup. They can only connect to the application if there is an IP address present. I want to add this just in case the user forgets to connect to the server if it is in dhcp mode at startup.







16.04 networking network-manager dhcp static-ip






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 3 hours ago









miceandmon

235




235












  • Related SO Q&A: stackoverflow.com/q/12727175/1531971
    – jdv
    3 hours ago










  • Thanks! But is there a way to have dhcp as default if I've already made static my default? A toggle between both that I can add to my code. For static default, I send the command in my question. For dynamic, is there a terminal command to do the same?
    – miceandmon
    3 hours ago










  • There is a fixed Ask Ubuntu networking page somewhere that may answer that.
    – jdv
    3 hours ago












  • oh ok. Got it. Thank you!!
    – miceandmon
    3 hours ago










  • If you find an actual answer to your question (or if it is answered elsewhere) make sure circle back here and let us know so future folks can benefit...
    – jdv
    2 hours ago


















  • Related SO Q&A: stackoverflow.com/q/12727175/1531971
    – jdv
    3 hours ago










  • Thanks! But is there a way to have dhcp as default if I've already made static my default? A toggle between both that I can add to my code. For static default, I send the command in my question. For dynamic, is there a terminal command to do the same?
    – miceandmon
    3 hours ago










  • There is a fixed Ask Ubuntu networking page somewhere that may answer that.
    – jdv
    3 hours ago












  • oh ok. Got it. Thank you!!
    – miceandmon
    3 hours ago










  • If you find an actual answer to your question (or if it is answered elsewhere) make sure circle back here and let us know so future folks can benefit...
    – jdv
    2 hours ago
















Related SO Q&A: stackoverflow.com/q/12727175/1531971
– jdv
3 hours ago




Related SO Q&A: stackoverflow.com/q/12727175/1531971
– jdv
3 hours ago












Thanks! But is there a way to have dhcp as default if I've already made static my default? A toggle between both that I can add to my code. For static default, I send the command in my question. For dynamic, is there a terminal command to do the same?
– miceandmon
3 hours ago




Thanks! But is there a way to have dhcp as default if I've already made static my default? A toggle between both that I can add to my code. For static default, I send the command in my question. For dynamic, is there a terminal command to do the same?
– miceandmon
3 hours ago












There is a fixed Ask Ubuntu networking page somewhere that may answer that.
– jdv
3 hours ago






There is a fixed Ask Ubuntu networking page somewhere that may answer that.
– jdv
3 hours ago














oh ok. Got it. Thank you!!
– miceandmon
3 hours ago




oh ok. Got it. Thank you!!
– miceandmon
3 hours ago












If you find an actual answer to your question (or if it is answered elsewhere) make sure circle back here and let us know so future folks can benefit...
– jdv
2 hours ago




If you find an actual answer to your question (or if it is answered elsewhere) make sure circle back here and let us know so future folks can benefit...
– jdv
2 hours ago















active

oldest

votes











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
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',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
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
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1093529%2fsetting-ip-address-if-dhcp-server-fails-at-bootup%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1093529%2fsetting-ip-address-if-dhcp-server-fails-at-bootup%23new-answer', 'question_page');
}
);

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







Popular posts from this blog

flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

Mangá

 ⁒  ․,‪⁊‑⁙ ⁖, ⁇‒※‌, †,⁖‗‌⁝    ‾‸⁘,‖⁔⁣,⁂‾
”‑,‥–,‬ ,⁀‹⁋‴⁑ ‒ ,‴⁋”‼ ⁨,‷⁔„ ‰′,‐‚ ‥‡‎“‷⁃⁨⁅⁣,⁔
⁇‘⁔⁡⁏⁌⁡‿‶‏⁨ ⁣⁕⁖⁨⁩⁥‽⁀  ‴‬⁜‟ ⁃‣‧⁕‮ …‍⁨‴ ⁩,⁚⁖‫ ,‵ ⁀,‮⁝‣‣ ⁑  ⁂– ․, ‾‽ ‏⁁“⁗‸ ‾… ‹‡⁌⁎‸‘ ‡⁏⁌‪ ‵⁛ ‎⁨ ―⁦⁤⁄⁕