Linux two methods to replace the "peanut shell" Software

Source: Internet
Author: User

There are machines in the house, dial-up Internet access, independent ip addresses, and many services. What should I do if I want to access them at any time? Remember the connected ip address when you exit? If the line is broken, the ip address will change after the automatic reconnection, so the solution may be to use the "peanut shell" software. Peanut shells also have the Linux version, which is indeed a choice, but it is equivalent to putting your ip publish online, assume that you are not at ease with your own security, and you do not know whether the peanut shells have collected your information), and your purpose is to use it in a small scale, for example, just you, your family or a few friends), then this dynamic IP address can be completely spread via personal email. I have simply explored two solutions: one is based on knemo + kmail, the second is based on udev + mail + exim4. The following is a brief introduction:

1. knemo + kmail

Knemo is the software that monitors the network under kde. It supports event triggering and kmail is the mail client under kde. It supports dcop script calling. The configuration steps are as follows:

Create a script to automatically obtain the ip address of the dial-up connection and send it through kmail:

#! /Bin/bash

FROM = "none"

TO = "youname@xxxx.com"

CC = "yourfiend@yyyyy.com"

BCC = ""

SUBJECT = "Today's PPP address"

Sleep 10 s

MESSAGE = '/sbin/ifconfig |/bin/sed-E'/P-t-P /! D'-e's/^ [[: space:] * inet addr: // G'-e's/[[: space:] * P-t-P :. * Mask :. * $ // g''

ATTACHMENT = "[] []"

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

Then, use it as the corresponding program in the notification configured for knemo.
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 drive your desktop because knemo and kmail are needed). The second method is to obtain kernel hardware changes, in case of a disconnection, the change in the/sys/device file will trigger, independent of X and the desktop system.

The configuration of exim4 is not mentioned here. You can view it on the Internet :-)
The corresponding sent script (/XXXXX/ppp-address.sh) is modified as follows:

#! /Bin/bash

FROM = "none"

TO = "youname@xxxxx.com"

CC = "yourfriend@yyyyy.com"

BCC = ""

SUBJECT = "Today's PPP address"

Sleep 10 s

MESSAGE = '/sbin/ifconfig |/bin/sed-E'/P-t-P /! D'-e's/^ [[: space:] * inet addr: // G'-e's/[[: space:] * P-t-P :. * Mask :. * $ // g''

Echo "$ MESSAGE" |/usr/bin/mail-s "$ SUBJECT"-c "$ CC"-B "$ BCC" "$"

Add a udev rule:/etc/udev/rules. d/. Add a rule file, for example, z100_ppp_ip_letter.rules:

ACTION = "add", SUBSYSTEM = "net", KERNEL = "ppp [0-9]", RUN + = "/XXXXX/ppp-address.sh"


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.