Linux two simple alternatives to "peanut shell" software

  

home machine, dial-up Internet, have a separate ip, open a lot of services, want to access anytime outside how to do? When you go out, remember to connect the ip? In case the line is broken, the ip will change after the automatic reconnection, then the solution may be to use the "peanut shell" software. The peanut shell also has a Linux version, which is really an option, but it is equivalent to publishing your ip to the Internet, assuming that you are not very comfortable with your own security (and you don't know if the peanut shell has collected your information). And your purpose is only a small scope (such as you, your family or a few good friends), then this dynamic ip can be spread by personal mail, I simply explored two solutions, one It is based on knemo+kmail, and the second is based on udev+mail+exim4. Here is a brief introduction:

1. knemo + kmail

knemo is the software for monitoring network under kde, supporting event triggering. Kmail is the mail client under kde. It supports dcop script calls. The configuration steps are as follows:

Create a script that automatically obtains the dial-up connection ip and sends it via kmail:
#!/bin/bash < BR>
FROM="none"

TO="[email protected]"

CC="[email protected]"

BCC=""

SUBJECT="Today's PPP address"

sleep 10s

MESSAGE=`/s Bin/ifconfig |  /bin/sed -e '/PtP/!d' -e 's/^[[:space:]]* inet addr://g' -e 's/[[:space:]]*PtP:. *Mask:.*$//g'`

ATTACHMENT="[] []"

dcop kmail MailTransportServiceIface "sendMessage(QString, QString, QString, QString, QString, QString, KURL ::List)" "$FROM" "$TO" "$CC" "$BCC" "$SUBJECT" "$MESSAGE" $ATTACHMENT

Then execute it as the corresponding notification in the knemo configuration The program is fine. The knemo configuration is on the kcontrol -> internet&network -> network monitor -> Misc panel.

2. udev + mail + exim4

The first method is very simple, but you need to use kde and always open your desktop (because you need knemo and kmail than you need) The second way is to get the hardware changes of the kernel. In case of a reconnection, the /sys/device file changes when it is changed, and does not depend on X and the desktop system.

The configuration of exim4 is not mentioned here, look online.

The corresponding script ( /XXXXX/ppp-address.sh ) is modified as follows:
#!/bin/bash

FROM="none"

TO="[email protected]"

CC="[email protected]"

BCC=""

SUBJECT="Today's PPP address"

sleep 10s

MESSAGE=`/sbin/ifconfig |  /bin/sed -e '/PtP/!d' -e 's/^[[:space:]]* inet addr://g' -e 's/[[:space:]]*PtP:. *Mask:.*$//g'`

echo "$MESSAGE" |  /usr/bin/mail -s "$SUBJECT" -c "$CC" -b "$BCC" "$TO"

udev Rule Add: /etc/udev/rules.d/Add one below The rules file such as z100_ppp_ip_letter.rules reads:
ACTION=="add", SUBSYSTEM=="net", KERNEL=="ppp[0-9]", RUN+="/XXXXX/ppp-address.sh"


Copyright © Windows knowledge All Rights Reserved