Jump to content

Linux Default gateway


artlk
 Share

Recommended Posts

Hi

 

i have 2 nic connected to centos server etho to lan and eth1 to bsnl isp

and set default gateway ip 10.10.1.169 in /etc/sysconfig/network file when i make /sbin/ifdown ppp0 then the server take default gateway 10.10.1.169 but when

i remove telepone line from modem then default gateway ip 10.10.1.169 is not set , pls suggest what is wrong and what i have to do

Link to comment
Share on other sites

Just taking the phone line out, your system still thinks that the ppp0 connection is active, and so you have two default routes. Which is probably why it works when you do ifdown ppp0. You said eth1 is your isp, so why are you using ppp0 unless of course that is also connected with eth1 for user authentication to bring the link up (PPPoE)?

 

I expect we need more information on your computer setup before we can help you further. But I expect it is related to the scenario I listed above that you have two default routes and everything is attempting to go via the one created by the ppp0 link until you drop the link.

 

In fact you don't need two default routes as such. You don't need this for your internal network if you are not accessing the internet from it. Perhaps explain more on what you are trying to achieve.

Link to comment
Share on other sites

Thanks for reply

 

i try to achieve that if my internet from centos server is down then i have to take internet from another window pc on which net is connected .

as i told i have centos on which 2 nic card one etho connected to eth0 and bsnl isp line connected to eth1 via adsl modem.

set default gateway ip 10.10.1.169 (this is ip of window pc on which net is connected) in /etc/sysconfig/network file when i make /sbin/ifdown ppp0(ppp0 is bsnl link when bsnl link is working) then the server take default gateway 10.10.1.169 and net start in centos server but when

i remove telepone line from modem then default gateway ip 10.10.1.169 is not set ,if i manually set default gateway to 10.10.1.169 it set checked by route -n but after 3-4 min it is remove automatically pls suggest what is wrong and what i have to do

Link to comment
Share on other sites

As I said, just removing the telephone line, CentOS still thinks the ppp0 connection is active, and it's not responding, and so this is your problem. Ideally ppp0 should disconnect when there is no longer an internet connection. I don't have such a setup to be able to tell you what to do. You need some kind of timeout for ppp0 when it's not in use, or when no traffic is able to go across the link. This would then initiate an ifdown and you would have the default route via your Windows machine.

 

Maybe this google search for an idle timeout will help give you the info you need:

 

https://www.google.co.uk/?gws_rd=ssl#q=linux+ppp0+idle+timeout

Link to comment
Share on other sites

As I said, just removing the telephone line, CentOS still thinks the ppp0 connection is active, and it's not responding, and so this is your problem. Ideally ppp0 should disconnect when there is no longer an internet connection. I don't have such a setup to be able to tell you what to do. You need some kind of timeout for ppp0 when it's not in use, or when no traffic is able to go across the link. This would then initiate an ifdown and you would have the default route via your Windows machine.

 

Maybe this google search for an idle timeout will help give you the info you need:

 

https://www.google.co.uk/?gws_rd=ssl#q=linux+ppp0+idle+timeout

Link to comment
Share on other sites

Hi

 

you are right but when i make /sbin/ifdown ppp0(here link is connected to adsl modem) then the server take default gateway 10.10.1.169 and net start in centos server but what do you think if i dont remove telephone line from modem and if real condition occur i.e net is down from bsnl then in that case default gateway 10.10.1.169 is set automatically or not

Link to comment
Share on other sites

I expect it won't do it automatically, because it seems you do not have a ppp0 idle timeout. Your simulation with pulling the telephone cable shows that this is the case. So you need to set some kind of idle timeout for ppp0, and then perhaps that will fix your problem.

Link to comment
Share on other sites

I expect it won't do it automatically, because it seems you do not have a ppp0 idle timeout. Your simulation with pulling the telephone cable shows that this is the case. So you need to set some kind of idle timeout for ppp0, and then perhaps that will fix your problem.

Link to comment
Share on other sites

If you don't have an idle timeout, then your ppp0 connection will stay active. Which is what you have now. If you have an idle timeout set for 3 minutes, then if nothing happens for 3 minutes, the connection will then drop and your system will work how you want it.

 

So you need to do this.

Link to comment
Share on other sites

If you don't have an idle timeout, then your ppp0 connection will stay active. Which is what you have now. If you have an idle timeout set for 3 minutes, then if nothing happens for 3 minutes, the connection will then drop and your system will work how you want it.

 

So you need to do this.

Link to comment
Share on other sites

you mean to say that if ppp0 is time out after 3 min then i have to run my script right but one thing i like to share when i disconnect phone line from modem then if i checked link status by /sbin/adsl-status it shows ppp0 is connected and after 2 min if i checked status then it shows error as "link is attached to ppp0 but ppp0 is down " in that case if i set gateway as 10.10.1.169 then it set but it automatically removed again

Link to comment
Share on other sites

idle n

 

If this option is configured, pppd will disconnect the link whenever this timer expires. Idle times are specified in seconds. Each new active data packet will reset the timer.

 

From here:

 

http://www.tldp.org/LDP/nag2/x7297.html

 

obviously n you set a number for in seconds to specify an idle timeout. As I said earlier, I don't have a set up like yours, so it helps if you use google and search for the info I provided you with.

Link to comment
Share on other sites

you mean to say that if ppp0 is time out after 3 min then i have to run my script right but one thing i like to share when i disconnect phone line from modem then if i checked link status by /sbin/adsl-status it shows ppp0 is connected and after 2 min if i checked status then it shows error as "link is attached to ppp0 but ppp0 is down " in that case if i set gateway as 10.10.1.169 then it set but it automatically removed again

 

No, you set the config option in my previous post to set the idle time, then ppp0 will be dropped, and your route should be active. I don't know what else you are doing or what your script is for.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...