2020年5月3日 星期日

教育部TANet無線漫遊設定【Perl + imap】

CentOS 6.8版本下載點
CentOS 7 版本下載點

cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

yum clean all

yum makecache


在 CentOS 的安裝上,我是選擇陽春版的方式處理,這樣子等一下會安裝的套件比較多,但是也可以了解是那些套件要安裝,以後查修比較簡單。

安裝前先升級 yum 套件
 [root@openvpn]# yum -y update

步驟一:安裝 OPENVPN軟體
================================
[root@openvpn]# yum install -y epel-release
[root@openvpn]# yum install -y openvpn


步驟二:將漫遊中心提供的 key「clt_number_name.tar」上傳放置 /etc/openvpn
================================
CentOS 6.10裝法
[root@openvpn]# cd /etc/openvpn
[root@openvpn]# tar -zxf clt_number_shortname.tar
[root@openvpn]# service openvpn restart
[root@openvpn]# chkconfig openvpn on

CentOS 7.0裝法
[root@openvpn]# cd /etc/openvpn
[root@openvpn]# tar -zxf clt_number_shortname.tar
[root@openvpn]# cp client.conf server.conf
[root@openvpn]# systemctl  restart  openvpn@server
[root@openvpn]# systemctl  enable  openvpn@server

看 tun0 VPN通道是否有啟動,如 tun0 有產生10.1.X.X代表VPN連線成功

步驟三:安裝 freeradius 軟體套件
================================
[root@freeradius]# yum install -y freeradius freeradius-utils
[root@freeradius]# cd  /etc/raddb
[root@freeradius]# vi clients.conf
================================
client 10.1.77.7 {
          secret        = spiradawn
          shortname = roamingcenter
     }


client 192.168.10.199 {
          secret      =  radius-key
          shortname  =  controller
     }

client 10.1.77.11 { 
           secret = spiradawn
           shortname = roamingcenter-monitor

}
===================================
修改/etc/raddb的proxy.conf檔案
[root@freeradius]# vi proxy.conf
===================================
<-->
realm NULL {
        authhost = LOCAL
        accthost = LOCAL
        secret = niucltcc
}

//設定學校的網域名稱
realm ntusd.ttc.edu.tw {
         authhost = LOCAL  //設定Radius Server認證(auth)位址
         accthost = LOCAL  //設定Radius Server計費(accounting)位址
}
realm DEFAULT { 
          authhost = 10.1.77.7:1812
          accthost = 10.1.77.7:1813
          secret = spiradawn    //漫遊中心給的Radius Key (金鑰)
          nostrip
}

==============================
啟動 Freeradius 服務
CentOS 6.10的方式
[root@freeradius ]#service radiusd restart
[root@freeradius ]#chkconfig radiusd on -->開機啟動

CentOS 7的方式
[root@freeradius ]# systemctl  restart  radiusd

[root@freeradius ]# systemctl  enable  radiusd -->開機啟動


[root@freeradius]# radtest  testuser@niu  testpass  127.0.0.1   0   testing123
                             radtest  帳號              密碼       測試伺服器  通訊埠  Secret
Sending Access-Request of id 234 to 10.1.0.7 port 1812
        User-Name = "testuser@niu"
        User-Password = "testpass"
        NAS-IP-Address = 127.0.0.1
        NAS-Port = 0
rad_recv: Access-Accept packet from host 10.1.0.7 port 1812, id=234, length=20

以上測試freeradius驗證是否正常


步驟四:修改 selinux 關閉

# vim /etc/sysconfig/selinux
   SELINUX=disabled    #關閉selinux功能

關閉防火牆功能 --> CentOS 6 指令
# /etc/init.d/iptables save 存檔
# /etc/init.d/iptables stop 停止
開機時停用防火牆
# chkconfig iptables off

關閉 Firewalld 防火牆指令: --> CentOS 7 指令 
# systemctl stop firewalld.service
設定下次開機不會啟動 Firewalld 防火牆
# systemctl disable firewalld.service

================================

步驟五:安裝perl相關模組

# yum install freeradius-perl perl perl-IO-Socket-SSL perl-Mail-IMAPClient -y

修改/etc/raddb/mods-available/perl檔案

[root@radius]# vim /etc/raddb/modules/perl    -->CentOS 6 指令
  
perl {
        #module = ${confdir}/example.pl
         module = ${confdir}/imap.pl





}

[root@radius]# vim /etc/raddb/mods-available/perl -->CentOS 7 指令
       
perl {
        #filename = ${modconfdir}/${.:instance}/example.pl
         filename = ${modconfdir}/${.:instance}/imap.pl





}


新增/etc/raddb/mods-config/perl/imap.pl並新增下列內容

[root@radius]# vim /etc/raddb/imap.pl  -->CentOS 6 指令
[root@radius]# vim /etc/raddb/mods-config/perl/imap.pl  -->CentOS 7 指令

use Mail::IMAPClient;
use Data::Dumper;

