עבור לתוכן
View in the app

A better way to browse. Learn more.

HWzone

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

איך להתקין חייגן כבלים ב UBUNTU

Featured Replies

פורסם

אני חדש לגמרי בעניני לינוקס ולא יודע איך להתקין חייגן כבלים ב UBUNTU. אם הדבר כרוך בהתקנת תוכנה - אנא הפנו אותח=י למקום בו ניתן ללמוד להתקין תוכנות בלינוקס.

פורסם

לא צריך להתקין כלום (בד"כ)

אני משתמש בסקריפט הבא, ישנם הרבה סקריפטים - זה רק אחד מהם.

#!/usr/bin/env python

import popen2;

import re;

import sys;

import time;

import os;

#**********************************************************************************************

# class: ConnDB: stores various information about providers, nameservers, servers and

# their names.

#

#**********************************************************************************************

class ConnDB:

def __init__(self):

#con tuple: nameserver1, nameserver2, remotename, name

self._cons = [];

#0 012.net - aztv

self._cons.append(("212.117.129.3","212.117.128.6","aztv.012.net.il","012.net -aztv"));

#1 012.net

self._cons.append(("212.117.129.3","212.117.128.6","cablepns.012.net.il","012.net"));

#2 actcom

self._cons.append(("192.114.47.4","192.114.47.52","192.117.122.13","actcom"));

#3 aquanet

self._cons.append(("192.117.240.10","192.117.240.3","cable.aquanet.co.il","aquanet"));

#4 barak

self._cons.append(("212.150.48.169","206.49.94.234","pns.barak.net.il","barak"))

#5 bezeqint

self._cons.append(("192.115.106.35","62.219.186.7","matav.bezeqint.net","bezeqint"))

#6 huji

self._cons.append(("128.139.6.1","128.139.4.3","vpn.huji.ac.il","huji"))

#7 israserv

self._cons.append(("192.115.0.100","192.115.3.100","192.117.195.250","israserv"))

#8 netvision

self._cons.append(("194.90.1.5","212.143.212.143","cable.netvision.net.il","netvision"))

#9 technion

self._cons.append(("132.68.1.2","132.68.1.9","ccdis3.technion.ac.il","technion"))

#10 zahav

self._cons.append(("192.116.202.222","192.116.192.9","pns.inter.net.il","zahav"))

#number of connections

self._numofcons = self._cons.__len__();

def getNumOfConnections(self):

return self._numofcons;

def getProviders(self):

return self._cons;

#**********************************************************************************************

# class: Connection: starts the pptp connection

#

#

#**********************************************************************************************

class Connection:

def __init__(self):

self.nameserver1 = ""

self.nameserver2 = ""

self.password = ""

self.username = ""

self.server = ""

self.pptp = "";

self.eth = ""

self.gateway = "";

self.newGateway = "";

self.dhcpClient = "";

self.dhcpClientPath = "";

self.msglen = 48;

def initiate(self, ns1, ns2, server, password, username, ethernet, dhcpClient, dhcpClientPath, pptpclient):

self.nameserver1 = ns1;

self.nameserver2 = ns2;

self.password = password;

self.username = username;

self.server = server;

self.pptp = pptpclient;

self.eth = ethernet;

self.gateway = "";

self.newGateway = "";

self.dhcpClient = dhcpClient;

self.dhcpClientPath = dhcpClientPath;

def connect(self):

self.clean();

self.writeResolve();

self.writeSecrets();

self.getGateway();

self.addRoute();

self.startPPTP();

self.getNewGateway();

self.deleteOldSetNewRoute();

self.writeResolve();

# self.shareInternet();

def writeResolve(self):

self.msg("Writing resolv.conf");

resolveFile = open('/etc/resolv.conf','w');

resolveFile.write("nameserver " + self.nameserver1 + '\n');

resolveFile.write("nameserver " + self.nameserver2 + '\n');

resolveFile.close();

def writeSecrets(self):

self.msg("Writing pap-secrets");

papSecretsFile = open('/etc/ppp/pap-secrets','w');

papSecretsFile.write('"' + self.username + '" * "'+self.password + '"\n');

papSecretsFile.close();

chapSecretsFile = open('/etc/ppp/chap-secrets','w');

chapSecretsFile.write('"' + self.username + '" * "' + self.password + '"\n');

chapSecretsFile.close();

def clean(self):

self.execute("rm -rf /var/run/pp*");

self.msg("Cleaning ... ");

self.execute("killall -9 pptp");

self.execute("killall -9 pptp-linux");

self.execute("killall -9 dhclient");

self.execute("killall -9 dhcpcd");

self.execute("killall -9 pump");

self.execute("modprobe usbnet");

self.execute("modprobe CDCEther");

self.execute("ifconfig " + self.eth + " down");

self.execute("rm -rf /etc/dhcpc/dhcpcd-" + self.eth + ".pid");

def getGatewayFromDhcpcd(self):

self.execute("dhcpcd " + self.eth, 3); #was 2

dhcpcdInfoFile = open("/etc/dhcpc/dhcpcd-" + self.eth + ".info","r");

gateMatch = 0;

while not gateMatch:

line = dhcpcdInfoFile.readline();

gateMatch = re.match("GATEWAY=.*",line);

if not line:

self.errorMsg("parsing error");

if gateMatch:

str = gateMatch.group(0);

self.gateway = re.split("=",str)[1];

dhcpcdInfoFile.close();

def getGatewayFromDhclient(self):

self.msg("executing " + self.dhcpClientPath + " " + self.eth);

self.execute(self.dhcpClientPath+" "+self.eth,3); #was 2

if os.access("/var/lib/dhcp/dhclient.leases",os.R_OK):

(stout, stin) = popen2.popen2('grep routers /var/lib/dhcp/dhclient.leases | tail -n 1 | cut -d ";" -f1 | cut -d " " -f5');

elif os.access("/var/lib/dhcp3/dhclient.leases",os.R_OK):

(stout, stin) = popen2.popen2('grep routers /var/lib/dhcp3/dhclient.leases | tail -n 1 | cut -d ";" -f1 | cut -d " " -f5');

self.gateway = stout.read()[:-1];

def getGateway(self):

self.msg("Getting gateway:");

if (self.dhcpClient == "dhcpcd"):

self.getGatewayFromDhcpcd();

elif (self.dhcpClient == "dhclient"):

self.getGatewayFromDhclient();

self.msg("Found Gateway: " + self.gateway);

def addRoute(self):

self.msg("Adding Route:");

self.execute("/sbin/route add -host " + self.server + " gw " + self.gateway + " dev " + self.eth, 3); #was 2

def startPPTP(self):

self.msg("Starting pptp");

popen2.Popen3(self.pptp+" "+ self.server + " user "+self.username+" debug remotename "+self.server+" mtu 1452 mru 1452 noauth defaultroute").wait();

i = 0;

while True:

(stout, stin) = popen2.popen2("netstat -n -r | grep ppp0");

if (stout.readline()):

self.msg("Connected!");

break;

i = i+1;

print "--- connecting.... ---";

time.sleep(1);

if (i == 20):

self.errorMsg("Failed to Connect");

def getNewGateway(self):

(stout, stin) = popen2.popen2('/sbin/ifconfig ppp0 | grep inet | cut -d":" -f3 | tail -1 | cut -d" " -f1');

self.newGateway = stout.read()[:-1]; #remove the trailing \n

self.msg("New Gateway: " + self.newGateway);

def deleteOldSetNewRoute(self):

self.msg("Fixing Gateway");

self.execute("/sbin/route del default dev " + self.eth);

self.execute("/sbin/route add default gw " + self.newGateway);

def shareInternet(self):

self.msg("Sharing Internet");

self.execute('iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE');

self.execute('echo "1" > /proc/sys/net/ipv4/ip_forward');

self.execute('ifconfig eth1 192.168.0.1 netmask 255.255.255.0 broadcast 192.168.0.1');

def errorMsg(self,m):

print "Error: ",m," \n";

sys.exit(0);

def execute(self, cmd, flag = 3):

popen2.Popen3(cmd,True).wait();

def msg(self,m):

print "++++++++ ",m," "*(self.msglen-m.__len__()),"++++++++\n";

#**********************************************************************************************

# class: CableInternet: detects the pptp client, dhcp client and gets the user information

#

# welcome(): print a welcome message to the screen

# saveUserInfo(): save the information about providers and username/password into a

# .cablecon configuration file.

# getUserInfo(): gets the infromation needed for connection from the user

# detectDhcpcd(): checks whether a Dhcpcd client exists in the path. Returns 0 if does.

# detectDhclient(): checks whether a Dhclient exists in the path. Returns 0 if does.

# detectDHCPClient(): Goes over the dhcpc client detectors in some order and stops when

# found one that exists in the path.

#

#**********************************************************************************************

class CableInternet:

def __init__(self):

self.condata = ConnDB();

self.provider = 0;

self.username = "";

self.password = "";

self.ethernet = "eth0";

self.cons = self.condata.getProviders();

self.dhcpClient = "";

self.dhcpClientPath = "";

self.pptp = "";

self.msglen = 48;

def welcome(self):

print "*********************************************************************\n";

print "***** Welcome to the Cable Internet Connection wizard ************\n";

print "*********************************************************************\n";

def saveUserInfo(self):

confFile = open('/etc/cablecon','w');

confFile.write(str(self.provider)+"\n");

confFile.write(self.password+"\n");

confFile.write(self.username+"\n");

confFile.write(self.ethernet+"\n");

confFile.close();

def getUserInfo(self):

i = 0;

N = self.condata.getNumOfConnections();

while i < N:

print i,") ",self.cons[3];

i = i+1;

try:

self.provider = int(raw_input("Enter the number near your provier:\n"));

except:

self.errorMsg("Next time try to be more accurate");

self.username = raw_input("Enter your username: ");

self.password = raw_input("Enter your password: ");

print "0) eth0 \n1) eth1";

try:

self.ethernet = "eth" + raw_input("Enter your ethernet (default = eth0): eth");

except:

self.errorMsg("Next time try to be more accurate");

ans = raw_input("Do you want to save these changes? [y,N]:");

if (ans.lower()[0] == 'y' ):

self.saveUserInfo();

def detectDhcpcd(self):

(stout, stin) = popen2.popen2("which dhcpcd");

self.dhcpClientPath = stout.read()[:-1];

if (self.dhcpClientPath):

self.dhcpClient = "dhcpcd";

self.msg("Detected: dhcpcd");

return 1;

return 0;

def detectDhclient(self):

(stout, stin) = popen2.popen2("which dhclient");

self. dhcpClientPath = stout.read()[:-1];

if (self.dhcpClientPath):

self.dhcpClient = "dhclient";

self.msg("Detected: dhclient");

return 1;

return 0;

def detectDHCPClient(self):

self.msg("Detecting DHCP client");

if not(self.detectDhcpcd() or self.detectDhclient()):

self.errorMsg("Couldn't detect any dhcp client");

def detectPPTP(self):

(stout,stin,sterr) = popen2.popen3("which pptp");

self.msg("Find what pptp do you use");

self.pptp = stout.read();

self.pptp = re.split("\n",self.pptp)[0];

if (self.pptp):

self.msg("Found pptp: " + self.pptp);

return 1;

return 0;

def detectPPTPLinux(self):

(stout,stin) = popen2.popen2("which pptp-linux")

self.pptp = stout.read();

self.pptp = re.split("\n",self.pptp)[0];

if (self.pptp):

self.msg("Found pptp: " + self.pptp);

return 1;

return 0;

def detectPPTPClient(self):

if not(self.detectPPTP() or self.detectPPTPLinux()):

self.errorMsg("error, couldn't find pptp client");

def getFileInfo(self):

confFile = open('/etc/cablecon','r');

self.provider = int(confFile.readline()[:-1]);

self.password = confFile.readline()[:-1];

self.username = confFile.readline()[:-1];

self.ethernet = confFile.readline()[:-1];

confFile.close();

def connect(self):

self.welcome();

self.detectDHCPClient();

self.detectPPTPClient();

if os.access("/etc/cablecon",os.R_OK):

self.getFileInfo();

else:

self.getUserInfo();

con = Connection();

con.initiate(self.cons[self.provider][0],self.cons[self.provider][1],self.cons[self.provider][2],\

self.password, self.username, self.ethernet, self.dhcpClient, self.dhcpClientPath,\

self.pptp);

con.connect();

def errorMsg(self,m):

print "Error: ",m," \n";

sys.exit(0);

def msg(self,m):

print "++++++++ ",m," "*(self.msglen-m.__len__()), "++++++++\n";

c = CableInternet();

c.connect();

המלצה, לא לשמור שינויים עד שהצלחת להתחבר כמו שצריך.

פקודות הרצה -

sudo python filename.py

מטי.

פורסם
  • מחבר

ה SCRIPT הזה מתאים גם ל L2TP ?.

פורסם

לא , pptp בלבד.

אם היית מציין מראש שזה מה שאתה צריך....

מטי.

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

דיונים חדשים

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.