domingo, 22 de mayo de 2011

How to perform automatic actions after a connection is established with wvdial/ppp


I'm on kubuntu Natty and I'm pretty glad with the distro overall. However, there are a couple  of bugs that bug me more often than I'd like them to. One of them is that, for whatever reason, when I establish an internet connection with wvdial/ppp, squid doesn't go through it. I have to restart he service once the connection is set up so that traffic starts pouring from squid. What I realized was that it is possible to do this action automatically.

There is one directory where you can put scripts to be run when a new connection is established and when a connection is dropped. I wanted to do something when the connection was established, so had to upt the script in /etc/ppp/ip-up.d:

$ cat /etc/ppp/ip-up.d/9999squid

/etc/init.d/squid3 restart

Pretty straightforward, right? Make sure the script has the executable flag set up and you are done.

Additionally, the script get the following information as parameters (in the order they are received):
Network Interface
Local IP address
Peer IP address
Additiona Parameter (as received by pppd).

There are some environment variables that I think are available for the script, but I haven't tested them: PPP_IFACE, PPP_TTY, PPP_SPEED, PPP_LOCAL, PPP_REMOTE y PPP_IPPARAM.

Note: Given that the hack is implemented on ppp, this should probably work with network connections set up on NetworkManager that use ppp (like broadband).

No hay comentarios:

Publicar un comentario en la entrada