一、 網絡環境如下
1.Open*** Server
外網卡eth1配置 IP:121.12.x.y MASK:255.255.255.128 GateWay:121.12.x.1 | LAN eth0卡配置 IP:192.168.38.87 MASK:255.255.255.0 DNS:192.168.38.1 | 遠程撥號DHCP池: 172.16.0.0 -172.16.0.127 掩碼:255.255.255.128 |
2.內網三層交接口IP:192.168.38.254
二、網絡配置注意點
1. Open*** Server內網卡上配置反向路由(eth0爲內網口,eth1爲外網口)
vi/etc/sysconfig/network-scripts/route-eth0
添加如下內容:192.168.0.0/16 via 192.168.38.254
2. *** Server防火牆配置(eth0爲內網口,eth1爲外網口)
#開放外網口UDP 1194(Open***)
iptables -I INPUT -i eth1 -p udp --dport 1194 -j ACCEPT
#內網口全部接受
iptables -I INPUT -i eth0 -j ACCEPT
#影響所有有出主動出去的返回包
iptables -I INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
#默認策略拒絕所有
iptables -A INPUT -j DROP
iptables -I OUTPUT -o eth1 -p udp --sport 1194 -j ACCEPT
iptables -I OUTPUT -o eth0 -j ACCEPT
iptables -A OUTPUT -j DROP
#接受外網口ping(允許ping入)
iptables -I INPUT -p icmp --icmp-type echo-request -j ACCEPT
#允許ping出
iptables -I OUTPUT -p icmp -m icmp--icmp-type echo-reply -j ACCEPT
iptables -I OUTPUT -p icmp --icmp-type echo-request -j ACCEPT
保存配置/sbin/iptables-save
說明:配置外網卡開放了udp端口1194;內網卡全開放同時開啓了ping
3.在三層交換機配置路由
iproute 172.16.0.0 255.255.255.128 192.168.38.87
三、服務器軟件安裝
1.建議停用SELinux 及開啓IP轉發
vi /etc/selinux/config
修改前:SELINUX=enforcing
修改後:SELINUX=disabled
開啓系統的路由功能 echo "1" >/proc/sys/net/ipv4/ip_forward
然後重啓服務器
2. Googele authenticator安裝
準備打包的軟件環境
yum -y install git gcc \
libtool autoconf \
automake pam-devel \
rpm-build qrencode-libs;
抓取源代碼,打包
git clone https://github.com/google/google-authenticator-libpam.git
cd google-authenticator-libpam
./bootstrap.sh
./configure
make dist
cp google-authenticator-*.tar.gz~/rpmbuild/SOURCES/
上面這一步如果提示~/rpmbuild目錄不存在,則先把下一步執行一次然後再試
下面這一步會確保有~/rpmbuild目錄
rpmbuild -ba contrib/rpm.spec
# 成功以後,編好的rpm包路徑在:
/root/rpmbuild/RPMS/x86_64/google-authenticator-1.03-1.el6.x86_64.rpm
進入 cd /root/rpmbuild/RPMS/x86_64/
安裝:rpm -ivh google-authenticator-1.03-1.el6.x86_64.rpm
3. Open***安裝
準備打包的軟件環境
正常yum是沒有open***、easy_rsa的安裝包,需要另外添加yum安裝源:epel源
rpm -ivh http://mirrors.sohu.com/fedora-epel/6/x86_64/epel-release-6-8.noarch.rpm
yum -y install open*** \
pam_ldap \
open***-auth-ldap \
pamtester \
lzo \
openssl \
zlib;
4. 證書配置
mkdir/etc/open***/easy-rsa
cp/usr/share/easy-rsa/2.0/* /etc/open***/easy-rsa/
vi/etc/open***/easy-rsa/vars修改vars中的以下信息,並保存
內容如下:
export KEY_COUNTRY="CN"
export KEY_PROVINCE="GD"
export KEY_CITY="ZS"
export KEY_ORG="NEO"
export KEY_EMAIL="[email protected]"
exportKEY_OU=“NEO”
進入cd /etc/open***/easy-rsa/
source ./vars初始化
./clean-all清理證書(此步驟第一次可以省去)
./build-ca創建根證書 在keys下生成ca.crt ca.key
./build-key-serverNEO創建服務器端證書 在keys下生成neo.crt neo.csr neo.key
./build-keyNEO-client創建客戶端證書 在keys下生成neo-client.crt neo-client.csr neo-client.key
./build-dh生成diffiehellman參數 在keys下生成dh2048.pem
四、服務器軟件配置
1.用戶認證配置
vi/etc/pam_ldap.conf
內容如下:
host 192.168.38.1 192.168.38.8
base dc=nccn,dc=int
uri ldap://192.168.38.1/
binddncn=ldapuser,ou=Special,ou=ZS,ou=NEOUsers,dc=nccn,dc=int
bindpw ldapuser賬號密碼
pam_login_attributesAMAccountName
2.Open***配置
vi /etc/open***/server.conf
內容如下:
port 1194
proto udp
dev tun
ca /etc/open***/easy-rsa/keys/ca.crt
cert /etc/open***/easy-rsa/keys/neo.crt
key /etc/open***/easy-rsa/keys/neo.key
dh /etc/open***/easy-rsa/keys/dh2048.pem
server 172.16.0.0 255.255.255.128
ifconfig-pool-persist ipp.txt
push "route 192.168.0.0 255.255.0.0"
push "dhcp-option DNS 192.168.38.1"
client-to-client
#keepalive 10 120
comp-lzo
max-clients 100
log /etc/open***/open***.log
log-append /etc/open***/open***.log
client-cert-not-required
username-as-common-name
plugin/usr/lib64/open***/plugins/open***-plugin-auth-pam.so /etc/pam.d/open***
vi/etc/pam.d/open***
內容如下:
auth required pam_google_authenticator.so nullokforward_pass debug
auth required pam_ldap.so use_first_pass debug
account required pam_unix.so
第一行的 forward_pass 參數使得一次讀入系統密碼(ldap,也就是 AD 密碼)和 google authenticator 的密碼,然後把系統密碼扔給後續的pam(也就是帶有 use_first_pass 參數的pam模塊)處理
第二行的 use_first_pass 上面已有講到(前兩行都帶 debug 參數完全是調試的需要,生產環境可以不用)
第三行是必須的,否則 open*** 登錄不上
3. 添加***服務爲自啓動
chkconfig --add open***
chkconfig open*** on
service open*** start
五、*** Client配置
1. Googele authenicator以及用戶初始化:
useradd ldapuser
su ldapuser
google-authenticator 全部回答”Y”
2. 安裝手機端
使用app商店查找Googeleauthenicator,進行安裝
在手機客戶端掃碼或者輸入賬號名和此賬號的 secretkey
完成後,每隔36000就會生成一個新6位碼:
3. 驗證是否成功
pamtester open*** ldapuser authenticate
4. 電腦端Open*** Client配置
從Open***服務器上的 /etc/open***/easy-rsa/keys/位置下載ca.crt到windows
同時在windows下生成一個叫client.o***的配置文件,內容如下:
client
dev tun
proto udp
remote 121.12.x.y 1194
ca ca.crt
verb 3
auth-user-pass
comp-lzo
在Windows OPEN***客戶端(此軟件安裝略)上,點“+”號
導入client.o***文件
即可進行測試撥號
下面成功顯示
查看一下系統IP
查看網絡路由表:
上面表示***撥號成功
後續
編寫一腳本自動建***賬號和發郵件給*** 用戶
修改/etc/nail.rc (/etc/mail.rc)
Set from=itsupport@maildomain.com smtp=mail.maildomain.com set smtp-auth-user=notice smtp-auth-password=password set smtp-auth=login
說明:
from是發送的郵件地址
smtp是發生的外部smtp服務器的地址
smtp-auth-user是外部smtp服務器認證的用戶名
smtp-auth-password是外部smtp服務器認證的用戶密碼
smtp-auth是郵件認證的方式
vi ***useradd
內容(其中:Open*** Client Setting Manual.pdf是Open***用戶端操作手冊):
----------------------
#!/bin/bash
echo "please input open***username:"
read a
if test-e /home/$a
then echo "this *** user is exist!"
else
useradd $a
su -c \
"google-authenticator -t -f -d -w17 -r 3 -R 30 -q" \
$a
echo "Below is $a 's new secretkey:" >gs-temp
echo " " >>gs-temp
head -1 /home/$a/.google_authenticator>>gs-temp
echo " ">>gs-temp
echo "1. Please follow the attachment Manual to do!" >>gs-temp
echo "2. Any question, please call IT NO.xxxx !" >>gs-temp
mail -s "Google_authenticatorKey" -a Open***\ Client\ Setting\ Manual.pdf [email protected] <gs-temp
fi
------------------------------
chmod755 ***useradd (chmod ***useradd 爲可執行文件)