{"id":1370,"date":"2016-10-19T18:25:46","date_gmt":"2016-10-19T10:25:46","guid":{"rendered":"http:\/\/www.strongd.net\/?p=1370"},"modified":"2018-05-31T16:03:20","modified_gmt":"2018-05-31T08:03:20","slug":"centos6%e5%ae%89%e8%a3%85ocservopenconnectcisco-anyconnect-vpn","status":"publish","type":"post","link":"https:\/\/www.strongd.net\/?p=1370","title":{"rendered":"Centos6\u5b89\u88c5ocserv\/openconnect\/cisco AnyConnect vpn"},"content":{"rendered":"<p>\u5b89\u88c5\u7f16\u8bd1\u73af\u5883\u53ca\u4f9d\u8d56\uff0c\u5982\u90e8\u5206\u8f6f\u4ef6\u4e0d\u80fd\u5b89\u88c5\u8bf7\u5148\u5b89\u88c5epel\u6e90\u3002<\/p>\n<p>yum install pam-devel readline-devel http-parser-devel unbound gmp-devel<br \/>\nyum install tar gzip xz wget gcc make autoconf<br \/>\nocserv\u7f16\u8bd1\u5b89\u88c5\u4f9d\u8d56\uff0cocserv\u9700\u8981gnutls3\u7248\u672c\u4ee5\u4e0a\uff0cgnutls\u4f9d\u8d56nettle2.7.1\uff1a<\/p>\n<p>wget ftp:\/\/ftp.gnu.org\/gnu\/nettle\/nettle-2.7.1.tar.gz<br \/>\ntar zxvf nettle-2.7.1.tar.gz<br \/>\ncd nettle-2.7.1\/<br \/>\n.\/configure &#8211;prefix=\/usr\/local\/nettle<br \/>\nmake &amp;&amp; make install<br \/>\necho &#8216;\/usr\/local\/nettle\/lib64\/&#8217; &gt; \/etc\/ld.so.conf.d\/nettle.conf<br \/>\nldconfig<br \/>\n\u5b89\u88c5gnutls3.3.9\uff1a<\/p>\n<p>export NETTLE_CFLAGS=&#8221;-I\/usr\/local\/nettle\/include\/&#8221;<br \/>\nexport NETTLE_LIBS=&#8221;-L\/usr\/local\/nettle\/lib64\/ -lnettle&#8221;<br \/>\nexport HOGWEED_LIBS=&#8221;-L\/usr\/local\/nettle\/lib64\/ -lhogweed&#8221;<br \/>\nexport HOGWEED_CFLAGS=&#8221;-I\/usr\/local\/nettle\/include&#8221;<br \/>\nwget ftp:\/\/ftp.gnutls.org\/gcrypt\/gnutls\/v3.3\/gnutls-3.3.9.tar.xz<br \/>\ntar xvf gnutls-3.3.9.tar.xz<br \/>\ncd gnutls-3.3.9\/<br \/>\n.\/configure &#8211;prefix=\/usr\/local\/gnutls<br \/>\nmake &amp;&amp; make install<br \/>\nln -s \/usr\/local\/gnutls\/bin\/certtool \/usr\/bin\/certtool<br \/>\necho &#8216;\/usr\/local\/gnutls\/lib\/&#8217; &gt; \/etc\/ld.so.conf.d\/gnutls.conf<br \/>\nldconfig<br \/>\n\u5b89\u88c5libnl\uff1a<\/p>\n<p>yum install bison flex<br \/>\nwget http:\/\/www.carisma.slowglass.com\/~tgr\/libnl\/files\/libnl-3.2.24.tar.gz<br \/>\ntar xvf libnl-3.2.24.tar.gz<br \/>\ncd libnl-3.2.24<br \/>\n.\/configure &#8211;prefix=\/usr\/local\/libnl<br \/>\nmake &amp;&amp; make install<br \/>\necho &#8216;\/usr\/local\/libnl\/lib\/&#8217; &gt; \/etc\/ld.so.conf.d\/libnl.conf<br \/>\nldconfig<br \/>\n\u5b89\u88c5ocserv\uff1a<\/p>\n<p>export LIBNL3_CFLAGS=&#8221;-I\/usr\/local\/libnl\/include\/libnl3&#8243;<br \/>\nexport LIBNL3_LIBS=&#8221;-L\/\/usr\/local\/libnl\/lib\/ -lnl-3 -lnl-route-3&#8243;<br \/>\nexport LIBGNUTLS_LIBS=&#8221;-L\/usr\/local\/gnutls\/lib\/ -lgnutls&#8221;<br \/>\nexport LIBGNUTLS_CFLAGS=&#8221;-I\/usr\/local\/gnutls\/include\/&#8221;<br \/>\nwget ftp:\/\/ftp.infradead.org\/pub\/ocserv\/ocserv-0.9.0.1.tar.xz<br \/>\ntar xvf ocserv-0.9.0.1.tar.xz<br \/>\ncd ocserv-0.9.0<br \/>\n.\/configure &#8211;prefix=\/usr\/local\/ocserv<br \/>\nmake &amp;&amp; make install<br \/>\necho &#8216;export PATH=$PATH:\/\/usr\/local\/ocserv\/sbin\/:\/usr\/local\/ocserv\/bin\/&#8217; &gt;&gt; $HOME\/.bashrc<br \/>\nsource $HOME\/.bashrc<br \/>\n\u751f\u6210SSL\u8bc1\u4e66\uff1a<\/p>\n<p>mkdir \/etc\/ocserv\/<br \/>\ncd \/etc\/ocserv<br \/>\n#CA\u79c1\u94a5\uff1a<br \/>\ncerttool &#8211;generate-privkey &#8211;outfile ca-key.pem<br \/>\n#CA\u6a21\u677f\uff1a<br \/>\ncat &lt;&lt; EOF &gt; ca.tmpl<br \/>\ncn = &#8220;thinkingandcreating.com&#8221;<br \/>\norganization = &#8220;thinkingandcreating.com&#8221;<br \/>\nserial = 1<br \/>\nexpiration_days = 3650<br \/>\nca<br \/>\nsigning_key<br \/>\ncert_signing_key<br \/>\ncrl_signing_key<br \/>\nEOF<br \/>\n#CA\u8bc1\u4e66\uff1a<br \/>\ncerttool &#8211;generate-self-signed &#8211;load-privkey ca-key.pem &#8211;template ca.tmpl &#8211;outfile ca-cert.pem<br \/>\n#Server\u79c1\u94a5\uff1a<br \/>\ncerttool &#8211;generate-privkey &#8211;outfile server-key.pem<br \/>\n#Server\u8bc1\u4e66\u6a21\u677f\uff1a<br \/>\ncat &lt;&lt; EOF &gt; server.tmpl<br \/>\ncn = &#8220;thinkingandcreating.com&#8221;<br \/>\no = &#8220;thinkingandcreating.com&#8221;<br \/>\nexpiration_days = 3650<br \/>\nsigning_key<br \/>\nencryption_key<br \/>\ntls_www_server<br \/>\nEOF<br \/>\n#Server\u8bc1\u4e66\uff1a<br \/>\ncerttool &#8211;generate-certificate &#8211;load-privkey server-key.pem &#8211;load-ca-certificate ca-cert.pem &#8211;load-ca-privkey ca-key.pem &#8211;template server.tmpl &#8211;outfile server-cert.pem<br \/>\n\u5bc6\u7801\u767b\u5f55\uff0c\u751f\u6210\u5bc6\u7801\u6587\u4ef6\uff1a<\/p>\n<p>ocpasswd -c \/etc\/ocserv\/passwd username<br \/>\n\u8bc1\u4e66\u767b\u5f55\uff1a<\/p>\n<p>#user\u79c1\u94a5<br \/>\ncerttool &#8211;generate-privkey &#8211;outfile user-key.pem<br \/>\n#user\u6a21\u677f<br \/>\ncat &lt;&lt; EOF &gt; user.tmpl<br \/>\ncn = &#8220;some random name&#8221;<br \/>\nunit = &#8220;some random unit&#8221;<br \/>\nexpiration_days = 365<br \/>\nsigning_key<br \/>\ntls_www_client<br \/>\nEOF<br \/>\n#user\u8bc1\u4e66<br \/>\ncerttool &#8211;generate-certificate &#8211;load-privkey user-key.pem &#8211;load-ca-certificate ca-cert.pem &#8211;load-ca-privkey ca-key.pem &#8211;template user.tmpl &#8211;outfile user-cert.pem<br \/>\n\u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n<p>auth = &#8220;plain[\/etc\/ocserv\/passwd]&#8221;<br \/>\n#\u8bc1\u4e66\u8ba4\u8bc1<br \/>\n#auth = &#8220;certificate&#8221;<br \/>\nca-cert \/etc\/ocserv\/ca-cert.pem<br \/>\nmax-clients = 16<br \/>\nmax-same-clients = 2<br \/>\ntcp-port = 5551<br \/>\nudp-port = 5551<br \/>\nkeepalive = 32400<br \/>\ntry-mtu-discovery = true<br \/>\ncisco-client-compat = true<br \/>\nserver-cert = \/etc\/ocserv\/server-cert.pem<br \/>\nserver-key = \/etc\/ocserv\/server-key.pem<br \/>\nauth-timeout = 40<br \/>\npid-file = \/var\/run\/ocserv.pid<br \/>\nsocket-file = \/var\/run\/ocserv-socket<br \/>\nrun-as-user = nobody<br \/>\nrun-as-group = daemon<br \/>\ndevice = vpns<br \/>\nipv4-network = 172.16.37.0<br \/>\nipv4-netmask = 255.255.255.0<br \/>\nroute = 172.16.37.0\/255.255.255.0<br \/>\n\u542f\u52a8opserv\uff1a<\/p>\n<p>ocserv -f -c \/etc\/ocserv\/ocserv.conf<br \/>\nIP\u8f6c\u53d1\u53caSNAT\uff1a<\/p>\n<p>iptables -t nat -A POSTROUTING -j SNAT \u2013to-source &lt;\u670d\u52a1\u5668\u516c\u7f51 IP &gt; -o &lt;\u5bf9\u5e94\u7f51\u5361\u7684\u540d\u79f0&gt;<br \/>\niptables -t nat -A POSTROUTING -s 172.16.37.0\/24 -o venet0 -j MASQUERADE<br \/>\niptables -A FORWARD -s 172.16.37.0\/24 -j ACCEPT<br \/>\nservice iptables save<br \/>\n\u8bb0\u5f97\u5f00\u59cbiptables<br \/>\n\u4f7f\u7528\u7528\u6237\u5bc6\u7801\u8fde\u63a5\uff1a<\/p>\n<p>echo passwd|openconnect -u username thinkingandcreating.com:5551 &#8211;no-cert-check<br \/>\n\u4f7f\u7528\u8bc1\u4e66\u8fde\u63a5\uff1a<\/p>\n<p>openconnect -k user-key.pem -c user-cert.pem thinkingandcreating.com:5551 &#8211;no-cert-check<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b89\u88c5\u7f16\u8bd1\u73af\u5883\u53ca\u4f9d\u8d56\uff0c\u5982\u90e8\u5206\u8f6f\u4ef6\u4e0d\u80fd\u5b89\u88c5\u8bf7\u5148\u5b89\u88c5epel\u6e90\u3002 yum install pam-devel readline-devel http-parser-devel unbound gmp-devel yum install tar gzip xz wget gcc make autoconf ocserv\u7f16\u8bd1\u5b89\u88c5\u4f9d\u8d56\uff0cocserv\u9700\u8981gnutls3\u7248\u672c\u4ee5\u4e0a\uff0cgnutls\u4f9d\u8d56nettle2.7.1\uff1a wget ftp:\/\/ftp.gnu.org\/gnu\/nettle\/nettle-2.7.1.tar.gz tar zxvf nettle-2.7.1.tar.gz cd nettle-2.7.1\/ .\/configure &#8211;prefix=\/usr\/local\/nettle make &amp;&amp; make install echo &#8216;\/usr\/local\/nettle\/lib64\/&#8217; &gt; \/etc\/ld.so.conf.d\/nettle.conf ldconfig \u5b89\u88c5gnutls3.3.9\uff1a export NETTLE_CFLAGS=&#8221;-I\/usr\/local\/nettle\/include\/&#8221; export NETTLE_LIBS=&#8221;-L\/usr\/local\/nettle\/lib64\/ -lnettle&#8221; export HOGWEED_LIBS=&#8221;-L\/usr\/local\/nettle\/lib64\/ -lhogweed&#8221; export HOGWEED_CFLAGS=&#8221;-I\/usr\/local\/nettle\/include&#8221; wget ftp:\/\/ftp.gnutls.org\/gcrypt\/gnutls\/v3.3\/gnutls-3.3.9.tar.xz tar xvf gnutls-3.3.9.tar.xz cd gnutls-3.3.9\/ .\/configure &hellip; <a href=\"https:\/\/www.strongd.net\/?p=1370\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Centos6\u5b89\u88c5ocserv\/openconnect\/cisco AnyConnect vpn<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[174],"class_list":["post-1370","post","type-post","status-publish","format-standard","hentry","category-linux","tag-vpn"],"_links":{"self":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts\/1370","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1370"}],"version-history":[{"count":4,"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts\/1370\/revisions"}],"predecessor-version":[{"id":1493,"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts\/1370\/revisions\/1493"}],"wp:attachment":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1370"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1370"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1370"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}