use constant    RLM_MODULE_REJECT=>    0;#  /* immediately reject the request */
use constant    RLM_MODULE_FAIL=>      1;#  /* module failed, don't reply */
use constant    RLM_MODULE_OK=>        2;#  /* the module is OK, continue */
use constant    RLM_MODULE_HANDLED=>   3;#  /* the module handled the request, so stop. */
use constant    RLM_MODULE_INVALID=>   4;#  /* the module considers the request invalid. */
use constant    RLM_MODULE_USERLOCK=>  5;#  /* reject the request (user is locked out) */
use constant    RLM_MODULE_NOTFOUND=>  6;#  /* user not found */
use constant    RLM_MODULE_NOOP=>      7;#  /* module succeeded without doing anything */
use constant    RLM_MODULE_UPDATED=>   8;#  /* OK (pairs modified) */
use constant    RLM_MODULE_NUMCODES=>  9;#  /* How many return codes there are *

sub authorize {
        return RLM_MODULE_OK;
}

sub authenticate {
   my $imap = Mail::IMAPClient->new(
        User     => $RAD_REQUEST{'User-Name'},
        Password => $RAD_REQUEST{'User-Password'},
        Server   => "imap.gmail.com",
        Port     => 993,
        Ssl      =>  1,
   ) or return RLM_MODULE_REJECT;
  
   if($imap->connect){
        return RLM_MODULE_OK;
        $imap->logout;
   }
}

修改/etc/raddb/proxy.conf 新增realm
[root@radius]# vim /etc/raddb/proxy.conf

realm XXX.edu.tw {
        type            = radius
        authhost        = LOCAL
        accthost        = LOCAL
}












[root@radius]# vim /etc/raddb/sites- enabled/default

authorize {
   if (!control:Auth-Type && User-Password) {
        update control {
            Auth-Type := Perl   #如果沒有認證屬性和密碼屬性使用Perl模組認證
        }
   }
}
authenticate {
    Auth-Type Perl {   #新增Auth-Perl認證
        perl
    }
}





















[root@freeradius ]#service radiusd restart   --> CentOS 6 指令
[root@freeradius ]#systemctl restart radiusd   --> CentOS 7 指令


一、 EAP-GTC驗證
1.          修改/etc/raddb/mods-enabled/eap
 [root@freeradius ]#vim /etc/raddb/mods-enabled/eap
  …
  gtc{ 
  ……              
    auth_type = perl
 
  }

  peap {
  …
     default_eap_type = gtc
 
  }
















 修改/etc/raddb/sites-enabled/inner-tunnel
[root@freeradius ]#vim /etc/raddb/sites-enabled/inner-tunnel

authenticate {
  Auth-Type Perl {
     perl
  }
}




步驟九:修改 freeradius 修改ntlm_auth模組(802.1X)
=====================================
[root@tanetroaming]# vim /etc/raddb/modules/ntlm_auth

exec ntlm_auth {
wait = yes
#program = "/path/to/ntlm_auth --request-nt-key --domain=MYDOMAIN --username=%{mschap:User-Name} --password=%{User-Password}" #將這一行註銷起來

program = "/usr/bin/ntlm_auth --request-nt-key --domain=aaa.bbb.edu.tw --username=%{%{Stripped-User-Name}:-%{%{User-Name}:-None}} --password=%{User-Password}"
#修改執行路徑和NULL認證方式
}


[root@tanetroaming]# vi /etc/raddb/sites-available/default
=====================================
authorize {
。。。略。。。
#  Read the 'users' file
files

if (!control:Auth-Type && User-Password) { #新增ntlm_auth驗證
        update control {
            Auth-Type := ntlm_auth
        }
    }
#
#  Look in an SQL database.  The schema of the database
#  is meant to mirror the "users" file.
#
#  See "Authorization Queries" in sql.conf

# sql
。。。略。。。

}


