# Strange problem with ping, eth2 and ppp0

## knedle

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:

```
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

```
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)

```
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)

```
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)

```
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
```

----------

## ce110ut

Sounds like you need to add to your script.  You need to change the default route once eth2 goes down.  Someething like:

```

# 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.

----------

## knedle

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:

```
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.  :Smile: 

----------

