Find actual default gateway from command line

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I need to get the router IP which I thought I could do via the ip route command (or many other variations). These all return a value for the default gateway which was fine until I discovered that what these commands return is actually the routers line in /etc/dhcpcd.conf.



This wouldn't normally be an issue except the use case I'm trying to solve is when the default gateway has changed from what is configured (e.g. user moves house or gets a new ISP or even just a new router that is configured with a different IP address than the previous one). Obviously if the configuration is wrong in dhcpcd.conf then there isn't a valid route to the internet.



Is there any command to get/find the actual IP address of the router or do I have to add a new gateway, ping something, if working great but if not then try another gateway?










share|improve this question























  • Hi and welcome. The ip route command gets the route information from the kernel, not from any configuration file. It may be true that the kernel information was previously supplied from configuration, but ip route doesn't know about that. In the end, the default route is what the kernel thinks that it is. In your case, when the machine was moved, what was done to update the default route?
    – Andy Dalton
    Sep 19 at 17:38











  • Yes - sorry you are right it's not directly from the config file. Nothing has been done at this point to update the default route. This is what I'm trying to solve so that the user doesn't have to do anything. I thought I had it all worked out and then realised that that the initial values I was working with were the old ones meaning writing them back to the config would be pointless. It sounds like from what you've said that it is going to be a matter of adding a new gateway and testing to see if there is actual connectivity?
    – Josh
    Sep 19 at 17:49














up vote
0
down vote

favorite












I need to get the router IP which I thought I could do via the ip route command (or many other variations). These all return a value for the default gateway which was fine until I discovered that what these commands return is actually the routers line in /etc/dhcpcd.conf.



This wouldn't normally be an issue except the use case I'm trying to solve is when the default gateway has changed from what is configured (e.g. user moves house or gets a new ISP or even just a new router that is configured with a different IP address than the previous one). Obviously if the configuration is wrong in dhcpcd.conf then there isn't a valid route to the internet.



Is there any command to get/find the actual IP address of the router or do I have to add a new gateway, ping something, if working great but if not then try another gateway?










share|improve this question























  • Hi and welcome. The ip route command gets the route information from the kernel, not from any configuration file. It may be true that the kernel information was previously supplied from configuration, but ip route doesn't know about that. In the end, the default route is what the kernel thinks that it is. In your case, when the machine was moved, what was done to update the default route?
    – Andy Dalton
    Sep 19 at 17:38











  • Yes - sorry you are right it's not directly from the config file. Nothing has been done at this point to update the default route. This is what I'm trying to solve so that the user doesn't have to do anything. I thought I had it all worked out and then realised that that the initial values I was working with were the old ones meaning writing them back to the config would be pointless. It sounds like from what you've said that it is going to be a matter of adding a new gateway and testing to see if there is actual connectivity?
    – Josh
    Sep 19 at 17:49












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I need to get the router IP which I thought I could do via the ip route command (or many other variations). These all return a value for the default gateway which was fine until I discovered that what these commands return is actually the routers line in /etc/dhcpcd.conf.



This wouldn't normally be an issue except the use case I'm trying to solve is when the default gateway has changed from what is configured (e.g. user moves house or gets a new ISP or even just a new router that is configured with a different IP address than the previous one). Obviously if the configuration is wrong in dhcpcd.conf then there isn't a valid route to the internet.



Is there any command to get/find the actual IP address of the router or do I have to add a new gateway, ping something, if working great but if not then try another gateway?










share|improve this question















I need to get the router IP which I thought I could do via the ip route command (or many other variations). These all return a value for the default gateway which was fine until I discovered that what these commands return is actually the routers line in /etc/dhcpcd.conf.



This wouldn't normally be an issue except the use case I'm trying to solve is when the default gateway has changed from what is configured (e.g. user moves house or gets a new ISP or even just a new router that is configured with a different IP address than the previous one). Obviously if the configuration is wrong in dhcpcd.conf then there isn't a valid route to the internet.



Is there any command to get/find the actual IP address of the router or do I have to add a new gateway, ping something, if working great but if not then try another gateway?







linux networking






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Sep 19 at 17:39









Andy Dalton

4,8691520




4,8691520










asked Sep 19 at 17:33









Josh

51




51











  • Hi and welcome. The ip route command gets the route information from the kernel, not from any configuration file. It may be true that the kernel information was previously supplied from configuration, but ip route doesn't know about that. In the end, the default route is what the kernel thinks that it is. In your case, when the machine was moved, what was done to update the default route?
    – Andy Dalton
    Sep 19 at 17:38











  • Yes - sorry you are right it's not directly from the config file. Nothing has been done at this point to update the default route. This is what I'm trying to solve so that the user doesn't have to do anything. I thought I had it all worked out and then realised that that the initial values I was working with were the old ones meaning writing them back to the config would be pointless. It sounds like from what you've said that it is going to be a matter of adding a new gateway and testing to see if there is actual connectivity?
    – Josh
    Sep 19 at 17:49
















  • Hi and welcome. The ip route command gets the route information from the kernel, not from any configuration file. It may be true that the kernel information was previously supplied from configuration, but ip route doesn't know about that. In the end, the default route is what the kernel thinks that it is. In your case, when the machine was moved, what was done to update the default route?
    – Andy Dalton
    Sep 19 at 17:38











  • Yes - sorry you are right it's not directly from the config file. Nothing has been done at this point to update the default route. This is what I'm trying to solve so that the user doesn't have to do anything. I thought I had it all worked out and then realised that that the initial values I was working with were the old ones meaning writing them back to the config would be pointless. It sounds like from what you've said that it is going to be a matter of adding a new gateway and testing to see if there is actual connectivity?
    – Josh
    Sep 19 at 17:49















Hi and welcome. The ip route command gets the route information from the kernel, not from any configuration file. It may be true that the kernel information was previously supplied from configuration, but ip route doesn't know about that. In the end, the default route is what the kernel thinks that it is. In your case, when the machine was moved, what was done to update the default route?
– Andy Dalton
Sep 19 at 17:38





Hi and welcome. The ip route command gets the route information from the kernel, not from any configuration file. It may be true that the kernel information was previously supplied from configuration, but ip route doesn't know about that. In the end, the default route is what the kernel thinks that it is. In your case, when the machine was moved, what was done to update the default route?
– Andy Dalton
Sep 19 at 17:38













Yes - sorry you are right it's not directly from the config file. Nothing has been done at this point to update the default route. This is what I'm trying to solve so that the user doesn't have to do anything. I thought I had it all worked out and then realised that that the initial values I was working with were the old ones meaning writing them back to the config would be pointless. It sounds like from what you've said that it is going to be a matter of adding a new gateway and testing to see if there is actual connectivity?
– Josh
Sep 19 at 17:49




Yes - sorry you are right it's not directly from the config file. Nothing has been done at this point to update the default route. This is what I'm trying to solve so that the user doesn't have to do anything. I thought I had it all worked out and then realised that that the initial values I was working with were the old ones meaning writing them back to the config would be pointless. It sounds like from what you've said that it is going to be a matter of adding a new gateway and testing to see if there is actual connectivity?
– Josh
Sep 19 at 17:49















active

oldest

votes











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',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f470076%2ffind-actual-default-gateway-from-command-line%23new-answer', 'question_page');

);

Post as a guest



































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%2funix.stackexchange.com%2fquestions%2f470076%2ffind-actual-default-gateway-from-command-line%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay