Пример #1
0
    def configure_l2tpIpsec(self, left, obj):
        l2tpconffile = "%s/l2tp.conf" % (self.VPNCONFDIR)
        vpnsecretfilte = "%s/ipsec.any.secrets" % (self.VPNCONFDIR)
        xl2tpdconffile = "/etc/xl2tpd/xl2tpd.conf"
        xl2tpoptionsfile = "/etc/ppp/options.xl2tpd"

        localip = obj['local_ip']
        localcidr = obj['local_cidr']
        publicIface = obj['public_interface']
        iprange = obj['ip_range']
        psk = obj['preshared_key']

        # Left
        l2tpfile = CsFile(l2tpconffile)
        l2tpfile.addeq(" left=%s" % left)
        l2tpfile.commit()

        secret = CsFile(vpnsecretfilte)
        secret.empty()
        secret.addeq("%s %%any : PSK \"%s\"" % (left, psk))
        secret.commit()

        xl2tpdconf = CsFile(xl2tpdconffile)
        xl2tpdconf.addeq("ip range = %s" % iprange)
        xl2tpdconf.addeq("local ip = %s" % localip)
        xl2tpdconf.commit()

        xl2tpoptions = CsFile(xl2tpoptionsfile)
        xl2tpoptions.search("ms-dns ", "ms-dns %s" % localip)
        xl2tpoptions.commit()
Пример #2
0
    def configure_l2tpIpsec(self, left, obj):
        l2tpconffile = "%s/l2tp.conf" % (self.VPNCONFDIR)
        vpnsecretfilte = "%s/ipsec.any.secrets" % (self.VPNCONFDIR)
        xl2tpdconffile = "/etc/xl2tpd/xl2tpd.conf"
        xl2tpoptionsfile = "/etc/ppp/options.xl2tpd"

        localip = obj['local_ip']
        localcidr = obj['local_cidr']
        publicIface = obj['public_interface']
        iprange = obj['ip_range']
        psk = obj['preshared_key']

        # Left
        l2tpfile = CsFile(l2tpconffile)
        l2tpfile.addeq(" left=%s" % left)
        l2tpfile.commit()

        secret = CsFile(vpnsecretfilte)
        secret.empty()
        secret.addeq("%s %%any : PSK \"%s\"" % (left, psk))
        secret.commit()

        xl2tpdconf = CsFile(xl2tpdconffile)
        xl2tpdconf.addeq("ip range = %s" % iprange)
        xl2tpdconf.addeq("local ip = %s" % localip)
        xl2tpdconf.commit()

        xl2tpoptions = CsFile(xl2tpoptionsfile)
        xl2tpoptions.search("ms-dns ", "ms-dns %s" % localip)
        xl2tpoptions.commit()
    def configure_l2tpIpsec(self, left,  obj):
        vpnconffile="%s/l2tp.conf" % (self.VPNCONFDIR)
        vpnsecretfilte="%s/ipsec.any.secrets" % (self.VPNCONFDIR)
        xl2tpdconffile="/etc/xl2tpd/xl2tpd.conf"
        xl2tpoptionsfile='/etc/ppp/options.xl2tpd'

        file = CsFile(vpnconffile)
        localip=obj['local_ip']
        localcidr=obj['local_cidr']
        publicIface=obj['public_interface']
        iprange=obj['ip_range']
        psk=obj['preshared_key']

        #left
        file.addeq(" left=%s" % left)
        file.commit()


        secret = CsFile(vpnsecretfilte)
        # xrstack - Clean up first to avoid useless PSK that used before
        secret.empty()
        secret.addeq(": PSK \"%s\"" %psk)
        secret.commit()

        xl2tpdconf = CsFile(xl2tpdconffile)
        xl2tpdconf.addeq("ip range = %s" %iprange)
        xl2tpdconf.addeq("local ip = %s" %localip)
        xl2tpdconf.commit()

        xl2tpoptions=CsFile(xl2tpoptionsfile)
        xl2tpoptions.search("ms-dns ", "ms-dns %s" %localip)
        xl2tpoptions.commit()