authenticate {
。。。略。。。

Auth-Type MS-CHAP {
mschap
}

Auth-Type ntlm_auth {    #新增ntlm_auth驗證
                ntlm_auth
}
==========================================
[root@freeradius ]# service radiusd restart #重啟 freeradius服務

參考資料如下

2020年2月16日 星期日

PVE 版本升級方式(6X)

# nano /etc/apt/sources.list

Proxmox VE No-Subscription Repository

As the name suggests, you do not need a subscription key to access this repository. It can be used for testing and non-production use. Its not recommended to run on production servers, as these packages are not always heavily tested and validated.
We recommend to configure this repository in /etc/apt/sources.list.
File /etc/apt/sources.list
deb http://ftp.tw.debian.org/debian buster main contrib

deb http://ftp.tw.debian.org/debian buster-updates main contrib

# PVE pve-no-subscription repository provided by proxmox.com,
# NOT recommended for production use
deb http://download.proxmox.com/debian/pve buster pve-no-subscription

# security updates
deb http://security.debian.org buster/updates main contrib

Proxmox VE Test Repository

按Ctrl+o -> enter Save
按Ctrl+X -> EXIT

 參考來源 BUBU 知識庫

2019年9月8日 星期日

Windows 10 更換SSD硬碟系統複製後開機出現 0xc0000225

客戶的電腦更換 M2 SSD使用完整 Copy後,就出現 0xC0000225 的錯誤訊息。


1、使用 Windows 10 安裝光碟或 USB 安裝碟開機 官方下載工具 這裡抓,然後應該是第二頁選擇『啟動修護你的電腦』『疑難排解』『進階選項』最後選擇『命令提示字元』

2、輸入 diskpart 按 Enter 進入磁碟管理工具模式

3、輸入 list volume  按 Enter 列出系統中所有磁碟
看清單中的標籤應該會寫 SYSTEM 或是 Fs 為 FAT32 的那個磁碟區,如果是磁碟 2 的話就輸入 select volume 2 按 Enter

4、輸入 assign letter=Z 按 Enter 暫時指定一個磁碟機代號 Z (可自訂,後續對應輸入)

5、輸入 exit 按 Enter 離開到一般命令提示字元

6、輸入 bcdboot C:\windows /s Z: /f UEFI 按 Enter 成功的話應該會出現『開機檔案已經順利建立』的訊息

7、輸入 exit 然後重新開機即可

參考網站 3C 達人廖阿輝

2019年8月11日 星期日

右鍵新增 Excel 檔案,無法開啟的問題

一直困擾很久的問題,終於解決了

就是如是右鍵 --> 新增 Excel檔案會出現下列的問題
無法開啟xlsx檔案 因為檔案格式或副檔名無效.請確認檔案沒有損毀 且副檔名符合檔案的格式

但是如果是開啟Excel檔,去新增的就沒問題,之前在 Google 也一直找不到問題,後來才找到問題點。

這個問題歸根結底,是模板導致的 。
也就是office 模板指向路徑沒有模板,例如被誤刪或指向路徑被修改。
問題現象就是彈出上面的框框。

解決這個問題的方法也很簡單,
新建一個xlsx檔案(要可以正常的),另存為excel12.xlsx
把這個檔案複製到 C:\WINDOWS\Shellnew\ 目錄下。
輸入regedit,進入登錄檔編輯器。
找到HKEY_CLASSES_ROOT,右鍵查詢,輸入 .xlsx

依次展開.xlsx → Excel.Sheet.12 →  ShellNew

找到filename 修改值為  C:\WINDOWS\Shellnew\excel12.xlsx 然後退出登錄檔編輯器,

然後右鍵新建一個Excel檔案開啟就可以了。

如果新建.xls檔案也有問題,那就新建一個.xlsx檔案另存為 .xls檔案 也放到指定的模板路徑裡
重複上述步驟 ,只不過搜尋.xlsx 改成搜尋.xls

參考來源:

2019年6月15日 星期六

Win10 安裝 Office 2016 出現錯誤代碼 1935

全新的電腦移內建的Office軟體之後,就變成無法安裝Office了

其實也不是網路上沒有解決方法,只是因為錯誤代碼與關鍵字沒有被文字化,找了好久才找到微軟的解答,也就是因為這個原因,我才決定要打這一篇文章。

解決的方法如下:
不用怕是奇怪的連結,因為我不是壞人,我是好人(笑

基本上呢,只要下載
NetFxRepairTool


上面的連結點進去會像下面圖片這個樣子。
我就在想說大家都是技術人員應該不用講的那麼細,但還是貼了(汗)

Microsoft .NET Framework Repair Tool的下載頁面

選擇修復軟體就好,下面的是隱私聲明的文件,想看的再勾就好。按下Next。

選擇Microsoft .NET Framework Repair Tool就好


並按照他的步驟修復之後,就可以順利的再把Office 安裝上去囉。

文章的出處 0x31 自己的問題自己解決

2019年5月25日 星期六

Proxmox 安裝 Webmin

WEBMIN下載網站

步驟一:
使用 SSH 登入 Putty

步驟二:
# wget http://prdownloads.sourceforge.net/webadmin/webmin-1.910.tar.gz
# gunzip webmin-1.910.tar.gz
# tar xf webmin-1.910.tar
# cd webmin-1.910
# ./setup.sh /usr/local/webmin

搞定了。

2019年5月12日 星期日

Window 2012 NPS安裝

安裝的步驟就不介紹了,Google還滿多了。
直接講重點
步驟一:在 RADIUS 用戶端新一個 Client 
===============================

步驟二:在原則-->連線要求原則--新增戶端 Client 
==========================================


步驟三:在原則-->網路原則--新增戶端 Client 
==========================================




查詢C:\Windows\system32\LogFiles\Log可以知道是否有成功

"RADIUSAD","IAS",05/12/2019,20:15:04,1,"kou@aaa.bbb.edu.tw","aaa.bbb.edu.tw/系統管理/test",,,,,,,,0,"192.168.166.243","UR-935",,,,,,,1,"Radius",0,"311 1 192.168.166.18 05/12/2019 11:32:54 8",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,"UR-935",1,,,,"

其中的 藍字 是在「RADIUS 用戶端」新增的名稱
其中的 紅字 是在「網路原則」新增的名稱