검색결과 리스트
설정에 해당되는 글 2건
- 2008/11/23 우분투 환경에서 openvpn 설정 (3)
- 2008/07/01 자바 CLASSPATH 설정
글
우분투 환경에서 openvpn 설정
상대적으로 openvpn 서버를 이용하지 않고, 윈도우에서 사용하는 pptp 프로토콜을 사용하려고 하는 경우 poptop의 우분투 패키지인 pptpd 를 설치하고 간단한 설정을 통해서 바로 접속이 가능했다. 문제는 우리 회사의 경우 pptpd 를 정책상 막아 놓은건지 서버로 접속은 가능했지만, 서버에서 외부 접속에서 사용하는 ppp를 생성하는 중에 아래와 같은 메시지를 뿜으면서 커넥션을 잃어버리더라...
pptpd 설정
...
Nov 23 16:28:21 zeropage pptpd[7279]: CTRL: Client 203.244.218.56 control connection started
Nov 23 16:28:21 zeropage pptpd[7279]: CTRL: Starting call (launching pppd, opening GRE)
Nov 23 16:28:21 zeropage pppd[7280]: Plugin /usr/lib/pptpd/pptpd-logwtmp.so loaded.
Nov 23 16:28:21 zeropage pppd[7280]: pppd 2.4.4 started by root, uid 0
Nov 23 16:28:21 zeropage pppd[7280]: Using interface ppp0
Nov 23 16:28:21 zeropage pppd[7280]: Connect: ppp0 <--> /dev/pts/2
Nov 23 16:28:21 zeropage pptpd[7279]: GRE: Bad checksum from pppd.
Nov 23 16:28:51 zeropage pppd[7280]: LCP: timeout sending Config-Requests
Nov 23 16:28:51 zeropage pppd[7280]: Connection terminated.
Nov 23 16:28:51 zeropage pppd[7280]: Modem hangup
Nov 23 16:28:51 zeropage pppd[7280]: Exit.
Nov 23 16:28:51 zeropage pptpd[7279]: GRE: read(fd=6,buffer=8058660,len=8196) from PTY failed: status = -1 error = Input/output error, usually caused by unexpected termination of pppd, check option syntax and pppd logs
Nov 23 16:28:51 zeropage pptpd[7279]: CTRL: PTY read or GRE write failed (pty,gre)=(6,7)
Nov 23 16:28:51 zeropage pptpd[7279]: CTRL: Reaping child PPP[7280]
Nov 23 16:28:51 zeropage pptpd[7279]: CTRL: Client 203.244.218.56 control connection finished
어쨋든 그래서 openvpn 을 다시 한번 시도를 해보았지만, 기존에 존재하는 국내 문서중에는 openvpn을 우분투 패키지를 이용해서 설정한 내용이 없어서, 설정을 시도하면서 문서로 남겨볼겸 이렇게 글을 적고 있다.
참고문서) http://www.ventanazul.com/webzine/articles/openvpn-ubuntu-and-hulu
더보기
우선, 패키지 관리자를 이용해서 openvpn 패키지를 설치한다. apt-get, aptitude, synaptic 무엇을 패키지 설치에 이용해도 무방할 것이다. 개인적 기호에 의해서 aptitude 를 이용해서 설치했다.
설치를 한뒤 아래의 명령어로 기본 설정파일 위치를 지정한다.
해당 파일을 열고 이전에 존재하는 모든 내용을 comment 처리 한뒤, AUTOSTART="openvpn" 을 마지막에 추가한다.
이렇게 설정해주면 openvpn 은 구동시 /etc/openvpn/openvpn.conf 설정을 찾는데, 현재는 존재하지 않기 때문에 따로 작성을 할 것이다.
다음 작업할 내용은 키와 인증서를 만드는 일이다.
rsa 설정을 위해서 예제 설정 파일을 복사해온다.
root@zeropage:/etc/openvpn#vi easy-rsa/vars
위의 파일이 존재하지 않는 상황이라면 아래의 위치에서 설정 파일을 찾아보자.
root@zeropage:/etc/openvpn#vi easy-rsa/2.0/vars
export KEY_PROVINCE=LI
export KEY_CITY=Lima
export KEY_ORG="Nombre-OpenVPN"
export KEY_EMAIL="tu-nombre@example.com"
그리고 아래의 명령어를 이용해서 환경 설정을 현재 터미널에 반영한다.
NOTE: If you run ./clean-all, I will be doing a rm -rf on /etc/openvpn/easy-rsa/2.0/keys
Generating a 1024 bit RSA private key
..............++++++
........................................++++++
writing new private key to 'ca.key'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [PE]:
State or Province Name (full name) [LI]:
Locality Name (eg, city) [Lima]:
Organization Name (eg, company) [Nombre-OpenVPN]:
Organizational Unit Name (eg, section) []:
Common Name (eg, your name or your server's hostname) [Nombre-OpenVPN CA]:
Email Address [tu-nombre@example.com]:
서버키를 작성한다. (서버키 작성 마지막에 certification 을 반드시 작성하도록 y를 선택해야한다)
Generating a 1024 bit RSA private key
...++++++
.................++++++
writing new private key to 'server.key'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [PE]:
State or Province Name (full name) [LI]:
Locality Name (eg, city) [Lima]:
Organization Name (eg, company) [Nombre-OpenVPN]:
Organizational Unit Name (eg, section) []:
Common Name (eg, your name or your server's hostname) [server]:
Email Address [tu-nombre@example.com]:
to be sent with your certificate request
A challenge password []:
An optional company name []:
Using configuration from /etc/openvpn/easy-rsa/2.0/openssl.cnf
Check that the request matches the signature
Signature ok
The Subject's Distinguished Name is as follows
countryName :PRINTABLE:'PE'
stateOrProvinceName :PRINTABLE:'LI'
localityName :PRINTABLE:'Lima'
organizationName :PRINTABLE:'Nombre-OpenVPN'
commonName :PRINTABLE:'server'
emailAddress :IA5STRING:'tu-nombre@example.com'
Certificate is to be certified until Nov 21 08:03:49 2018 GMT (3650 days)
Sign the certificate? [y/n]:
CERTIFICATE WILL NOT BE CERTIFIED
클라이언트 키를 작성한다.
Generating a 1024 bit RSA private key
..................++++++
............++++++
writing new private key to 'client.key'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [PE]:
State or Province Name (full name) [LI]:
Locality Name (eg, city) [Lima]:
Organization Name (eg, company) [Nombre-OpenVPN]:
Organizational Unit Name (eg, section) []:
Common Name (eg, your name or your server's hostname) [client]:
Email Address [tu-nombre@example.com]:
to be sent with your certificate request
A challenge password []:
An optional company name []:
Using configuration from /etc/openvpn/easy-rsa/2.0/openssl.cnf
Check that the request matches the signature
Signature ok
The Subject's Distinguished Name is as follows
countryName :PRINTABLE:'PE'
stateOrProvinceName :PRINTABLE:'LI'
localityName :PRINTABLE:'Lima'
organizationName :PRINTABLE:'Nombre-OpenVPN'
commonName :PRINTABLE:'client'
emailAddress :IA5STRING:'tu-nombre@example.com'
Certificate is to be certified until Nov 21 08:06:02 2018 GMT (3650 days)
Sign the certificate? [y/n]:
CERTIFICATE WILL NOT BE CERTIFIED
Diffie Hellman 파라메터를 생성한다.
root@zeropage:/etc/openvpn/easy-rsa/2.0# ./build-dh
root@zeropage:/etc/openvpn/easy-rsa/2.0# ./build-dh
This is going to take a long time
.........+....................................+................+.........................................+.............................................................................+...................+.............................................+....+........................+..........................................................................................+...........................................+............................+.............................................................................++*++*++*
이제 기본적인 키 작성 작업이 끝났다. 클라이언트 측에서 서버로의 접속을 위해서는 /etc/openvpn/easy-rsa/keys 디렉토리내에 3개의 파일이 필요하니 잘 보관한다.
client1.crt
client1.key
openvpn 환경 설정 파일을 만들어야한다.
dev tun
proto tcp
port 1194
ca /etc/openvpn/easy-rsa/2.0/keys/ca.crt
cert /etc/openvpn/easy-rsa/2.0/keys/server.crt
key /etc/openvpn/easy-rsa/2.0/keys/server.key
dh /etc/openvpn/easy-rsa/2.0/keys/dh1024.pem
user nobody
group nogroup
server 10.8.0.0 255.255.255.0
persist-key
persist-tun
#status openvpn-status.log
#verb 3
client-to-client
push "redirect-gateway def1"
#log-append /var/log/openvpn
comp-lzo
그리고 IP라우팅을 위해서 아래의 커맨드를 한번씩 날려준다.
sudo iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE
sudo iptables -L -t nat
(차후 방화벽 정책 삭제를 위해서는 sudo iptables -F -t nat)
서버쪽 설정은 완료 되었음을 알 수 있다.
eth0 Link encap:Ethernet HWaddr 00:17:31:f3:11:1e
inet addr:165.194.17.160 Bcast:165.194.17.255 Mask:255.255.255.0
inet6 addr: fe80::217:31ff:fef3:111e/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:34354629 errors:0 dropped:0 overruns:0 frame:0
TX packets:14478158 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:355495487 (339.0 MB) TX bytes:744316533 (709.8 MB)
Interrupt:217 Base address:0x8000
eth1 Link encap:Ethernet HWaddr 00:48:54:4a:e0:c7
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Interrupt:20 Base address:0xac00
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:348697 errors:0 dropped:0 overruns:0 frame:0
TX packets:348697 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:185131767 (176.5 MB) TX bytes:185131767 (176.5 MB)
tun0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
inet addr:10.8.0.1 P-t-P:10.8.0.2 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
자 이제 오늘의 핵심 클라이언트에서 이제 VPN 서버로 한번 붙여보자. ㅋㅋ
VPN서버로 붙일 윈도우에서 http://openvpn.org 에서 제공하는 윈도우용 클라이언트를 받고 설치하자!!!
프로그램 메뉴의 OpenVPN configuration file directory 를 열고 서버에서 생성된 키중 ca.crt, client.crt, client.key 를 복사하고, client.ovpn 파일을 열고 remote 항목을 수정하면 종료!!!
# Sample client-side OpenVPN 2.0 config file #
# for connecting to multi-client server. #
# #
# This configuration can be used by multiple #
# clients, however each client should have #
# its own cert and key files. #
# #
# On Windows, you might want to rename this #
# file so it has a .ovpn extension #
##############################################
# will be pulling certain config file directives
# from the server.
client
# the server.
# On most systems, the VPN will not function
# unless you partially or fully disable
# the firewall for the TUN/TAP interface.
;dev tap
dev tun
# from the Network Connections panel
# if you have more than one. On XP SP2,
# you may need to disable the firewall
# for the TAP adapter.
;dev-node MyTap
# UDP server? Use the same setting as
# on the server.
;proto tcp
proto udp
# You can have multiple remote entries
# to load balance between the servers.
remote 165.194.17.160 1194
;remote my-server-2 1194
# list for load-balancing. Otherwise
# try hosts in the order specified.
;remote-random
# host name of the OpenVPN server. Very useful
# on machines which are not permanently connected
# to the internet such as laptops.
resolv-retry infinite
# a specific local port number.
nobind
;user nobody
;group nobody
persist-key
persist-tun
# HTTP proxy to reach the actual OpenVPN
# server, put the proxy server/IP and
# port number here. See the man page
# if your proxy server requires
# authentication.
;http-proxy-retry # retry on connection failures
;http-proxy [proxy server] [proxy port #]
# of duplicate packets. Set this flag
# to silence duplicate packet warnings.
;mute-replay-warnings
# See the server config file for more
# description. It's best to use
# a separate .crt/.key file pair
# for each client. A single ca
# file can be used for all clients.
ca ca.crt
cert client.crt
key client.key
# 위의 3개의 값을 절대경로를 함께 넣어서 "c:\\program files\\openvpn\\config\\key\...." 형태로 지정해야함.
# that the certicate has the nsCertType
# field set to "server". This is an
# important precaution to protect against
# a potential attack discussed here:
# http://openvpn.net/howto.html#mitm
#
# To use this feature, you will need to generate
# your server certificates with the nsCertType
# field set to "server". The build-key-server
# script in the easy-rsa folder will do this.
;ns-cert-type server
# then every client must also have the key.
;tls-auth ta.key 1
# If the cipher option is used on the server
# then you must also specify it here.
;cipher x
# Don't enable this unless it is also
# enabled in the server config file.
comp-lzo
verb 3
;mute 20
오케이 이렇게 하고 접속하면 VPN 성공... ㅋㅋㅋ
ps. 근데 또 안붙네... ㅡㅡ;; 덜덜 역시 외부망으로는 못붙는건가... 영 이상한디 ㅜ.ㅜ
글
자바 CLASSPATH 설정
자바의 classpath 를 사용하는 이유는 프로그램을 작성하면서 참조하는 다양한 라이브러리의 경로를 명시하여, jvm 구동시 이를 동적으로 링크하기 위함이다.
이를 지정하는 방법은 크게 두가지로 구분할 수 있다. 한가지는 시스템이 제공하는 환경변수 설정을 이용하는 방법, 두번째는 java 구동환경에서 option 을 설정을 통해서 명시적으로 지정하는 방법이다.
1. 환경 변수를 이용한 설정
운영체제는 시스템 운영상 필요한 경로를 시스템에 지정해두고서
참조하는 것이 가능하다. 이를 환경 변수라고 부르는데, 자바도
이곳에 필요한 경로를 설정해두고서 이용하는 것이 가능하다.
필요한 환경변수는 Path,
CLASSPATH 두개의 환경변수가 필요하며, 첫번째
Path 는 운영체제가 명령어를 실행하면서 해당 명령어에 맞는 실행파일을 찾아가는 순서를 명시한 환경변수이다.
이곳에 아래와 같은 식으로 설정을 함으로써 어떤 폴더에서나 자바의
컴파일러인 javac를 접근할 수 있다.
PATH=C:\Program Files\Java\jre1.6.0_05\bin;%SystemRoot%\system32;%SystemRoot%;
CLASSPATH= .;C:\Program Files\Java\jre1.6.0_05\lib\;
문제는 이렇게 환경변수를 설정하는 경우 컴파일시 다른 버전의
컴파일러를 실행하기 위해서는 변수 설정이 안됐을 때와 마찬가지로 절대경로로 접근해야하는 문제가 존재한다. 이런
상황에서 변리한 버전 변경을 위해서 아래와 같은 테크닉을 이용한다.
또한, 상기에서 보면 CLASSPATH에 현재 경로를 의미하는 . 를 추가했는데, 이는 자바 컴파일러가 명시적으로 CLASSPATH를 지정할 경우
현재 경로를 보지 않기 때문에 환경 변수상에서 현재 폴더를 추가해야만 정상적인 실행이 가능하기 때문이다.
JAVAPATH= C:\Program Files\Java\jre1.6.0_05;
PATH= %JAVAPATH%\bin;%SystemRoot%\system32;%SystemRoot%;
CLASSPATH= .; %JAVAPATH%\lib\;
즉, 환경변수는 시스템내에서 %{environmental
variables}%의 형대로 참조가 가능하다. 이렇게 설정을 할 경우 다른 버전의 자바
컴파일러를 사용할 경우 JAVAPATH 만을 변경해주면 된다.
환경 변수를 시스템에 설정하지 않고도 클래스 패스를 지정하는 것이 가능한데, 이는 javac, java를 이용해서 실행할 때 –classpath 라는 옵션을 사용하는 것이다.
이 경우에는 윈도우의 경우 아래의 형태로 일단 사용이 가능하다.
java –classpath “C:\Program Files\Java\jre1.6.0_05\lib”;. HelloWorld
주의점은 경로상에 빈칸이 존재하는 경우에는 경로를 반드시 “”를 이용해서 묶어줘야 한다. 또한 만약 자바의 경로를 환경변수 상에 지정한 경우라면 아래와 같은 형태의 표현도 가능하다.
java –classpath %JAVAPATH%\bin;. HelloWorld
이 경우 마찬가지로 자바의 경로상에 빈칸이 존재하는 경우라면 환경변수 설정된 디렉토리를 “”로 묶어줘야 한다.