View previous topic :: View next topic |
Author |
Message |
knedle n00b
Joined: 21 Nov 2008 Posts: 12
|
Posted: Wed Jun 27, 2012 4:55 pm Post subject: Strange problem with ping, eth2 and ppp0 |
|
|
Since one of my servers needs to be connected to internet 24/7, even if the ADSL internet is offline, I have bought a GSM usb modem and connected it to my gentoo box, after some playing with wvdial I have managed to connect to internet and almost everything works fine.
I have got two interfaces - eth2 which is connected to ADSL and ppp0 connected to mobile internet.
I have written a small bash script that pings something (in my case 8.8.8.8, which seems to be always up and running) using eth2 interface, if it fails then my script starts wvdial and connects to the internet using ppp0, in other case it does nothing, except disconnecting ppp0.
The problem is that when I'm connected to the internet by ppp0, I can't ping anything except local network using eth2. I would be grateful for any suggestions.
My ifconfig:
Code: | eth2 Link encap:Ethernet HWaddr 1c:6f:65:a1:e4:51
inet addr:10.9.1.10 Bcast:10.9.1.255 Mask:255.255.255.0
ppp0 Link encap:Point-to-Point Protocol
inet addr:37.108.137.108 P-t-P:10.64.64.64 Mask:255.255.255.255
|
When ppp0 is down:
As an user and root works the same
Code: | ping -Ieth2 8.8.8.8
PING 8.8.8.8 (8.8.8.8) from 10.9.1.10 eth2: 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_req=1 ttl=49 time=29.0 ms |
When ppp0 is up:
As an user: (notice, that it's showing wrong address in from)
Code: | ping -Ieth2 8.8.8.8
PING 8.8.8.8 (8.8.8.8) from 37.108.137.108 eth2: 56(84) bytes of data.
(nothing shows) |
As a root: (address seems to be ok, but it still doesn't work)
Code: | sudo ping -Ieth2 8.8.8.8
PING 8.8.8.8 (8.8.8.8) from 10.9.1.10 eth2: 56(84) bytes of data.
(nothing shows) |
And ping using ppp0 (as an user and root works the same)
Code: | ping 8.8.8.8 -Ippp0
PING 8.8.8.8 (8.8.8.8) from 37.108.137.108 ppp0: 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_req=1 ttl=45 time=106 ms |
_________________ Main Computer | Intel Core 2 Quad | Foxconn G45 | 2x 4 + 2 GB RAM | WD 500 GB | 2x Seagate Expansion 1 TB | Gentoo inside |
|
Back to top |
|
|
ce110ut Apprentice
Joined: 27 Sep 2002 Posts: 200
|
Posted: Wed Jun 27, 2012 5:51 pm Post subject: |
|
|
Sounds like you need to add to your script. You need to change the default route once eth2 goes down. Someething like:
Code: |
# your script . . .
# remove your default route
route del default
# set default route for ppp0
route add default gateway 10.64.64.64 ppp0
|
You may also need to reverse the logic when eth2 comes back up, where you delete the default route and add eth2 as the default route. Try it by hand first and let us know if that works. |
|
Back to top |
|
|
knedle n00b
Joined: 21 Nov 2008 Posts: 12
|
Posted: Wed Jun 27, 2012 6:24 pm Post subject: |
|
|
Actually I had problem with being unable to ping anything using eth2, while ppp0 is up. I'm doing it, since I want to check if main internet connection is back and I can disconnect from ppp0, however your post helped me to get rid of that problem, I simply executed:
Code: | route add 8.8.8.8 gateway 10.9.1.1 eth2 |
Now I can ping 8.8.8.8 even if ppp0 is up.
Until today I had no knowledge about route command.
Thank you. _________________ Main Computer | Intel Core 2 Quad | Foxconn G45 | 2x 4 + 2 GB RAM | WD 500 GB | 2x Seagate Expansion 1 TB | Gentoo inside |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|