четверг, 10 мая 2012 г.

How to disconnect all pppoe connections to your server?

ps ax | grep pppd | egrep -v "(pptp|E|grep)" | while read PID tmp; do
  kill -HUP $PID
done

1. Grep all pppd processes
2. Filters out our grep process pid, all pptp (VPN) connections. 'E' means external interface in my current project, you can dismiss it.
3. Read in PID variable pid of remaining processes and kill -HUP them one by one.

Q: Why kill them?
A: If you restart networking, ppp interfaces (for pppoe) on server are removed, but on clients they still up, but gives no access to the internets. HUP disconnect them correctly.