• Iptables nat для strongswan accel-l2tp - как подружить?

    @Free0wl Автор вопроса
    даже если на "шлюзе" сделать так:
    iptables -t nat -D PREROUTING -i ifE -s 10.0.0.85 -j DNAT --to 192.168.9.2

    10.0.0.85 - это vm1 (гипотетический клиент)
    192.168.9.2 - vm3 (VPN сервер)
    PPTP работает
    Strongswan + L2TP - нет
    Ответ написан
    Комментировать
  • Как из file.txt убрать строки в которых есть слова из последнего поля exlude-list.txt и ...?

    @Free0wl Автор вопроса
    возможно не очень изящно, но работает:
    исходные данные:
    file.txt:
    1 a good line
    exception 2 a line with an
    3
    4 is another line
    deleting 5 a good line by
    6
    7 all the other lines
    excptn with a space 8 string with
    9 and etc

    exluded.txt:
    file\separated\with\exception
    file\separated with\excptn with a space
    file\separated\with\deleting

    результат:
    PS D:\PS.my\egrep.v> .\clear_of_excess_enOnly.cmd
    -------Exclude list-----
    exception|excptn with a space|deleting
    -------Exclude list-----
    ---------BODY-----------

    1 a good line
    3
    4 is another line
    6
    7 all the other lines
    9 and etc
    ---------BODY-----------
    - непонятно откуда первая пустая строка, но для меня не актуально. скорее всего из-за кодировки
    решение:
    (небольшое уточнение - слова исключения всегда на первом месте, потому поиск ведётся с использованием "^" )
    $body = Get-Content $IncListFile
    $IncListArr = @()
    foreach ($line in $body){
    $IncListArr += $line | %{$a=$_.Split('\'); $a[$a.length-1]}
    }

    $ListArr = $IncListArr -join '|'
    write-host "-------Exclude list-----"
    $ListArr
    write-host "-------Exclude list-----"
    $body = Get-Content $LogFile -encoding utf8 | Select-String -pattern ^"$ListArr" -notmatch
    write-host "---------BODY-----------"
    $body
    write-host "---------BODY-----------"

    более-менее полный (рабочий) кусок, вдруг кому-то понадобится

    <# :

    @echo off
    :: chcp 65001

    REM адрес отправителя
    SET mail_from=MailUser@maildomen.ru
    REM почтовый логин отправителя
    SET mail_user=MailUser
    REM почтовый пароль отправителя
    SET mail_passw=MaIlPaSsWoRd
    REM почтовый сервер
    SET mail_smtp=smtp.maildomen.ru
    SET mail_smtp_port=587
    REM адрес получателя
    SET mail_to=user@maildomen.ru

    REM Сетевые настройки
    REM имя пользователя
    SET bu_username=bu_UserName

    pushd D:\PS.my\egrep.v

    SET fullpath=%CD%

    goto tops

    :TheEnd
    popd
    exit /b

    :tops
    @powershell -c "Invoke-Expression $([System.IO.File]::ReadAllText('%~f0'))"
    endlocal
    goto TheEnd

    #>

    $IncName="exluded.txt"
    $LogName="file.txt"

    $IncListFile = $env:fullpath + "\" + $IncName
    $LogFile = $env:fullpath + "\" + $LogName
    $DumpFile = $env:fullpath + "\dump.txt"

    if (Test-Path $DumpFile) {
    Remove-Item $DumpFile
    }

    $body = Get-Content $IncListFile
    $IncListArr = @()
    foreach ($line in $body){
    $IncListArr += $line | %{$a=$_.Split('\'); $a[$a.length-1]}
    }

    $ListArr = $IncListArr -join '|'
    write-host "-------Exclude list-----"
    $ListArr
    write-host "-------Exclude list-----"
    $body = Get-Content $LogFile -encoding utf8 | Select-String -pattern ^"$ListArr" -notmatch
    write-host "---------BODY-----------"
    $body
    write-host "---------BODY-----------"

    # отправка почты
    $LogFile = $LogFile
    $LogFileZip = $LogFile + ".zip"
    if (Test-Path $LogFileZip) {
    Remove-Item $LogFileZip
    }
    Compress-Archive -Path "$LogFile" -DestinationPath "$LogFileZip"

    $LogFile = $env:log_path
    $maillog = $env:cmd_path_dos + "sendEmail.log"
    $maillogerr = $env:cmd_path_dos + "sendEmailError.log"

    Start-Transcript -Path "$maillogerr"

    $pc = get-content env:computername
    $from = "BackUP from " + $pc + "<"+$env:mail_from+">"
    $to = "$env:mail_to"
    $smtpserver = $env:mail_smtp
    $Port = $env:mail_smtp_port
    $Password = "$env:mail_passw" | ConvertTo-SecureString -AsPlainText -Force
    $Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $From, $Password

    if (test-path $LogFile)
    {
    $subject = "Report from PC: " + $pc + " User: " + $env:bu_username
    [System.Net.ServicePointManager]::ServerCertificateValidationCallback = { return $true }
    foreach ($recipient in $to)
    {
    Send-MailMessage -SmtpServer $smtpserver -UseSsl -From $from -To $recipient -Subject $subject -Body ($body | Out-String) -Encoding utf8 -Credential $Credential -Attachments "$LogFileZip"
    }
    }
    else
    {
    $d = Get-Date
    $DateTimeRun = $d.GetDateTimeFormats()[57]
    $body = "$DateTimeRun`n`LOG-file not exist"
    $subject = "Report from PC: $pc. User: $env:bu_username - ERROR"
    foreach ($recipient in $to)
    {
    Send-MailMessage -SmtpServer $smtpserver -UseSsl -From $from -To $recipient -Subject $subject -Body $body -Encoding utf8 -Credential $Credential
    }
    }


    осталось решить проблему кодировки (кириллица в UTF8) - на почту приходят кракозябры - а ларчик-то просто открывался, надо было всего лишь добавить к get-content ... -encoding utf8
    Ответ написан
    Комментировать
  • Как правильно создать сертификаты accel-ppp для SSTP?

    @Free0wl Автор вопроса
    не удалось победить.
    делаю так:
    1. мой CNF
    camy.cnf
    [ ca ]
    default_ca = CA_default

    [ CA_default ]
    serial = ca-serial
    crl = ca-crl.pem
    default_crl_days = 3650
    default_md = md5

    [ req ]
    default_bits = 2048
    days = 3650
    distinguished_name = req_distinguished_name
    attributes = req_attributes
    prompt = no

    [ req_distinguished_name ]
    C = RU
    ST = MO
    L = Moscow
    O = BL
    OU = BLITdep
    CN = ca
    emailAddress = admin@vdebian.homenet.home

    [ req_attributes ]

    1. корневой ключ
    openssl genrsa -out sstp-ca.key
    2. корневой сертификат.
    openssl req -x509 -new -key sstp-ca.key -days 3650 -out sstp-ca.crt -config camy.cnf
    3. ключ для sstp
    openssl genrsa -out sstp-key.pem
    4. запрос на сертификат
    openssl req -new -key sstp-key.pem -out sstp-csr.csr -config camy.cnf
    5. подписать запрос на сертификат корневым сертификатом
    openssl x509 -req -in sstp-csr.csr -CA sstp-ca.crt -CAkey sstp-ca.key -CAcreateserial -out sstp-cert.pem -days 3650
    6. импортирую "sstp-ca.crt" в Windows "Доверенные корневые центры сертификации -> Локальный компьютер -> Сертификаты"

    секция SSTP в конфиге
    [sstp]
    verbose=1
    bind=0.0.0.0
    accept=ssl
    ssl-ca-file=/etc/accel-ppp/ssl/sstp-ca.crt
    ssl-pemfile=/etc/accel-ppp/ssl/sstp-cert.pem
    ssl-keyfile=/etc/accel-ppp/ssl/sstp-key.pem
    cert-hash-proto=sha256
    http-error=allow
    ifname=sstp%d

    при подключении:
    "не удаётся проверить подпись сертификата"

    чего я делаю не так?
    Ответ написан
    Комментировать