블로그 이미지
훅크선장

카테고리

분류 전체보기 (361)
사진이야기 (23)
펭귄컴퓨팅 (120)
컴퓨터보안 (84)
돼지털세상 (12)
네트웍세상 (68)
신기한것들 (4)
절름발이 프로그래머 (59)
하드웨어개조 (23)
멀알려줄까 (35)
홈베이킹&홈쿠킹 (2)
잡다한것들 (15)
Total
Today
Yesterday

달력

« » 2024.4
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30

공지사항

태그목록

최근에 올라온 글

아래 링크 내용을 참고하였음.
http://www.cyberciti.biz/tips/lighttpd-setup-a-password-protected-directory-directories.html


1. lighttpd-mod-auth 모듈을 설치한다.

root@HomeRouter:/etc/lighttpd# opkg install lighttpd-mod-auth
Installing lighttpd-mod-auth (1.4.29-3) to root...
Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/lighttpd-mod-auth_1.4.29-3_ar71xx.ipk.
Configuring lighttpd-mod-auth.

2. lighttpd.conf 설정파일에서 인증과 관련된 내용을 추가한다.
mod_auth 모듈의 사용 여부를 지정하고, 인증 방식과 인증 관련 파일 지정 및 인증 디렉토리별 사용자 설정을 한다.

root@HomeRouter:/etc/lighttpd# vi lighttpd.conf 
# lighttpd configuration file
...
<중략>
...
server.modules = ( 
# "mod_rewrite", 
# "mod_redirect", 
# "mod_alias", 
"mod_auth", 
# "mod_status", 
# "mod_setenv",
# "mod_fastcgi",
# "mod_proxy",
# "mod_simple_vhost",
# "mod_cgi",
# "mod_ssi",
# "mod_usertrack",
# "mod_expire",
# "mod_webdav"
)

...
<중략>
...

#### auth module
## read authentification.txt for more info
auth.debug = 2
auth.backend = "plain"
#auth.backend.plain.userfile = "lighttpd.user"
auth.backend.plain.userfile = "/etc/lighttpd/.lighttpdpassword"
#auth.backend.plain.groupfile = "lighttpd.group"
auth.require = (
# "/server-status" => ( 
# "method"  => "digest",
# "realm"   => "download archiv",
# "require" => "group=www|user=jan|host=192.168.2.10"
# ),
"/download/" => ( 
"method"  => "basic",
"realm"   => "Private Download Area",
"require" => "user=webuser"
)
)

3. 인증용 패스워드 파일을 생성하고, 사용자명과 패스워드를 적어준다.

root@HomeRouter:/etc/lighttpd# ll
drwxr-xr-x    2 root     root          4096 Jan  4 09:36 .
drwxr-xr-x   17 root     root          4096 Dec 30 00:03 ..
-rw-r--r--    1 root     root            14 Jan  4 09:36 .lighttpdpassword
-rw-r--r--    1 root     root          6077 Jan  4 09:51 lighttpd.conf
root@HomeRouter:/etc/lighttpd# vi .lighttpdpassword 
webuser:password
~

4. lighttpd 데몬을 재시작한다.
 
root@HomeRouter:/etc/lighttpd# sync
root@HomeRouter:/etc/lighttpd# /etc/init.d/lighttpd restart

5. 정상적인 동작이 되지 않을 때는, 디버깅한다.

lighttpd.conf 파일에 다음 내용을 추가하고, 데몬을 재시작한다.
 ## where to send error-messages to
server.errorlog = "/var/log/lighttpd/error.log"

지정된  /var/log/lighttpd/error.log 파일 내용을 보면, 어떤 문제가 생겼는지를 알 수가 있다.
 
Posted by 훅크선장
, |
1. OpenWRT Firmware 설치
사전 준비사항
1) OpenWRT Firmware 10.3.1 버전 (2011년 11월 29일 현재 최신 버전)을 다운받는다. 파일명은 openwrt-ar71xx-generic-dir-825-b1-jffs2-factory.bin 이며, http://downloads.openwrt.org/backfire/10.03.1/ar71xx/ 에서 다운받을 수 있다.

firmware recovery mode를 이용하여, 웹 인터페이스로 펌웨어를 설치
2) DIR-825 공유기의 전원이 꺼진 상태에서, 후면 패널 부분의 RESET 버튼을 누른 상태로 전원을 인가한다. RESET 버튼을 계속 누른 상태로 약 10초 ~ 30초 사이를 유지하면, 전면 패널의 전원 LED 가 주황색으로 느리게 깜빡거리는 상태가 바로 firmware recovery mode이다. 

컴퓨터의 네트워크설 
3) 컴퓨터의 네트워크 설정을 IP 주소 : 192.168.0.100, 서브넷 마스크 : 255.255.255.0, 기본 게이트웨이 : 192.168.0.1 로 설정한다. 다른 항목은 설정하지 않아도 된다.

컴퓨터와 공유기의 연결
4) 컴퓨터 네트워크 카드와 공유기의 LAN 포트를 랜 케이블로 연결한다. 공유기의 LAN 포트는 후면 패널에서 파란색 영역으로 표시되어 있고, 1, 2, 3, 4 라고 번호가 붙여진 곳이다. 4개의 포트 중에 어떤 포트를 사용해도 상관없다.

펌웨어 업데이트
5) 컴퓨터에서 인터넷 익스플로러를 실행하고(반드시 Internet Explorer이어야 한다. 기타 사파리, 파이어폭스, 크롬 브라우저를 사용해서는 안된다.), 주소창에 http://192.168.0.1 를 입력한다.
6) 펌웨어 업데이트 화면이 나오면, "Browse" 버튼을 누른 다음, 미리 다운받은 openwrt-ar71xx-generic-dir-825-b1-jffs2-factory.bin 펌웨어 파일을 선택하고, "Update"  버튼을 클릭한다. 
7) 화면에서 펌웨어 업데이트 진행과정이 %로 표시된다. 100%가 되고나서도 약 10 ~ 20초 정도를 더 기다리면, 자동으로 장비가 리부팅된다. (절대 어떤 일이 있더라도, 브라우저를 닫아버리거나, 공유기를 끄면 안된다. 컴퓨터도 건드리지 않는 것이 좋다.)

펌웨어 업데이트 확인
8) 공유기가 리부팅되는 과정중에 전면 패널의 전원 LED 가 주황색으로 깜빡거린 후에, 완전히 동작하면 주황색으로 켜진 상태가 유지된다. 컴퓨터의 네트워크 설정을 “자동으로 IP 주소 받기” 와 “자동으로 DNS 서버 주소 받기”로 설정한다. 그리고 명령어 창을 열고 ipconfig 명령을 내렸을 때, 컴퓨터의 IP 주소가 자동으로 192.168.1.144와 같은 192.168.1.x 대역을 가지고 있다면 정상적으로 펌웨어가 업데이트된 상황이다.

공유기의 관리자 암호 설정
9) OpenWRT는 처음 설치하면, 무조건 관리자 암호를 설정하도록 되어 있다.
 OpenWRT 공유기의 IP 주소는 192.168.1.1이며, 먼저 telnet을 통하여 관리자 암호를 설정한다. 

telnet 192.168.1.1
한 다음,
바로 로그인되면, passwd 명령어를 이용하여, 관리자 암호를 설정한다. 관리자 암호는 두 번 넣도록 되어 있다.
(XShell과 같은 자동 로그인되는 터미널 프로그램에서는 로그인 스크립트 인식을 꺼놓아야 한다. 왜냐하면, XShell과 같은 프로그램은 접속하는 순간, 로그인 스크립트를 실행하기 때문에, 정상적인 로그인이 되는 것이 아니라, 엉뚱하게도 패스워드가 틀렸으니, 패스워드를 바꾸라는 화면이 나온다.)

exit 명령어로 telnet 접속을 종료한다.
telnet 접속이 종료되면, telnet은 더 이상 사용할 수 없다. 오직 SSH로만 접속 가능하다.

D-Link DIR-825 공유기의 OpenWRT는 웹 인터페이스가 없으므로,(나중에 설치할 수는 있으나, 공유기 내부 디스크 공간 제약이 존재한다.) 모든 것을 SSH 접속으로 설정한다.

버팔로 WZR-HP-G300NH 제품은 펌웨어에 기본적으로 Luci 웹 인터페이스가 존재한다. 두 제품의 차이는 내부 램 영역의 사용 파티션 공간 때문에 생긴다.
DIR-825는 루트 파티션 영역이 5MB로 설정되고, WZR-HP-G300NH는 30MB로 설정되므로, 후자가 훨씬 많은 추가 패키지들을 설치할 수 있다. DIR-825는 Luci 웹 인터페이스를 설치하게 되면, 다른 기능들을 거의 설치할 수가 없다.

2. OpenWRT의 기본 설정 변경
SSH 클라이언트를 이용하여, IP 주소 : 192.168.1.1 , 포트번호 : 22 , 사용자 계정 : root 로 공유기로 SSH 로그인을 한다. 앞에서 설정한 패스워드를 사용한다. 

1) 쉘 명령어 alias 추가
쉘에서 디렉토리의 파일들을 보여주는 ls -la 명령어를 ll 명령어를 줄여서 쓸 수 있도록 설정한다.
/root 디렉토리에 .profile을 생성하고, 그 안에 alias 구문으로 설정하면 된다.
또는
/etc 디렉토리에 있는 profile 파일을 수정하면 된다.

Connecting to 192.168.1.1:22...
Connection established.
Escape character is '^@]'.

sh: /usr/bin/X11/xauth: not found


BusyBox v1.19.3 (2011-12-19 15:01:26 MST) built-in shell (ash)
Enter 'help' for a list of built-in commands.

  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 ATTITUDE ADJUSTMENT (bleeding edge, r29570) ----------
  * 1/4 oz Vodka      Pour all ingredients into mixing
  * 1/4 oz Gin        tin with ice, strain into glass.
  * 1/4 oz Amaretto
  * 1/4 oz Triple sec
  * 1/4 oz Peach schnapps
  * 1/4 oz Sour mix
  * 1 splash Cranberry juice
 -----------------------------------------------------
root@OpenWrt:/# cd
root@OpenWrt:~# vi .profile
alias ll='ls -la'

~
root@OpenWrt:~# sync
root@OpenWrt:~# source ./.profile 

다른 방법으로 /etc 디렉토리에 있는 profile 파일 수정하기

root@OpenWrt:~# cd /etc
root@OpenWrt:/etc# vi profile
#!/bin/sh
[ -f /etc/banner ] && cat /etc/banner
...
<중략>
...
[ -x /usr/bin/arp ] || arp() { cat /proc/net/arp; }
[ -z /bin/ldd ] || ldd() { LD_TRACE_LOADED_OBJECTS=1 $*; }
 
# Shell Command Alias
alias ll='ls -la'
~

2) 내부 LAN 네트워크 대역 변경
내부 LAN 네트워크 대역 192.168.1.1을 나만의 네트워크 대역으로 바꾼다.
다른 공유기와 혼란이 되지 않도록, C-Class 대역이 생소한 192.168.43.1 네트워크 대역으로 변경한다.

내부 LAN 네트워크 설정을 수정한다.

root@OpenWrt:/# cd /etc
root@OpenWrt:/etc# ll
drwxr-xr-x   13 root     root             0 Jan  1  1970 .
drwxr-xr-x   17 root     root             0 Dec 27 01:47 ..
lrwxrwxrwx    1 root     root             7 Dec 20 09:43 TZ -> /tmp/TZ
-rw-r--r--    1 root     root           589 Dec 19 21:57 banner
drwxr-xr-x    2 root     root             0 Jan  1  1970 config
drwxr-xr-x    2 root     root             0 Dec 19 21:57 crontabs
drwxr-xr-x    4 root     root             0 Dec 19 21:57 defconfig
-rwxr-xr-x    1 root     root          2671 Dec 19 21:02 diag.sh
-rw-r--r--    1 root     root          1368 Dec 19 22:04 dnsmasq.conf
drwx------    2 root     root             0 Jan  1  1970 dropbear
-rw-r--r--    1 root     root             0 Jan  1  1970 ethers
-rw-r--r--    1 root     root           139 Dec 19 22:06 firewall.user
lrwxrwxrwx    1 root     root            10 Dec 20 09:43 fstab -> /tmp/fstab
lrwxrwxrwx    1 root     root            19 Dec 20 09:43 functions.sh -> ../lib/functions.sh
-rw-r--r--    1 root     root            78 Jan  1  1970 fw_env.config
-rw-r--r--    1 root     root           123 Mar 21  2011 group
-rw-r--r--    1 root     root            20 Mar 21  2011 hosts
drwxr-xr-x    8 root     root             0 Dec 20 09:43 hotplug.d
-rw-r--r--    1 root     root          1201 Nov  5 23:38 hotplug2-common.rules
-rw-r--r--    1 root     root            80 Mar 21  2011 hotplug2-init.rules
-rw-r--r--    1 root     root           242 Dec 20 09:26 hotplug2.rules
drwxr-xr-x    2 root     root             0 Nov  9 21:52 init.d
-rw-r--r--    1 root     root           104 Jan  1  1970 inittab
drwxr-xr-x    2 root     root             0 Dec 20 09:42 modules-boot.d
drwxr-xr-x    2 root     root             0 Dec 20 09:29 modules.d
lrwxrwxrwx    1 root     root            12 Dec 20 09:43 mtab -> /proc/mounts
-rw-r--r--    1 root     root           163 Dec 20 09:14 opkg.conf
-rw-r--r--    1 root     root           190 Jan  1  1970 passwd
-rw-r--r--    1 root     root           190 Nov 18 00:28 passwd-
drwxr-xr-x    4 root     root             0 Dec 20 09:43 ppp
-rwxr-xr-x    1 root     root           888 Jul 23 18:38 preinit
-rw-r--r--    1 root     root           476 Aug 19 18:08 profile
-rw-r--r--    1 root     root          2478 Mar 21  2011 protocols
-rwxr-xr-x    1 root     root          1490 Nov  9 21:52 rc.common
drwxr-xr-x    2 root     root             0 Dec 20 09:43 rc.d
-rw-r--r--    1 root     root           132 Mar 21  2011 rc.local
lrwxrwxrwx    1 root     root            16 Dec 20 09:43 resolv.conf -> /tmp/resolv.conf
-rw-r--r--    1 root     root          3001 Mar 21  2011 services
-rw-r--r--    1 root     root           149 Jan  1  1970 shadow
-rw-r--r--    1 root     root           116 Dec 19 21:57 shadow-
-rw-r--r--    1 root     root             9 Mar 21  2011 shells
-rw-r--r--    1 root     root           976 Sep 19 05:24 sysctl.conf
-rw-r--r--    1 root     root           128 Mar 21  2011 sysupgrade.conf
drwxr-xr-x    2 root     root             0 Jan  1  1970 uci-defaults
root@OpenWrt:/etc# cd config
root@OpenWrt:/etc/config# ls
dhcp      dropbear  firewall  network   system    ubootenv  wireless
root@OpenWrt:/etc/config# ll
drwxr-xr-x    2 root     root             0 Jan  1  1970 .
drwxr-xr-x   13 root     root             0 Jan  1  1970 ..
-rw-r--r--    1 root     root           885 Dec 19 22:04 dhcp
-rw-r--r--    1 root     root           134 Dec 19 22:05 dropbear
-rw-r--r--    1 root     root          3631 Dec 19 22:06 firewall
-rw-r--r--    1 root     root           564 Jan  1  1970 network
-rw-r--r--    1 root     root           411 Jan  1  1970 system
-rw-r--r--    1 root     root             0 Jan  1  1970 ubootenv
-rw-r--r--    1 root     root           874 Jan  1  1970 wireless
root@OpenWrt:/etc/config# vi network

config 'interface' 'loopback'
        option 'ifname' 'lo'
        option 'proto' 'static'
        option 'ipaddr' '127.0.0.1'
        option 'netmask' '255.0.0.0'

config 'interface' 'lan'
        option 'ifname' 'eth0.1'
        option 'type' 'bridge'
        option 'proto' 'static'
        option 'ipaddr' '192.168.43.1'
        option 'netmask' '255.255.255.0'

config 'interface' 'wan'
        option 'ifname' 'eth1'
        option 'proto' 'dhcp'

config 'switch'
        option 'name' 'rtl8366s'
        option 'reset' '1'
        option 'enable_vlan' '1'

config 'switch_vlan'
        option 'device' 'rtl8366s'
        option 'vlan' '1'
        option 'ports' '0 1 2 3 5t'

~
root@OpenWrt:/etc/config# sync
root@OpenWrt:/etc/config# reboot
root@OpenWrt:/etc/config# 

공유기를 리부팅한 다음,
SSH 클라이언트를 이용하여, IP 주소 : 192.168.43.1로 다시 로그인해서, 변경된 네트워크 대역을 확인한다.

Connecting to 192.168.43.1:22...
Connection established.
Escape character is '^@]'.

sh: /usr/bin/X11/xauth: not found


BusyBox v1.19.3 (2011-12-19 15:01:26 MST) built-in shell (ash)
Enter 'help' for a list of built-in commands.

  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 ATTITUDE ADJUSTMENT (bleeding edge, r29570) ----------
  * 1/4 oz Vodka      Pour all ingredients into mixing
  * 1/4 oz Gin        tin with ice, strain into glass.
  * 1/4 oz Amaretto
  * 1/4 oz Triple sec
  * 1/4 oz Peach schnapps
  * 1/4 oz Sour mix
  * 1 splash Cranberry juice
 -----------------------------------------------------
root@OpenWrt:~# ifconfig
br-lan    Link encap:Ethernet  HWaddr 00:18:E7:DB:68:1E  
          inet addr:192.168.43.1  Bcast:192.168.43.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:360 errors:0 dropped:67 overruns:0 frame:0
          TX packets:88 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:27884 (27.2 KiB)  TX bytes:13178 (12.8 KiB)

eth0      Link encap:Ethernet  HWaddr 00:18:E7:DB:68:1E  
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:432 errors:0 dropped:9 overruns:12 frame:0
          TX packets:103 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:40342 (39.3 KiB)  TX bytes:15765 (15.3 KiB)
          Interrupt:4 

eth0.1    Link encap:Ethernet  HWaddr 00:18:E7:DB:68:1E  
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:382 errors:0 dropped:0 overruns:0 frame:0
          TX packets:94 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:31124 (30.3 KiB)  TX bytes:13574 (13.2 KiB)

eth1      Link encap:Ethernet  HWaddr 00:18:E7:DB:68:1F  
          inet addr:121.183.236.174  Bcast:121.183.236.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1222 errors:0 dropped:0 overruns:0 frame:0
          TX packets:109 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:81262 (79.3 KiB)  TX bytes:9851 (9.6 KiB)
          Interrupt:5 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:16 errors:0 dropped:0 overruns:0 frame:0
          TX packets:16 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:3038 (2.9 KiB)  TX bytes:3038 (2.9 KiB)

3) 패키지 목록 업데이트
추가 패키지 설치를 위한 패키지 목록을 업데이트한다.

root@OpenWrt:~# opkg update
Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/Packages.gz.
Inflating http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/Packages.gz.
Updated list of available packages in /var/opkg-lists/snapshots.

4) USB 장치 마운트용 패키지 설치
USB 메모리스틱이나 USB 하드디스크 등을 공유기 뒷면 패널의 USB 포트에 연결하여 사용할 수 있도록 하는 패키지들을 설치한다. 홈서버로 사용되는 공유기는 내부 메모리 용량이 매우 작기 때문에, USB 메모리스틱과 같은 장치를 이용해서 저장공간을 확장할 수 있다.

root@OpenWrt:~# opkg install fdisk kmod-fs-ext4 kmod-usb2 kmod-usb-storage kmod-usb-storage-extras block-mount hotplug2
Installing fdisk (2.13.0.1-4) to root...
Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/fdisk_2.13.0.1-4_ar71xx.ipk.
Installing kmod-fs-ext4 (2.6.39.4-1) to root...
Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/kmod-fs-ext4_2.6.39.4-1_ar71xx.ipk.
Installing kmod-lib-crc16 (2.6.39.4-1) to root...
Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/kmod-lib-crc16_2.6.39.4-1_ar71xx.ipk.
Package kmod-usb2 (2.6.39.4-1) installed in root is up to date.
Installing kmod-usb-storage (2.6.39.4-1) to root...
Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/kmod-usb-storage_2.6.39.4-1_ar71xx.ipk.
Installing kmod-scsi-core (2.6.39.4-1) to root...
Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/kmod-scsi-core_2.6.39.4-1_ar71xx.ipk.
Installing kmod-usb-storage-extras (2.6.39.4-1) to root...
Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/kmod-usb-storage-extras_2.6.39.4-1_ar71xx.ipk.
Installing block-mount (0.2.0-7) to root...
Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/block-mount_0.2.0-7_ar71xx.ipk.
Installing blkid (1.41.12-2) to root...
Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/blkid_1.41.12-2_ar71xx.ipk.
Installing libuuid (1.41.12-2) to root...
Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/libuuid_1.41.12-2_ar71xx.ipk.
Installing libblkid (1.41.12-2) to root...
Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/libblkid_1.41.12-2_ar71xx.ipk.
Installing libext2fs (1.41.12-2) to root...
Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/libext2fs_1.41.12-2_ar71xx.ipk.
Installing libcom_err (1.41.12-2) to root...
Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/libcom_err_1.41.12-2_ar71xx.ipk.
Installing libpthread (0.9.32-98) to root...
Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/libpthread_0.9.32-98_ar71xx.ipk.
Installing swap-utils (2.13.0.1-4) to root...
Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/swap-utils_2.13.0.1-4_ar71xx.ipk.
Package hotplug2 (1.0-beta-4) installed in root is up to date.
Configuring kmod-scsi-core.
Configuring kmod-usb-storage.
Configuring libpthread.
Configuring kmod-lib-crc16.
Configuring libcom_err.
Configuring libblkid.
Configuring libuuid.
Configuring libext2fs.
Configuring blkid.
Configuring swap-utils.
Configuring block-mount.
Configuring kmod-fs-ext4.
Configuring fdisk.
Configuring kmod-usb-storage-extras.
root@OpenWrt:~# sync

테스트로 1GB 용량의 USB 메모리스틱을 꽂고, 마운트가 정상적으로 되는지 확인한다.(USB 메모리스틱에는 Linux용의 파티션이 2개가 존재한다.)

root@OpenWrt:~# mount
rootfs on / type rootfs (rw)
/dev/root on / type jffs2 (rw,noatime)
proc on /proc type proc (rw,noatime)
sysfs on /sys type sysfs (rw,noatime)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noatime,size=30964k)
tmpfs on /dev type tmpfs (rw,noatime,size=512k,mode=755)
devpts on /dev/pts type devpts (rw,noatime,mode=600)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
none on /proc/bus/usb type usbfs (rw,relatime)
root@OpenWrt:~# fdisk -l

Disk /dev/mtdblock0: 0 MB, 262144 bytes
255 heads, 63 sectors/track, 0 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x19010010

Disk /dev/mtdblock0 doesn't contain a valid partition table
...
<중략>
...
Disk /dev/mtdblock6: 6 MB, 6356992 bytes
255 heads, 63 sectors/track, 0 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x2b36ce10

Disk /dev/mtdblock6 doesn't contain a valid partition table

Disk /dev/sda: 1012 MB, 1012924416 bytes
32 heads, 61 sectors/track, 1013 cylinders
Units = cylinders of 1952 * 512 = 999424 bytes
Disk identifier: 0xb0bcd68e

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1         913      891057+  83  Linux
/dev/sda2             914        1013       97600   82  Linux swap / Solaris
root@OpenWrt:~# mount /dev/sda1 /mnt
root@OpenWrt:~# mount
rootfs on / type rootfs (rw)
/dev/root on / type jffs2 (rw,noatime)
proc on /proc type proc (rw,noatime)
sysfs on /sys type sysfs (rw,noatime)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noatime,size=30964k)
tmpfs on /dev type tmpfs (rw,noatime,size=512k,mode=755)
devpts on /dev/pts type devpts (rw,noatime,mode=600)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
none on /proc/bus/usb type usbfs (rw,relatime)
/dev/sda1 on /mnt type ext2 (rw,relatime,user_xattr,barrier=1,data=ordered)

5) 홈서버의 동적 DNS 사용을 위한 설치 및 설정
동적 DNS 설정을 위해서 패키지를 설치하고, 설정한다.

root@OpenWrt:/mnt# opkg install ddns-scripts
Installing ddns-scripts (1.0.0-17) to root...
Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/ddns-scripts_1.0.0-17_all.ipk.
Configuring ddns-scripts.
root@OpenWrt:/mnt# cd /etc/config
root@OpenWrt:/etc/config# mv ddns /root/
root@OpenWrt:/etc/config# vi ddns
config 'service' 'MyDDNS'
option 'force_unit' 'hours'
option 'enabled' '1'
option 'service_name' 'freedns.afraid.org'
option 'domain' '할당받은 도메인명'
option 'username' '사용자 ID'
option 'password' '도메인용 키 값'
option 'ip_source' 'network'
option 'ip_network' 'wan'
option 'check_interval' '1'
option 'check_unit' 'hours'
option 'force_interval' '72'
~
root@OpenWrt:/etc/config# sync

6) OpenVPN 설치 및 설정
OpenVPN 패키지를 설치하고, 설정한다.

root@OpenWrt:/etc/config# opkg install openvpn
Installing openvpn (2.2.1-4) to root...
Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/openvpn_2.2.1-4_ar71xx.ipk.
Installing kmod-tun (2.6.39.4-1) to root...
Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/kmod-tun_2.6.39.4-1_ar71xx.ipk.
Installing libopenssl (1.0.0e-1) to root...
Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/libopenssl_1.0.0e-1_ar71xx.ipk.
Installing zlib (1.2.5-1) to root...
Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/zlib_1.2.5-1_ar71xx.ipk.
Installing liblzo (2.05-1) to root...
Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/liblzo_2.05-1_ar71xx.ipk.
Configuring kmod-tun.
Configuring zlib.
Configuring libopenssl.
Configuring liblzo.
Configuring openvpn.
root@OpenWrt:/etc/config# mv openvpn /root/
root@OpenWrt:/etc/config# vi openvpn
config 'openvpn' 'MyOpenVPNServer'
    option 'server' '10.100.200.0 255.255.255.0'
    option 'dev' 'tun0'
    option 'proto' 'tcp'
    option 'port' '1194'
    option 'keepalive' '10 120'
    option 'ca' '/etc/openvpn/ca.crt'
    option 'cert' '/etc/openvpn/server.crt'
    option 'key' '/etc/openvpn/server.key'
    option 'dh' '/etc/openvpn/dh1024.pem'
    option 'status' '/tmp/openvpn-status.log'
    option 'verb' '3'
    option 'enable' '1'
~
root@OpenWrt:/etc/config# sync

인증서 파일을 /etc/openvpn 디렉토리에 복사한다.

root@OpenWrt:/etc/openvpn# ll
drwxr-xr-x    2 root     root             0 Dec 27 02:13 .
drwxr-xr-x   14 root     root             0 Dec 27 02:10 ..
-rw-r-----    1 root     root          1346 Dec 27 02:13 ca.crt
-rw-r-----    1 root     root          1456 Dec 27 02:13 cert.pem
-rw-r-----    1 root     root           424 Dec 27 02:13 dh.pem
-rw-r-----    1 root     root           887 Dec 27 02:13 key.pem
root@OpenWrt:/etc/openvpn# sync

인증서 파일과 디렉토리는 접근권한을 잘 설정해준다.

root@OpenWrt:/etc/openvpn# chmod 600 *
root@OpenWrt:/etc/openvpn# ll
drwxr-xr-x    2 root     root             0 Dec 27 02:13 .
drwxr-xr-x   14 root     root             0 Dec 27 02:10 ..
-rw-------    1 root     root          1346 Dec 27 02:13 ca.crt
-rw-------    1 root     root          1456 Dec 27 02:13 cert.pem
-rw-------    1 root     root           424 Dec 27 02:13 dh.pem
-rw-------    1 root     root           887 Dec 27 02:13 key.pem
root@OpenWrt:/etc/openvpn# cd ..
root@OpenWrt:/etc# chmod 700 openvpn

7) OpenVPN을 위한 방화벽 설정 및 기본 방화벽 추가 설정
OpenVPN 방화벽 룰, 외부 인터넷망에서 SSH 접근 방화벽 룰과 외부 FTP 접근, PPTP 방화벽룰까지 포함한다.
그리고, VPN 접속시에 공유기 웹 인터페이스 접근도 추가(DIR-825는 웹 인터페이스가 없으므로, 필요없다.)

root@OpenWrt:/etc# vi firewall.user 
# This file is interpreted as shell script.
# Put your custom iptables rules here, they will
# be executed with each firewall (re-)start.
                                      
# OpenVPN Remote Access & Routing Rule           
iptables -I INPUT 1 -p udp --dport 1194 -j ACCEPT
iptables -I INPUT 1 -p tcp --dport 1194 -j ACCEPT       
iptables -I FORWARD 1 --source 10.100.200.0/24 -j ACCEPT  
iptables -I FORWARD -i eth0 -o tun0 -j ACCEPT
iptables -I FORWARD -i tun0 -o eth0 -j ACCEPT                          
iptables -t nat -A POSTROUTING -s 10.100.200.0/24 -o eth0 -j MASQUERADE   
                                                                          
# Allow SSH Remote Access                                 
iptables -A input_rule -i eth1 -p tcp --dport 22 -j ACCEPT
                                                          
# Allow FTP Remote Access                                 
#iptables -A input_rule -i eth1 -p tcp --dport 21 -j ACCEPT 
                                                          
# Allow VPN client's Web Interface Access              
iptables -I INPUT 1 -i tun0 -p tcp --dport 80 -j ACCEPT
                                                       
# PPTP Server Setting                            
iptables -I INPUT 1 -p tcp --dport 1723 -j ACCEPT
iptables -I INPUT 1 -p gre -j ACCEPT             
                                     
iptables -I INPUT 1 -i ppp+ -j ACCEPT
iptables -I FORWARD -i ppp+ -j ACCEPT
iptables -I FORWARD -o ppp+ -j ACCEPT 
iptables -I OUTPUT 1 -o ppp+ -j ACCEPT              
#iptables -A input_wan -p tcp --dport 1723 -j ACCEPT
#iptables -A input_wan -p gre -j ACCEPT             
                                         
#iptables -A input_rule -i ppp+ -j ACCEPT     
#iptables -A forwarding_rule -i ppp+ -j ACCEPT
#iptables -A forwarding_rule -o ppp+ -j ACCEPT
#iptables -A output_rule -o ppp+ -j ACCEPT    
~                                         
root@OpenWrt:/etc# sync

마지막으로 OpenVPN 서비스를 매 부팅때마다 자동실행되도록 설정하고, 바로 실행한다.

root@OpenWrt:/etc# sync
root@OpenWrt:/etc# /etc/init.d/openvpn enable
root@OpenWrt:/etc# /etc/init.d/openvpn start

OpenVPN 서비스의 실행여부는 ps 명령어로 확인가능하고, 동작에 따른 로그는 logread 명령어로 확인할 수 있다.

root@OpenWrt:/etc# ps elf
  PID USER       VSZ STAT COMMAND
    1 root      1480 S    init
    2 root         0 SW   [kthreadd]
    3 root         0 SW   [ksoftirqd/0]
    4 root         0 SW   [kworker/0:0]
    5 root         0 SW   [kworker/u:0]
    6 root         0 SW   [rcu_kthread]
    7 root         0 SW<  [khelper]
   54 root         0 SW   [sync_supers]
   56 root         0 SW   [bdi-default]
   58 root         0 SW<  [kblockd]
   88 root         0 SW   [kswapd0]
  135 root         0 SW   [fsnotify_mark]
  149 root         0 SW<  [ar71xx-spi]
  162 root         0 SW   [mtdblock0]
  167 root         0 SW   [mtdblock1]
  172 root         0 SW   [mtdblock2]
  177 root         0 SW   [mtdblock3]
  182 root         0 SW   [mtdblock4]
  187 root         0 SW   [mtdblock5]
  192 root         0 SW   [mtdblock6]
  335 root         0 SW   [kworker/0:1]
  522 root         0 SW<  [ipolldevd]
  566 root         0 SWN  [jffs2_gcd_mtd3]
  573 root      1480 S    init
  607 root         0 SW<  [cfg80211]
  619 root         0 SW   [khubd]
  690 root      1484 S    /sbin/syslogd -C16
  692 root      1464 S    /sbin/klogd
  694 root       804 S    /sbin/hotplug2 --override --persistent --set-worker
 1303 root      1132 S    /usr/sbin/dropbear -P /var/run/dropbear.1.pid -p 22
 1433 root      1484 S    /sbin/udhcpc -t 0 -i eth1 -b -p /var/run/dhcp-eth1.p
 1499 nobody     928 S    /usr/sbin/dnsmasq -K -D -y -Z -b -E -s lan -S /lan/
 1510 root      1476 S    /sbin/watchdog -t 5 /dev/watchdog
 1514 root      1480 S    /usr/sbin/ntpd -n -p 0.openwrt.pool.ntp.org -p 1.ope
 1517 root      1196 R    /usr/sbin/dropbear -P /var/run/dropbear.1.pid -p 22
 1518 root      1484 S    -ash
 1752 root         0 SW   [scsi_eh_0]
 1754 root         0 SW   [usb-storage]
 1761 root         0 SW   [kworker/u:2]
 1891 root         0 SW   [jbd2/sda1-8]
 1892 root         0 SW<  [ext4-dio-unwrit]
 2075 root         0 SW   [flush-mtd-unmap]
 2076 root         0 SW   [flush-8:0]
 2091 root      3064 S    /usr/sbin/openvpn --syslog openvpn(MyOpenVPNServer)
 2092 root       804 S    /sbin/hotplug2 --override --persistent --set-worker
 2105 root      1472 R    ps elf
root@OpenWrt:/etc# logread
...
Dec 27 02:26:22 OpenWrt daemon.notice openvpn(MyOpenVPNServer)[2091]: OpenVPN 2.2.1 mips-openwrt-linux [SSL] [LZO2] [EPOLL] built on Dec 19 2011
Dec 27 02:26:22 OpenWrt daemon.warn openvpn(MyOpenVPNServer)[2091]: NOTE: OpenVPN 2.1 requires '--script-security 2' or higher to call user-defined scripts or executables
Dec 27 02:26:23 OpenWrt daemon.notice openvpn(MyOpenVPNServer)[2091]: Diffie-Hellman initialized with 2048 bit key
Dec 27 02:26:23 OpenWrt daemon.notice openvpn(MyOpenVPNServer)[2091]: TLS-Auth MTU parms [ L:1543 D:140 EF:40 EB:0 ET:0 EL:0 ]
Dec 27 02:26:23 OpenWrt daemon.notice openvpn(MyOpenVPNServer)[2091]: Socket Buffers: R=[87380->131072] S=[16384->131072]
Dec 27 02:26:23 OpenWrt daemon.notice openvpn(MyOpenVPNServer)[2091]: TUN/TAP device tun0 opened
Dec 27 02:26:23 OpenWrt daemon.notice openvpn(MyOpenVPNServer)[2091]: TUN/TAP TX queue length set to 100
Dec 27 02:26:23 OpenWrt daemon.notice openvpn(MyOpenVPNServer)[2091]: /sbin/ifconfig tun0 10.100.200.1 pointopoint 10.100.200.2 mtu 1500
Dec 27 02:26:23 OpenWrt daemon.notice openvpn(MyOpenVPNServer)[2091]: /sbin/route add -net 10.100.200.0 netmask 255.255.255.0 gw 10.100.200.2
Dec 27 02:26:23 OpenWrt daemon.notice openvpn(MyOpenVPNServer)[2091]: Data Channel MTU parms [ L:1543 D:1450 EF:43 EB:4 ET:0 EL:0 ]
Dec 27 02:26:23 OpenWrt daemon.notice openvpn(MyOpenVPNServer)[2091]: Listening for incoming TCP connection on [undef]:1194
Dec 27 02:26:23 OpenWrt daemon.notice openvpn(MyOpenVPNServer)[2091]: TCPv4_SERVER link local (bound): [undef]:1194
Dec 27 02:26:23 OpenWrt daemon.notice openvpn(MyOpenVPNServer)[2091]: TCPv4_SERVER link remote: [undef]
Dec 27 02:26:23 OpenWrt daemon.notice openvpn(MyOpenVPNServer)[2091]: MULTI: multi_init called, r=256 v=256
Dec 27 02:26:23 OpenWrt daemon.notice openvpn(MyOpenVPNServer)[2091]: IFCONFIG POOL: base=10.100.200.4 size=62
Dec 27 02:26:23 OpenWrt daemon.notice openvpn(MyOpenVPNServer)[2091]: MULTI: TCP INIT maxclients=1024 maxevents=1028
Dec 27 02:26:23 OpenWrt daemon.notice openvpn(MyOpenVPNServer)[2091]: Initialization Sequence Completed
root@OpenWrt:/etc# 

7) lsof 패키지 설치
공유기의 프로세스 감시나 기타 설정등에 대한 정보를 자세히 알기 위해서는,
lsof 패키지를 설치하는 것이 좋다.

lsof 패키지를 설치한 다음에, 인터넷 열린 포트들에 대한 정보를 확인한다.

root@OpenWrt:/etc# opkg install lsof
Installing lsof (4.81-2) to root...
Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/lsof_4.81-2_ar71xx.ipk.
Installing librpc (0.9.32-rc2-0a2179bbc0844928f2a0ec01dba93d9b5d6d41a7) to root...
Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/librpc_0.9.32-rc2-0a2179bbc0844928f2a0ec01dba93d9b5d6d41a7_ar71xx.ipk.
Configuring librpc.
Configuring lsof.

root@OpenWrt:/etc# lsof -i
COMMAND   PID   USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
dropbear 1303   root    3u  IPv4   1460      0t0  TCP *:ssh (LISTEN)
dnsmasq  1499 nobody    5u  IPv4   1566      0t0  UDP *:bootps 
dnsmasq  1499 nobody    6u  IPv4   1570      0t0  UDP *:domain 
dnsmasq  1499 nobody    7u  IPv4   1571      0t0  TCP *:domain (LISTEN)
dropbear 1517   root    7u  IPv4   1684      0t0  TCP localhost:6010 (LISTEN)
openvpn  2091   root    5u  IPv4   2476      0t0  TCP *:openvpn (LISTEN)

8) PPTP 서비스 설치
아이폰과 같은 스마트폰에서 VPN 사용을 위한 PPTP 서비스를 설치한다.
pptpd 패키지 뿐만 아니라, MPPE 지원도 설치해야 한다.
root@OpenWrt:/etc/config# opkg install kmod-mppe
Installing kmod-mppe (2.6.32.27-1) to root...
Downloading http://downloads.openwrt.org/backfire/10.03.1/ar71xx/packages/kmod-mppe_2.6.32.27-1_ar71xx.ipk.
Installing kmod-crypto-sha1 (2.6.32.27-1) to root...
Downloading http://downloads.openwrt.org/backfire/10.03.1/ar71xx/packages/kmod-crypto-sha1_2.6.32.27-1_ar71xx.ipk.
Configuring kmod-crypto-sha1.
Configuring kmod-mppe.
root@OpenWrt:/etc/config# opkg install pptpd    
Installing pptpd (1.3.4-2) to root...
Downloading http://downloads.openwrt.org/backfire/10.03.1/ar71xx/packages/pptpd_1.3.4-2_ar71xx.ipk.
Installing kmod-gre (2.6.32.27-1) to root...
Downloading http://downloads.openwrt.org/backfire/10.03.1/ar71xx/packages/kmod-gre_2.6.32.27-1_ar71xx.ipk.
Configuring kmod-gre.
Configuring pptpd.

PPTP와 관련된 설정파일은 사용자 ID와 패스워드 설정을 위해서 /etc/ppp/chap-secrets 파일과 서비스 dns 지정을 위한 /etc/ppp/options.pptpd 파일을 설정한다.

chap-secrets 파일에는 사용자명과 패스워드를 평문으로 입력한다.
PROVIDER는 아무 이름이나 지정하면 되고, IPADDRESS는 *를 지정한다.

root@OpenWrt:/etc/ppp# vi chap-secrets 
#USERNAME  PROVIDER  PASSWORD  IPADDRESS
pptp_user1    pptp-server     user-pw1        *
pptp_user2    pptp-server     user-pw2        *
~

options.pptpd 파일내에 있는 주석처리된 ms-dns 항목에 공유기의 IP 주소, 여기 예제에서는 192.168.43.1을 지정해서 추가한다.

root@OpenWrt:/etc/ppp# vi options.pptpd
#debug
#logfile /tmp/pptp-server.log
172.16.1.1:
auth
name "pptp-server"
lcp-echo-failure 3
lcp-echo-interval 60
default-asyncmap
mtu 1482
mru 1482
nobsdcomp
nodeflate
#noproxyarp
#nomppc
mppe required,no40,no56,stateless
require-mschap-v2
refuse-chap
refuse-mschap
refuse-eap
refuse-pap
ms-dns 192.168.43.1
#plugin radius.so
#radius-config-file /etc/radius.conf
~
root@OpenWrt:/etc/ppp# sync

PPTP 서비스를 매 부팅때마다 자동실행되도록 설정하고, 바로 실행한다.
root@OpenWrt:/etc/ppp# /etc/init.d/pptpd enable
root@OpenWrt:/etc/ppp# /etc/init.d/pptpd start

9) FTP 와 SFTP 서비스 설치
추가적으로 vsftpd 와 openssh-sftp-server 를 설치한다.
FTP 서버와 SFTP 접속을 가능하도록 한다.

root@OpenWrt:/etc# opkg install vsftpd
Installing vsftpd (2.3.4-3) to root...
Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/vsftpd_2.3.4-3_ar71xx.ipk.
Configuring vsftpd.

root@OpenWrt:/etc# opkg install openssh-sftp-server
Installing openssh-sftp-server (5.9p1-4) to root...
Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/openssh-sftp-server_5.9p1-4_ar71xx.ipk.
Configuring openssh-sftp-server.
root@OpenWrt:/etc# opkg files openssh-sftp-server
Package openssh-sftp-server (5.9p1-4) is installed on root and has the following files:
/usr/libexec/sftp-server
/usr/lib/sftp-server
 
FTP 설정은 /etc/vsftpd.conf 파일에서 한다.
root@MyRouter:~# cat /etc/vsftpd.conf 
background=YES
listen=YES
anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
check_shell=NO
#chroot settings
chroot_local_user=NO
#passwd_chroot_enable=YES
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd/chroot_list
#dirmessage_enable=YES
ftpd_banner=FTP Server
session_support=NO
#syslog_enable=YES
#userlist_enable=YES
#userlist_deny=NO
#userlist_file=/etc/vsftpd.users
#xferlog_enable=YES
#xferlog_file=/var/log/vsftpd.log
#xferlog_std_format=YES
root@MyRouter:~# 

ftp 사용자들은 chroot로 접근제어를 걸어준다.
그 사용자들의 목록은 /etc/vsftpd/chroot_list 적는다.
ftp 사용자들이 ftp로 공유기에 있는 중요 설정파일들을 모두 볼 수 있으므로, 반드시 chroot가 필요하다.(패스워드 해킹도 가능)

root@MyRouter:~# cat /etc/vsftpd/chroot_list 
ftp
root@MyRouter:~#  

ftp 사용자들의 계정은 /etc/passwd 에 수록한다. (버팔로 제품은 /etc/passwd 파일만이 존재하지만, DIR-825는 passwd와 shadow 파일이 존재한다. DIR-825에서는 계정정보를 /etc/passwd와 /etc/shadow 파일 모두에 적어주어야 한다.)
root@MyRouter:~# cat /etc/passwd
...
ftp:$1$agmhQqLM$0CjSWAbJnK4gWIyIwC03i.:55:55:ftp:/home/ftp:/bin/false
root@MyRouter:~#   

패스워드 필드를 비워둔 상태에서 생성하고, root가 passwd 명령어로 패스워드를 넣어주면 된다.
ftp 사용자들이 shell 접속(ssh와 sftp)이 불가하도록, /bin/false를 쉘로 지정해둔다.

root@OpenWrt:~# cd /etc/
root@OpenWrt:/etc# ll
drwxr-xr-x   17 root     root          4096 Dec 29 00:35 .
drwxr-xr-x   17 root     root          4096 Dec 29 00:34 ..
lrwxrwxrwx    1 root     root             7 Dec 27 05:56 TZ -> /tmp/TZ
drwxr-xr-x    3 root     root          4096 Dec 27 07:27 apache
-rw-r--r--    1 root     root           589 Dec 19 21:57 banner
-rw-r--r--    1 root     root           232 Dec 27 08:53 blkid.tab
-rw-r--r--    1 root     root           232 Dec 27 08:46 blkid.tab.old
drwxr-xr-x    2 root     root          4096 Dec 27 05:56 config
drwxr-xr-x    2 root     root          4096 Dec 19 21:57 crontabs
drwxr-xr-x    4 root     root          4096 Dec 27 05:56 defconfig
-rwxr-xr-x    1 root     root          2671 Dec 19 21:02 diag.sh
-rw-r--r--    1 root     root          1368 Dec 19 22:04 dnsmasq.conf
drwx------    2 root     root          4096 Dec 27 05:56 dropbear
-rw-r--r--    1 root     root            38 Dec 19 21:58 e2fsck.conf
-rw-r--r--    1 root     root             0 Jan  1  1970 ethers
-rw-r--r--    1 root     root          1460 Dec 27 07:34 firewall.user
lrwxrwxrwx    1 root     root            10 Dec 27 05:56 fstab -> /tmp/fstab
lrwxrwxrwx    1 root     root            19 Dec 27 05:56 functions.sh -> ../lib/functions.sh
-rw-r--r--    1 root     root            78 Jan  1  1970 fw_env.config
-rw-r--r--    1 root     root           123 Mar 21  2011 group
-rw-r--r--    1 root     root            20 Mar 21  2011 hosts
drwx------    9 root     root          4096 Dec 27 05:56 hotplug.d
-rw-r--r--    1 root     root          1201 Nov  5 23:38 hotplug2-common.rules
-rw-r--r--    1 root     root            80 Mar 21  2011 hotplug2-init.rules
-rw-r--r--    1 root     root           242 Dec 20 09:26 hotplug2.rules
drwxr-xr-x    2 root     root          4096 Dec 28 08:11 init.d
-rw-r--r--    1 root     root           104 Jan  1  1970 inittab
drwxr-xr-x    2 root     root          4096 Dec 27 07:29 lighttpd
drwxr-xr-x    2 root     root          4096 Dec 27 05:56 modules-boot.d
drwxr-xr-x    2 root     root          4096 Dec 27 05:56 modules.d
lrwxrwxrwx    1 root     root            12 Dec 27 05:56 mtab -> /proc/mounts
drwx------    2 root     root          4096 Dec 27 05:56 openvpn
-rw-r--r--    1 root     root           163 Dec 20 09:14 opkg.conf
-rw-r--r--    1 root     root           190 Dec 29 00:35 passwd
-rw-r--r--    1 root     root           190 Jan  1  1970 passwd-
drwxr-xr-x    4 root     root          4096 Dec 27 05:56 ppp
-rw-r--r--    1 root     root           128 Dec 20 07:12 pptpd.conf
-rwxr-xr-x    1 root     root           888 Jul 23 18:38 preinit
-rw-r--r--    1 root     root           518 Dec 27 02:21 profile
-rw-r--r--    1 root     root          2478 Mar 21  2011 protocols
-rwxr-xr-x    1 root     root          1490 Nov  9 21:52 rc.common
drwxr-xr-x    2 root     root          4096 Dec 27 08:30 rc.d
-rw-r--r--    1 root     root           132 Mar 21  2011 rc.local
lrwxrwxrwx    1 root     root            16 Dec 27 05:56 resolv.conf -> /tmp/resolv.conf
-rw-r--r--    1 root     root          3001 Mar 21  2011 services
-rw-r--r--    1 root     root           186 Dec 29 00:35 shadow
-rw-r--r--    1 root     root           149 Jan  1  1970 shadow-
-rw-r--r--    1 root     root             9 Mar 21  2011 shells
-rw-r--r--    1 root     root           976 Sep 19 05:24 sysctl.conf
-rw-r--r--    1 root     root           128 Mar 21  2011 sysupgrade.conf
drwxr-xr-x    2 root     root          4096 Jan  1  1970 uci-defaults
drwxr-xr-x    2 root     root          4096 Dec 29 00:33 vsftpd
-rw-r--r--    1 root     root           488 Dec 29 00:33 vsftpd.conf
 
root@OpenWrt:/etc# cat /etc/passwd
root:x:0:0:root:/root:/bin/ash
daemon:*:1:1:daemon:/var:/bin/false
ftp:x:55:55:ftp:/home/ftp:/bin/false
network:*:101:101:network:/var:/bin/false
nobody:*:65534:65534:nobody:/var:/bin/false
 
root@OpenWrt:/etc# cat /etc/shadow
root:$1$kzAg4U0J$F27Nb/oEdcgd7lU3xffGdi/:0:0:99999:7:::
daemon:*:0:0:99999:7:::
ftp:$1$Wp92U.qZ$j9zEwEQ0q6eEt/Sl45XJz1:15337:0:99999:7:::
network:*:0:0:99999:7:::
nobody:*:0:0:99999:7:::
root@OpenWrt:/etc# 

10) ntp를 이용한 라우터의 시간 맞추기
/etc/TZ에 설정된 UTC 시간을 GMT-9 Seoul 시간으로  변경한다.

root@OpenWrt:~# cat /etc/TZ
UTC
root@OpenWrt:~# date
Thu Dec 29 05:25:50 UTC 2011
root@OpenWrt:~# echo GMT-09 > /etc/TZ
root@OpenWrt:~# cat /etc/TZ
GMT-09 
root@OpenWrt:~# date
Thu Dec 29 14:26:15 GMT 2011

영구적인 변경을 위해서는, /etc/config/system 설정파일을 다음과 같이 변경한다.
time server들을 아래와 같이 설정하면 된다.
 
root@OpenWrt:~# cd /etc/
root@OpenWrt:/etc# cd config
root@OpenWrt:/etc/config# vi system

config 'system'
        option 'hostname' 'OpenWrt'
        option 'timezone' 'GMT-9' 

config 'timeserver' 'ntp'
        list 'server' 'time.kriss.re.kr'
        list 'server' '3.kr.pool.ntp.org'
        list 'server' '3.asia.pool.ntp.org'
        list 'server' '0.asia.pool.ntp.org'
        list 'server' '0.openwrt.pool.ntp.org'
        list 'server' '1.openwrt.pool.ntp.org'
        list 'server' '2.openwrt.pool.ntp.org'
        list 'server' '3.openwrt.pool.ntp.org'

...
<중략>
...
------------------------------------------------------------

추가적으로 ssh 포트번호를 8080번으로 변경하고,
방화벽에서 8080번을 외부접속 가능하도록 풀어주면, 완벽할 것으로 예상.

Posted by 훅크선장
, |

###############################################
# Sample OpenVPN 2.0 uci config for             #
# multi-client server.                          #
#################################################

config openvpn sample_server

        # Set to 1 to enable this instance:
        option enable 1

        # Which local IP address should OpenVPN
        # listen on? (optional)
#       option local 0.0.0.0

        # Which TCP/UDP port should OpenVPN listen on?
        # If you want to run multiple OpenVPN instances
        # on the same machine, use a different port
        # number for each one.  You will need to
        # open up this port on your firewall.
        option port 1194

        # TCP or UDP server?
        option proto tcp

        option route_up /etc/openvpn/server.up
        
        # "dev tun" will create a routed IP tunnel,
        # "dev tap" will create an ethernet tunnel.
        # Use "dev tap0" if you are ethernet bridging
        # and have precreated a tap0 virtual interface
        # and bridged it with your ethernet interface.
        # If you want to control access policies
        # over the VPN, you must create firewall
        # rules for the the TUN/TAP interface.
        # On non-Windows systems, you can give
        # an explicit unit number, such as tun0.
        # On Windows, use "dev-node" for this.
        # On most systems, the VPN will not function
        # unless you partially or fully disable
        # the firewall for the TUN/TAP interface.
        option dev tun

        # SSL/TLS root certificate (ca), certificate
        # (cert), and private key (key).  Each client
        # and the server must have their own cert and
        # key file.  The server and all clients will
        # use the same ca file.
        #
        # See the "easy-rsa" directory for a series
        # of scripts for generating RSA certificates
        # and private keys.  Remember to use
        # a unique Common Name for the server
        # and each of the client certificates.
        #
        # Any X509 key management system can be used.
        # OpenVPN can also use a PKCS #12 formatted key file
        # (see "pkcs12" directive in man page).
        option ca /etc/easy-rsa/keys/ca.crt
        option cert /etc/easy-rsa/keys/mail.crt
        # This file should be kept secret:
        option key /etc/easy-rsa/keys/mail.key

        # Diffie hellman parameters.
        # Generate your own with:
        #   openssl dhparam -out dh1024.pem 1024
        # Substitute 2048 for 1024 if you are using
        # 2048 bit keys.
        option dh /etc/easy-rsa/keys/dh1024.pem

        # Configure server mode and supply a VPN subnet
        # for OpenVPN to draw client addresses from.
        # The server will take 10.8.0.1 for itself,
        # the rest will be made available to clients.
        # Each client will be able to reach the server
        # on 10.8.0.1. Comment this line out if you are
        # ethernet bridging. See the man page for more info.
        option server "10.8.0.0 255.255.255.0"

        # Maintain a record of client <-> virtual IP address
        # associations in this file.  If OpenVPN goes down or
        # is restarted, reconnecting clients can be assigned
        # the same virtual IP address from the pool that was
        # previously assigned.
        option ifconfig_pool_persist /etc/openvpn/ipp.txt

        # Configure server mode for ethernet bridging.
        # You must first use your OS's bridging capability
        # to bridge the TAP interface with the ethernet
        # NIC interface.  Then you must manually set the
        # IP/netmask on the bridge interface, here we
        # assume 10.8.0.4/255.255.255.0.  Finally we
        # must set aside an IP range in this subnet
        # (start=10.8.0.50 end=10.8.0.100) to allocate
        # to connecting clients.  Leave this line commented
        # out unless you are ethernet bridging.
#       option server_bridge "10.8.0.4 255.255.255.0 10.8.0.50 10.8.0.100"

        # Push routes to the client to allow it
        # to reach other private subnets behind
        # the server.  Remember that these
        # private subnets will also need
        # to know to route the OpenVPN client
        # address pool (10.8.0.0/255.255.255.0)
        # back to the OpenVPN server.
        list push "route 10.0.0.0 255.255.255.0"
    #PUSH
    
    
        # To assign specific IP addresses to specific
        # clients or if a connecting client has a private
        # subnet behind it that should also have VPN access,
        # use the subdirectory "ccd" for client-specific
        # configuration files (see man page for more info).

        # EXAMPLE: Suppose the client
        # having the certificate common name "Thelonious"
        # also has a small subnet behind his connecting
        # machine, such as 192.168.40.128/255.255.255.248.
        # First, uncomment out these lines:
       option client_config_dir /etc/openvpn/ccd
       list route "192.168.2.0 255.255.255.0"
        # Then create a file ccd/Thelonious with this line:
        #   iroute 192.168.40.128 255.255.255.248
        # This will allow Thelonious' private subnet to
        # access the VPN.  This example will only work
        # if you are routing, not bridging, i.e. you are
        # using "dev tun" and "server" directives.

        # EXAMPLE: Suppose you want to give
        # Thelonious a fixed VPN IP address of 10.9.0.1.
        # First uncomment out these lines:
#       option client_config_dir /etc/openvpn/ccd
#       list route "10.9.0.0 255.255.255.252"
#       list route "192.168.100.0 255.255.255.0"
        # Then add this line to ccd/Thelonious:
        #   ifconfig-push "10.9.0.1 10.9.0.2"

        # Suppose that you want to enable different
        # firewall access policies for different groups
        # of clients.  There are two methods:
        # (1) Run multiple OpenVPN daemons, one for each
        #     group, and firewall the TUN/TAP interface
        #     for each group/daemon appropriately.
        # (2) (Advanced) Create a script to dynamically
        #     modify the firewall in response to access
        #     from different clients.  See man
        #     page for more info on learn-address script.
#       option learn_address /etc/openvpn/script

        # If enabled, this directive will configure
        # all clients to redirect their default
        # network gateway through the VPN, causing
        # all IP traffic such as web browsing and
        # and DNS lookups to go through the VPN
        # (The OpenVPN server machine may need to NAT
        # the TUN/TAP interface to the internet in
        # order for this to work properly).
        # CAVEAT: May break client's network config if
        # client's local DHCP server packets get routed
        # through the tunnel.  Solution: make sure
        # client's local DHCP server is reachable via
        # a more specific route than the default route
        # of 0.0.0.0/0.0.0.0.
#       list push "redirect-gateway"

        # Certain Windows-specific network settings
        # can be pushed to clients, such as DNS
        # or WINS server addresses.  CAVEAT:
        # http://openvpn.net/faq.html#dhcpcaveats
#       list push "dhcp-option DNS 10.8.0.1"
#       list push "dhcp-option WINS 10.8.0.1"

        # Uncomment this directive to allow different
        # clients to be able to "see" each other.
        # By default, clients will only see the server.
        # To force clients to only see the server, you
        # will also need to appropriately firewall the
        # server's TUN/TAP interface.
       option client_to_client 1

        # Uncomment this directive if multiple clients
        # might connect with the same certificate/key
        # files or common names.  This is recommended
        # only for testing purposes.  For production use,
        # each client should have its own certificate/key
        # pair.
        #
        # IF YOU HAVE NOT GENERATED INDIVIDUAL
        # CERTIFICATE/KEY PAIRS FOR EACH CLIENT,
        # EACH HAVING ITS OWN UNIQUE "COMMON NAME",
        # UNCOMMENT THIS LINE OUT.
#       option duplicate_cn 1

        # The keepalive directive causes ping-like
        # messages to be sent back and forth over
        # the link so that each side knows when
        # the other side has gone down.
        # Ping every 10 seconds, assume that remote
        # peer is down if no ping received during
        # a 120 second time period.
        option keepalive "10 120"

        # For extra security beyond that provided
        # by SSL/TLS, create an "HMAC firewall"
        # to help block DoS attacks and UDP port flooding.
        #
        # Generate with:
        #   openvpn --genkey --secret ta.key
        #
        # The server and each client must have
        # a copy of this key.
        # The second parameter should be '0'
        # on the server and '1' on the clients.
        # This file is secret:
#       option tls_auth "/etc/openvpn/ta.key 0"

        # Select a cryptographic cipher.
        # This config item must be copied to
        # the client config file as well.
        # Blowfish (default):
       option cipher BF-CBC
        # AES:
#       option cipher AES-128-CBC
        # Triple-DES:
#       option cipher DES-EDE3-CBC

        # Enable compression on the VPN link.
        # If you enable it here, you must also
        # enable it in the client config file.
        option comp_lzo 1

        # The maximum number of concurrently connected
        # clients we want to allow.
#       option max_clients 100

        # The persist options will try to avoid
        # accessing certain resources on restart
        # that may no longer be accessible because
        # of the privilege downgrade.
        option persist_key 1
#        option persist_tun 1

        # Output a short status file showing
        # current connections, truncated
        # and rewritten every minute.
        option status /tmp/openvpn-status.log

        # By default, log messages will go to the syslog (or
        # on Windows, if running as a service, they will go to
        # the "\Program Files\OpenVPN\log" directory).
        # Use log or log-append to override this default.
        # "log" will truncate the log file on OpenVPN startup,
        # while "log-append" will append to it.  Use one
        # or the other (but not both).
#       option log         /tmp/openvpn.log
#       option log_append  /tmp/openvpn.log

        # Set the appropriate level of log
        # file verbosity.
        #
        # 0 is silent, except for fatal errors
        # 4 is reasonable for general usage
        # 5 and 6 can help to debug connection problems
        # 9 is extremely verbose
        option verb 4

        # Silence repeating messages.  At most 20
        # sequential messages of the same message
        # category will be output to the log.
#       option mute 20

Posted by 훅크선장
, |
1. USB 메모리스틱의 파티션 생성
usb 메모리스틱을 openwrt에 꽂은 후의 로그는 다음과 같이 인식되어야 한다.

root@OpenWrt:/etc# logread
...
Dec 27 05:32:27 OpenWrt kern.info kernel: [ 2178.370000] usb 1-2: new high speed USB device number 3 using ar71xx-ehci
Dec 27 05:32:27 OpenWrt kern.info kernel: [ 2178.530000] scsi1 : usb-storage 1-2:1.0
Dec 27 05:32:28 OpenWrt kern.notice kernel: [ 2179.530000] scsi 1:0:0:0: Direct-Access     Generic  Flash Disk       8.07 PQ: 0 ANSI: 2
Dec 27 05:32:28 OpenWrt kern.notice kernel: [ 2179.540000] sd 1:0:0:0: [sda] 1978368 512-byte logical blocks: (1.01 GB/966 MiB)
Dec 27 05:32:28 OpenWrt kern.notice kernel: [ 2179.550000] sd 1:0:0:0: [sda] Write Protect is off
Dec 27 05:32:28 OpenWrt kern.debug kernel: [ 2179.550000] sd 1:0:0:0: [sda] Mode Sense: 03 00 00 00
Dec 27 05:32:28 OpenWrt kern.err kernel: [ 2179.550000] sd 1:0:0:0: [sda] Assuming drive cache: write through
Dec 27 05:32:28 OpenWrt kern.err kernel: [ 2179.560000] sd 1:0:0:0: [sda] Assuming drive cache: write through
Dec 27 05:32:29 OpenWrt kern.info kernel: [ 2179.860000]  sda:
Dec 27 05:32:29 OpenWrt kern.err kernel: [ 2179.860000] sd 1:0:0:0: [sda] Assuming drive cache: write through
Dec 27 05:32:29 OpenWrt kern.notice kernel: [ 2179.870000] sd 1:0:0:0: [sda] Attached SCSI removable disk

usb 메모리스틱은 /dev/sda 라는 디바이스명으로 인식되었다.

해당 디바이스의 파티션을 확인한다.

root@OpenWrt:/etc# fdisk -l /dev/sda

Disk /dev/sda: 1012 MB, 1012924416 bytes
32 heads, 61 sectors/track, 1013 cylinders
Units = cylinders of 1952 * 512 = 999424 bytes
Disk identifier: 0xb0bcd68e

   Device Boot      Start         End      Blocks   Id  System
root@OpenWrt:/etc# 

디스크 확장을 위한 공간을 생성한다.
스왑공간도 생성한다.

root@OpenWrt:/etc# fdisk  /dev/sda

Command (m for help): p

Disk /dev/sda: 1012 MB, 1012924416 bytes
32 heads, 61 sectors/track, 1013 cylinders
Units = cylinders of 1952 * 512 = 999424 bytes
Disk identifier: 0xb0bcd68e

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1013, default 1): 
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1013, default 1013): 913

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (914-1013, default 914): 
Using default value 914
Last cylinder or +size or +sizeM or +sizeK (914-1013, default 1013): 
Using default value 1013

Command (m for help): p

Disk /dev/sda: 1012 MB, 1012924416 bytes
32 heads, 61 sectors/track, 1013 cylinders
Units = cylinders of 1952 * 512 = 999424 bytes
Disk identifier: 0xb0bcd68e

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1         913      891057+  83  Linux
/dev/sda2             914        1013       97600   83  Linux

Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes): 82
Changed system type of partition 2 to 82 (Linux swap / Solaris)

Command (m for help): p

Disk /dev/sda: 1012 MB, 1012924416 bytes
32 heads, 61 sectors/track, 1013 cylinders
Units = cylinders of 1952 * 512 = 999424 bytes
Disk identifier: 0xb0bcd68e

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1         913      891057+  83  Linux
/dev/sda2             914        1013       97600   82  Linux swap / Solaris

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
root@OpenWrt:/etc# fdisk -l /dev/sda

Disk /dev/sda: 1012 MB, 1012924416 bytes
32 heads, 61 sectors/track, 1013 cylinders
Units = cylinders of 1952 * 512 = 999424 bytes
Disk identifier: 0xb0bcd68e

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1         913      891057+  83  Linux
/dev/sda2             914        1013       97600   82  Linux swap / Solaris
root@OpenWrt:/etc# 

2. 파티션에 리눅스 파일시스템 생성
스왑공간을 활성화하고, 파티션에 리눅스 파일시스템을 생성한다.

먼저 리눅스 파일시스템 생성을 위한 프로그램을 설치해야 한다.

root@OpenWrt:/etc# opkg list-installed|grep fs
kmod-fs-ext4 - 2.6.39.4-1
libext2fs - 1.41.12-2
root@OpenWrt:/etc# opkg install e2fsprogs
Installing e2fsprogs (1.41.12-2) to root...
Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/e2fsprogs_1.41.12-2_ar71xx.ipk.
Configuring e2fsprogs.
root@OpenWrt:/etc# sync
root@OpenWrt:/etc# opkg files e2fsprogs
Package e2fsprogs (1.41.12-2) is installed on root and has the following files:
/usr/sbin/mkfs.ext2
/usr/sbin/mkfs.ext3
/usr/sbin/mkfs.ext4
/usr/lib/libe2p.so.2
/lib/functions/fsck/e2fsck.sh
/usr/sbin/e2fsck
/etc/e2fsck.conf
/usr/sbin/mke2fs
/usr/lib/libe2p.so.2.3
root@OpenWrt:/etc# 

리눅스 파일시스템을 생성한다.

root@OpenWrt:/etc# mkfs.ext4 /dev/sda1
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
55776 inodes, 222764 blocks
11138 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=230686720
7 block groups
32768 blocks per group, 32768 fragments per group
7968 inodes per group
Superblock backups stored on blocks: 
32768, 98304, 163840

Writing inode tables: done                            
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 21 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

3. 파일시스템 마운트와 운영체제 파일 복사
usb 메모리스틱에 파일시스템이 정상적으로 생성되었는지를 확인한다.
스왑영역을 활성화하고,

/mnt/root 라는 디렉토리를 만들어서, 그곳에 새로운 파일시스템 공간을 마운트시킨다.

root@OpenWrt:/etc# swapon /dev/sda2
root@OpenWrt:/etc# mount
rootfs on / type rootfs (rw)
/dev/root on / type jffs2 (rw,noatime)
proc on /proc type proc (rw,noatime)
sysfs on /sys type sysfs (rw,noatime)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noatime,size=30964k)
tmpfs on /dev type tmpfs (rw,noatime,size=512k,mode=755)
devpts on /dev/pts type devpts (rw,noatime,mode=600)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
none on /proc/bus/usb type usbfs (rw,relatime)
root@OpenWrt:/etc# ll /mnt
drwxr-xr-x    2 root     root             0 Dec 19 21:57 .
drwxr-xr-x   17 root     root             0 Jan  1  1970 ..
root@OpenWrt:/etc# mkdir -p /mnt/root/
root@OpenWrt:/etc# ll /mnt
drwxr-xr-x    3 root     root             0 Dec 27 05:52 .
drwxr-xr-x   17 root     root             0 Jan  1  1970 ..
drwxr-xr-x    2 root     root             0 Dec 27 05:52 root
root@OpenWrt:/etc# mount -t ext4 /dev/sda1 /mnt/root
root@OpenWrt:/etc# mount
rootfs on / type rootfs (rw)
/dev/root on / type jffs2 (rw,noatime)
proc on /proc type proc (rw,noatime)
sysfs on /sys type sysfs (rw,noatime)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noatime,size=30964k)
tmpfs on /dev type tmpfs (rw,noatime,size=512k,mode=755)
devpts on /dev/pts type devpts (rw,noatime,mode=600)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
none on /proc/bus/usb type usbfs (rw,relatime)
/dev/sda1 on /mnt/root type ext4 (rw,relatime,user_xattr,barrier=1,data=ordered)

기존의 파일시스템을 확장된 디스크 영역으로 복사한다.

root@OpenWrt:~# cd /mnt
root@OpenWrt:/mnt# ll
drwxr-xr-x    3 root     root             0 Dec 27 05:52 .
drwxr-xr-x   17 root     root             0 Jan  1  1970 ..
drwxr-xr-x    3 root     root          4096 Dec 27 05:45 root
root@OpenWrt:/mnt#  tar cvO -C / bin/ etc/ root/ lib/ sbin/ usr/ www/ var/ | tar x -C /mnt/root
bin/
bin/dd
bin/cp
bin/df
bin/ln
bin/ls
bin/mv
bin/ps
bin/rm
bin/sh
bin/vi

... 중략 ...

usr/sbin/chroot
usr/sbin/mkfs.ext2
usr/sbin/mkfs.ext3
usr/sbin/mkfs.ext4
usr/sbin/iwlist
usr/sbin/iwpriv
usr/sbin/pptpctrl
usr/sbin/mke2fs
usr/sbin/fw_printenv
usr/sbin/bcrelay
usr/sbin/openvpn
usr/sbin/wpa_supplicant
usr/share/
usr/share/udhcpc/
usr/share/udhcpc/default.script
www/
var
root@OpenWrt:/mnt# mkdir -p /mnt/root/tmp && mkdir -p /mnt/root/dev && mkdir -p /mnt/root/proc && mkdir -p /mnt
/root/jffs && mkdir -p /mnt/root/mnt/openwrt && mkdir -p /mnt/root/sys
root@OpenWrt:/mnt# ll
drwxr-xr-x    3 root     root             0 Dec 27 05:52 .
drwxr-xr-x   17 root     root             0 Jan  1  1970 ..
drwxr-xr-x   16 root     root          4096 Dec 27 05:57 root
root@OpenWrt:/mnt# ll ./root/
drwxr-xr-x   16 root     root          4096 Dec 27 05:57 .
drwxr-xr-x    3 root     root             0 Dec 27 05:52 ..
drwxr-xr-x    2 root     root          4096 Dec 27 05:56 bin
drwxr-xr-x    2 root     root          4096 Dec 27 05:57 dev
drwxr-xr-x   14 root     root          4096 Dec 27 05:56 etc
drwxr-xr-x    2 root     root          4096 Dec 27 05:57 jffs
drwxr-xr-x   12 root     root          4096 Dec 27 05:56 lib
drwx------    2 root     root         16384 Dec 27 05:45 lost+found
drwxr-xr-x    3 root     root          4096 Dec 27 05:57 mnt
drwxr-xr-x    2 root     root          4096 Dec 27 05:57 proc
drwxr-xr-x    2 root     root          4096 Dec 27 05:56 root
drwxr-xr-x    2 root     root          4096 Dec 27 05:56 sbin
drwxr-xr-x    2 root     root          4096 Dec 27 05:57 sys
drwxr-xr-x    2 root     root          4096 Dec 27 05:57 tmp
drwxr-xr-x    6 root     root          4096 Dec 27 05:56 usr
lrwxrwxrwx    1 root     root             4 Dec 27 05:56 var -> /tmp
drwxr-xr-x    2 root     root          4096 Dec 19 21:57 www
root@OpenWrt:/mnt# 

4. 부팅 스크립트 수정
다음으로, 부팅스트립트 조정하기
/etc/init.d/rcS 스크립트에 루트 파일시스템을 변경하는 내용 추가

root@OpenWrt:/etc# cd /etc/init.d
root@OpenWrt:/etc/init.d# ll
drwxr-xr-x    2 root     root             0 Dec 19 21:58 .
drwxr-xr-x   14 root     root             0 Dec 27 05:44 ..
-rwxr-xr-x    1 root     root          3263 Nov 18 00:28 boot
-rwxr-xr-x    1 root     root           385 Dec 19 22:02 cron
-rwxr-xr-x    1 root     root           318 Nov  9 21:52 defconfig
-rwxr-xr-x    1 root     root         10032 Dec 19 22:04 dnsmasq
-rwxr-xr-x    1 root     root           318 Mar 21  2011 done
-rwxr-xr-x    1 root     root          4367 Dec 19 22:05 dropbear
-rwxr-xr-x    1 root     root           233 Dec 19 22:06 firewall
-rwxr-xr-x    1 root     root          2004 Dec 19 22:01 fstab
-rwxr-xr-x    1 root     root          1570 Mar 21  2011 led
-rwxr-xr-x    1 root     root           641 Nov  5 23:38 network
-rwxr-xr-x    1 root     root          4657 Dec 19 22:14 openvpn
-rwxr-xr-x    1 root     root           375 Dec 20 07:12 pptpd
-rwxr-xr-x    1 root     root           454 Mar 21  2011 rcS
-rwxr-xr-x    1 root     root           126 Mar 21  2011 sysctl
-rwxr-xr-x    1 root     root           505 Nov  9 21:52 sysntpd
-rwxr-xr-x    1 root     root           878 Dec 19 22:02 telnet
-rwxr-xr-x    1 root     root           673 Dec 20 09:34 uboot-envtools
-rwxr-xr-x    1 root     root            99 Mar 21  2011 umount
-rwxr-xr-x    1 root     root           154 Mar 21  2011 usb
-rwxr-xr-x    1 root     root           244 Nov  9 21:52 watchdog
root@OpenWrt:/etc/init.d# vi rcS
#!/bin/sh
# Copyright (C) 2006 OpenWrt.org

run_scripts() {
        for i in /etc/rc.d/$1*; do
                [ -x $i ] && $i $2 2>&1
        done | $LOGGER
}

system_config() {
        config_get_bool foreground $1 foreground 0
}

LOGGER="cat"
[ -x /usr/bin/logger ] && LOGGER="logger -s -p 6 -t sysinit"

#--------------------------------------------------------------------                                 
# Switch to pivoroot if available
#                                                        
if [ "$2" == "boot" -a -x /etc/init.d/pivotroot ] ; then            
      echo "[`date`]: Pivot root log created." > /tmp/pivotroot.log 
      /etc/init.d/pivotroot >> /tmp/pivotroot.log 
fi                                             
#--------------------------------------------------------------------
                                   
. /etc/functions.sh                            
                                               
config_load system                 
config_foreach system_config system            
                                               
if [ "$1" = "S" -a "$foreground" != "1" ]; then
        run_scripts "$1" "$2" &
else                         
        run_scripts "$1" "$2"
fi
~
root@OpenWrt:/etc/init.d# 

/etc/init.d/ 디렉토리 밑에 pivotroot 라는 이름으로 다음 내용을 작성하고,

root@OpenWrt:/etc/init.d# vi pivotroot
                                                                               
    if [ -z $DRIVE ]; then                                                     
        echo No partitions, skipping pivotroot                                 
    else                                      
        umount $DRIVE                         
        e2fsck -p $DRIVE                      
        fsstat=$?                             
        echo e2fsck status is $fsstat
        if [ $fsstat -eq 2 ]; then   
            echo Corrected errors on $DRIVE, need to reboot
            sleep 5                                        
            reboot                                         
        elif [ $fsstat -eq 1 ]; then                       
            echo Corrected errors on $DRIVE                
        elif [ $fsstat -gt 2 ]; then       
            echo No usable filesystem on $DRIVE
        fi                                     
        echo Mounting $DRIVE                   
        mount -t ext4 $DRIVE /mnt/openwrt      
        mt=$?                                  
        if [ $mt -eq 0 ]; then           
            if [ -x /mnt/openwrt/sbin/init -a -d /mnt/openwrt/jffs -a -d /mnt/openwrt/mnt/openwrt ]; then
                echo Found OpenWRT root on $DRIVE                                                        
            # Side-effect - leave /mnt/openwrt mounted                                                   
            else                                                                                         
                echo "Missing /sbin/init, /jffs, or /mnt/openwrt (mount status was $mt)"                 
                [ -x /mnt/openwrt/sbin/init ] || echo Failed -x /sbin/init              
                [ -d /mnt/openwrt/mnt/openwrt ]     || echo Failed -x /mnt/openwrt      
                [ -d /mnt/openwrt/jffs ]      || echo Failed -x /jffs                   
                umount $DRIVE                                                           
            fi                                                                    
        else                                                                      
            echo mount status is $mt                                 
        fi                          
    fi                              
    #if everything looks ok, do the pivot root
    [ -x /mnt/openwrt/sbin/init ] && {        
        mount -o move /proc /mnt/openwrt/proc && \
        pivot_root /mnt/openwrt /mnt/openwrt/mnt/openwrt && {
            mount -o move /mnt/openwrt/dev /dev              
            mount -o move /mnt/openwrt/tmp /tmp              
            mount -o move /mnt/openwrt/jffs2 /jffs2 2>&-     
            mount -o move /mnt/openwrt/sys /sys 2>&-         
        }                                               
    }                                                   
                                                        
root@OpenWrt:/etc/init.d# sync
root@OpenWrt:/etc/init.d# ll
drwxr-xr-x    2 root     root             0 Dec 27 06:07 .
drwxr-xr-x   14 root     root             0 Dec 27 05:44 ..
-rwxr-xr-x    1 root     root          3263 Nov 18 00:28 boot
-rwxr-xr-x    1 root     root           385 Dec 19 22:02 cron
-rwxr-xr-x    1 root     root           318 Nov  9 21:52 defconfig
-rwxr-xr-x    1 root     root         10032 Dec 19 22:04 dnsmasq
-rwxr-xr-x    1 root     root           318 Mar 21  2011 done
-rwxr-xr-x    1 root     root          4367 Dec 19 22:05 dropbear
-rwxr-xr-x    1 root     root           233 Dec 19 22:06 firewall
-rwxr-xr-x    1 root     root          2004 Dec 19 22:01 fstab
-rwxr-xr-x    1 root     root          1570 Mar 21  2011 led
-rwxr-xr-x    1 root     root           641 Nov  5 23:38 network
-rwxr-xr-x    1 root     root          4657 Dec 19 22:14 openvpn
-rw-r--r--    1 root     root          2110 Dec 27 06:14 pivotroot
-rwxr-xr-x    1 root     root           375 Dec 20 07:12 pptpd
-rwxr-xr-x    1 root     root           669 Dec 27 06:03 rcS
-rwxr-xr-x    1 root     root           126 Mar 21  2011 sysctl
-rwxr-xr-x    1 root     root           505 Nov  9 21:52 sysntpd
-rwxr-xr-x    1 root     root           878 Dec 19 22:02 telnet
-rwxr-xr-x    1 root     root           673 Dec 20 09:34 uboot-envtools
-rwxr-xr-x    1 root     root            99 Mar 21  2011 umount
-rwxr-xr-x    1 root     root           154 Mar 21  2011 usb
-rwxr-xr-x    1 root     root           244 Nov  9 21:52 watchdog

pivotroot 파일에 실행권한을 부여한다.

root@OpenWrt:/etc/init.d# chmod 755 pivotroot 

위의 파일시스템 변경 스크립트에서 기본 마운트 포인트가 /mnt/openwrt 로 되어있다.

기존에 마운트해서 파일을 사용했던. /mnt/root 폴더 대신에, /mnt/openwrt 로 이름을 변경한다.

root@OpenWrt:/etc/init.d# cd /mnt
root@OpenWrt:/mnt# mount
rootfs on / type rootfs (rw)
/dev/root on / type jffs2 (rw,noatime)
proc on /proc type proc (rw,noatime)
sysfs on /sys type sysfs (rw,noatime)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noatime,size=30964k)
tmpfs on /dev type tmpfs (rw,noatime,size=512k,mode=755)
devpts on /dev/pts type devpts (rw,noatime,mode=600)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
none on /proc/bus/usb type usbfs (rw,relatime)
/dev/sda1 on /mnt/root type ext4 (rw,relatime,user_xattr,barrier=1,data=ordered)
root@OpenWrt:/mnt# umount /dev/sda1
root@OpenWrt:/mnt# mount
rootfs on / type rootfs (rw)
/dev/root on / type jffs2 (rw,noatime)
proc on /proc type proc (rw,noatime)
sysfs on /sys type sysfs (rw,noatime)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noatime,size=30964k)
tmpfs on /dev type tmpfs (rw,noatime,size=512k,mode=755)
devpts on /dev/pts type devpts (rw,noatime,mode=600)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
none on /proc/bus/usb type usbfs (rw,relatime)

root@OpenWrt:/mnt# ll
drwxr-xr-x    3 root     root             0 Dec 27 06:15 .
drwxr-xr-x   17 root     root             0 Jan  1  1970 ..
drwxr-xr-x    2 root     root             0 Dec 27 05:52 root
root@OpenWrt:/mnt# mv root openwrt
root@OpenWrt:/mnt# ll
drwxr-xr-x    3 root     root             0 Dec 27 06:16 .
drwxr-xr-x   17 root     root             0 Jan  1  1970 ..
drwxr-xr-x    2 root     root             0 Dec 27 05:52 openwrt
root@OpenWrt:/mnt# sync

5. 부팅 파티션의 변경 완료 확인
공유기를 재부팅해서, 정상적으로 파일시스템이 이전되었는지를 확인한다.

root@OpenWrt:/mnt# sync
root@OpenWrt:/mnt# reboot
root@OpenWrt:/mnt# 
Connection closed by foreign host.

Type `help' to learn how to use Xshell prompt.
Xshell:\> 

Connecting to 192.168.43.1:8080...
Connection established.
Escape character is '^@]'.

sh: /usr/bin/X11/xauth: not found


BusyBox v1.19.3 (2011-12-19 15:01:26 MST) built-in shell (ash)
Enter 'help' for a list of built-in commands.

  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 ATTITUDE ADJUSTMENT (bleeding edge, r29570) ----------
  * 1/4 oz Vodka      Pour all ingredients into mixing
  * 1/4 oz Gin        tin with ice, strain into glass.
  * 1/4 oz Amaretto
  * 1/4 oz Triple sec
  * 1/4 oz Peach schnapps
  * 1/4 oz Sour mix
  * 1 splash Cranberry juice
 -----------------------------------------------------
root@OpenWrt:~# df -h
Filesystem                Size      Used Available Use% Mounted on
rootfs                  856.5M     27.0M    786.0M   3% /
/dev/root                 5.1M      4.2M    864.0K  83% /mnt/openwrt
tmpfs                    30.2M     76.0K     30.2M   0% /tmp
tmpfs                   512.0K         0    512.0K   0% /dev
/dev/sda1               856.5M     27.0M    786.0M   3% /
root@OpenWrt:~# cat /tmp/
.uci/               lock/               pivotroot.log       run/
TZ                  log/                resolv.conf         state/
dhcp.leases         openvpn-status.log  resolv.conf.auto    sysinfo/
root@OpenWrt:~# cat /tmp/pivotroot.log 
[Thu Jan  1 00:00:35 UTC 1970]: Pivot root log created.
/dev/sda1: clean, 840/55776 files, 10418/222764 blocks
e2fsck status is 0
Mounting /dev/sda1
Found OpenWRT root on /dev/sda1
root@OpenWrt:~# 

디스크 정보와 로그에서 완벽하게 이전되었음을 확인할 수 있다.

Posted by 훅크선장
, |
사설망 내부 서버들의 시간 동기화를 위해서, ntp 서버 데몬을 사용하는 방법입니다.

먼저 시간의 기준이 되는 서버를 선정합니다. 예로 그 서버가 192.168.100.15 라고 합니다.
그리고, 각 서버들이 192.168.100.x  네트워크에 속해있다고 가정합니다.

제일 우선적으로 모든 서버에 ntp 데몬을 설치하여야 합니다.
[root@localhost ~]# yum install ntp
Loaded plugins: dellsysid, fastestmirror
Loading mirror speeds from cached hostfile
 * base: centos.tt.co.kr
 * extras: centos.tt.co.kr치
 * updates: centos.tt.co.kr
base                                                                 | 2.1 kB     00:00     
dell-omsa-indep                                                      | 1.9 kB     00:00     
dell-omsa-specific                                                   | 1.9 kB     00:00     
extras                                                               | 2.1 kB     00:00     
updates                                                              | 1.9 kB     00:00     
updates/primary_db                                                   | 588 kB     00:00     
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package ntp.x86_64 0:4.2.2p1-9.el5.centos.2.1 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

============================================================================================
 Package        Arch              Version                             Repository       Size
============================================================================================
Installing:
 ntp            x86_64            4.2.2p1-9.el5.centos.2.1            base            1.3 M

Transaction Summary
============================================================================================
Install       1 Package(s)
Upgrade       0 Package(s)

Total download size: 1.3 M
Is this ok [y/N]: y
Downloading Packages:
ntp-4.2.2p1-9.el5.centos.2.1.x86_64.rpm                              | 1.3 MB     00:00     
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : ntp                                                                  1/1 

Installed:
  ntp.x86_64 0:4.2.2p1-9.el5.centos.2.1

설치가 완료되었으면, ntp 관련 설정을 하면 됩니다.
기존에 자동으로 설치되는 /etc/ntp.conf 에서 일부만 고치면 됩니다.

사설망내에서 시간의 기준이 되는 예로 192.168.100.15 번 서버는 /etc/ntp.conf 파일에서 다음 부분만 수정하여 설정합니다.
# Hosts on local network are less restricted.
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
restrict 192.168.100.0 mask 255.255.255.0 nomodify notrap # 로컬 서버들이 시간 정보를 가져갈 수 있도록, 접근제한을 풀어줍니다.

# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#server 0.rhel.pool.ntp.org  # 기존에 설정된 server 들을 모두 사용하지 않습니다.
#server 1.rhel.pool.ntp.org  # 오직 자체 시스템의 클럭만을 시간으로 사용합니다. (이 서버가 기준이므로,)
#server 2.rhel.pool.ntp.org

192.168.100.15 번 서버는 현재 사설망의 기준 시간이 되는 서버이므로, 오직 자체 시스템의 클럭만을 시간으로 사용합니다. 그러므로, /etc/ntp.conf 파일 내에서 server 라는 문구는 유일하게 다음 한 줄만 존재하여야 합니다.
server  127.127.1.0     # local clock

다음으로, 192.168.100.x 네트워크에 존재하는 다른 서버들은 기준 시간 서버로 192.168.100.15 서버를 사용하므로, /etc/ntp.conf 파일에서 다음 부분만 수정하여 설정합니다.

# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#server 0.rhel.pool.ntp.org  # 기존에 설정된 server 들을 모두 사용하지 않습니다.
#server 1.rhel.pool.ntp.org
#server 2.rhel.pool.ntp.org
server 192.168.100.15  # 사설망내 시간 기준 서버를 지정합니다.

기준 시간 서버인 192.168.100.15 서버와 192.168.100.x 네트워크에 존재하는 다른 서버들의 설정이 다른 것은 기준 서버를 제외한 다른 서버들은 별도로 시간 정보를 다른 쪽에 줄 필요가 없기 때문입니다.( 기준 서버와 동일하게, 접근제한을 풀어줘서 또 다른 기준 시간 서버로 사용할 수도 있습니다만, 관리자의 선택에 따르면 됩니다.)

설정이 완료되었으면, ntpd 서비스를 시작시키고, 매 시스템이 시작될 때마다 구동되도록 설정합니다.
[root@localhost ~]# service ntpd start
[root@localhost ~]# chkconfig ntpd on

ntpd 서비스가 정상적으로 동작하는지를 확인합니다.
[root@localhost ~]# ps -ef |grep ntp
ntp      23483     1  0 14:24 ?        00:00:00 ntpd -u ntp:ntp -p /var/run/ntpd.pid -g
root     24326 23151  0 15:10 pts/12   00:00:00 grep ntp
[root@localhost ~]#

ntpd 서비스가 시간을 정상적으로 동기화하고 있는 여부는 다음과 같이 확인합니다.
기준 시간 서버인 192.168.100.15 서버는 동기화 정보를 자기 자신뿐이므로, 결과가 다음과 같이 나타나고,
[root@localhost ~]# ntpq -pn
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*127.127.1.0     .LOCL.          10 l   19   64  377    0.000    0.000   0.001
[root@localhost ~]#

192.168.100.x 네트워크에 존재하는 다른 서버들은 기준 시간 서버인 192.168.100.15 서버를 참조하고 있기 때문에, 다음과 같이 결과가 출력됩니다.

[root@Server1 etc]# ntpq -pn
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*192.168..100.15  LOCAL(0)        11 u   47   64  377    0.156   16.448  14.100
 127.127.1.0     .LOCL.          10 l   40   64  377    0.000    0.000   0.001
[root@Server1 etc]#


Posted by 훅크선장
, |
OpenWRT에는 Klog와 syslogd가 모두 동작합니다만,
일반적인 리눅스 시스템과 같이 별도의 로그파일을 생성하지 않습니다. (디스크 공간이 없기 때문이죠~)
그래서, /var/log/messages 파일 같은 것은 없습니다.

대신, 메모리 공간에 약간의 버퍼를 만들어두고, 거기에 로그를 씁니다.
그 로그를 읽는 방법은 간단합니다. 그냥 logread 명령어를 쓰면 됩니다.

# logread
하면,

/var/log/messages 파일의 내용과 같은, OpenWRT의 시스템 로그가 보입니다.
Posted by 훅크선장
, |
설치를 하지 않고, 간단하게 바꾸고 싶다면, etherchange.exe
http://ntsecurity.nu/toolbox/etherchange/

설치를 하더라도, 자세한 정보를 보고 싶고 GUI 환경을 원하면, MAC Address Changer
http://www.technitium.com/tmac/index.html

개인적으로는 etherchange.exe가 훨씬 나은 듯하다.

무선랜카드의 MAC 주소 변경에도 아주 잘 동작한다.
Posted by 훅크선장
, |
예전에 소개한 적이 있는 BackTrack 4 R2 버전에서 지원되는 Ralink 사의  RT2870  칩셋을 사용하는 유니콘 정보통신의 TW-300N 802.11n USB 무선랜카드입니다. 외장 안테나가 없어서, 한번 개조해보기로 했습니다.
현재는 이 무선랜카드가 단종되어서 구할 수가 없기 때문에, 이 글이 참 쓸모 없을 수도 있습니다.
개조에 대한 아이디어는 여기서 얻었습니다.
http://tcom.tistory.com/41

엄밀하게 말하면, 칩셋은 RT2870의 이전 모델로 보이는 RT2770F 입니다.

먼저 외장입니다. 일반적인 USB 동글 비슷하게 생겼습니다.


외장 플라스틱 사이를 칼 등으로 비틀면, 바로 분해되고, 다음과 같은 기판이 등장합니다.


기판 위면을 보면, 선명한 글씨로 RT2770F 라는 글씨가 보입니다.
개조를 위해서는, 그림상에서 가장 구석(USB 커넥터에서 가장 먼쪽으로)에 파란색으로 선명한 사각형의 칩이 보입니다. 이것이 바로 내장 안테나입니다.


기판 아래면을 보면, 다른 것보다, 역시 내장 안테나가 하나 보입니다.
그림상에서 가장 구석(USB 커넥터에서 가장 먼쪽으로)에 파란색으로 선명한 사각형의 칩이 내장 안테나입니다.


내장 안테나가 두 개입니다만, 실험에 의한 경험과 문서 정보를 종합해서 보았을 때,
기판 위면의 내장 안테나는 TX/RX용으로 사용되며, 기판 아래면의 내장 안테나는 RX 용으로만 쓰이고, 기판 위면의 내장 안테나의 보조용입니다.

참고한 문서는 http://www.ralinktech.com/download.php?t=U0wyRnpjMlYwY3k4eU1EQTVMekEzTHpJNEwzQnliMlIxWTNRMk56STVOVEF3TnpBMkxuQmtaajA5UFZKVU1qY3dNRjh3TlY5dVpYZGZiR0Z6ZEdWemRDNWZPVEl3Qw%3D%3D 입니다.
문서 내용에 보면, TX0/RX0가 한 개의 안테나로 RX1이 또다른 안테나로 구성된 것을 볼 수 있습니다.

개조를 위해서 필요한 부품은 다음과 같습니다.
SMA(F)S/T_PCB_T
SMA-C-316  (이건, SMA 안에 있는 정심만 필요합니다.)


부품은 다음 링크의 부품사이트에서 구할 수 있으며, 오프라인으로도 구하기 어렵지 않을 것입니다.
http://www.devicemart.co.kr/mart7/search.php?sort=sim&cate_code=013&page=3&query=sma

필요한 공구는 다음과 같습니다.
전기인두, 무연납 , 롱노우즈 플라이어(소형)뿐입니다.
핀셋과 테스터기는 있으면 좋습니다. 안전한 납땜과 개조가 잘 되었는지를 확인하는 용도로~.

사진과 함께 글로 설명합니다.



1) 기판 위면에 있는 내장 안테나를 제거합니다. 파란색 사각형 칩 형태의 내장 안테나를 뜯어내야 합니다.
    양 측면을 인두로 가열하면서, 핀셋으로 집어내면, 그냥 바로 떨어집니다. 어렵지 않습니다.


2) SMA 커넥터를 만듭니다. 먼저 SMA(F)S/T_PCB_T를 분해합니다. 내부 심까지 모두다 분해해야 합니다.
왜냐하면, 일반적인 안테나들은 SMA 역심을 가진 Male 형태입니다. 그러면 연결되는 커넥터로 SMA 정심을 가진 Female 형태가 필요한데, 판매되는 부품은 SMA 역심을 가진 Female 형태이므로, 역심을 정심으로 교체하는 작업을 해야됩니다.
롱노우즈 플라이어(소형)을 가지고, 커넥터의 뒤 부분의 하얀 플라스틱 부분을 밀어내서, 내부 심부분을 빼냅니다.
그리고, 잘 조심스럽게, 하얀 플라스틱에서  역심을 뽑아냅니다.


2-1) 역심자리에 SMA-C-316의 정심을 꽂은 다음, 다시 조립합니다. 역시 롱노우즈 플라이어로 잘 밀어넣으면 됩니다.


2-2) 먼저 정심에 연장선을 납땜으로 연결했습니다. 정심에 연장선은 조립한 다음에 해도 상관없습니다.



3) 정심 교체가 된 SMA(F)S/T_PCB_T에서 정심부분에 구리선 연장을 납땜으로 해줍니다. 앞에서 조립하기 전에 미리 했습니다. (구리선은 어떤 종류든 전선의 피복을 벗긴 구리선이면 됩니다. 정심에 들어가려면, 상당히 가는 선을 사용해야 되겠지요~.)


4) 내장 안테나를 떼어낸 부분에, 정심 교체가 된 SMA(F)S/T_PCB_T를 장착합니다. 장착은 정심 연장된 부분이 안테나 선에 바로 닿을 수 있게 하면 됩니다. 안테나 선 부분은 기판쪽으로 연결된 선부분이 있는 곳 입니다.( 바깥쪽과 가까운 납땜지역은 아무것도 연결되어 있지 않습니다.) 이렇게 하면, 다리 한 쪽이 기판의 접지 구리선부분(노랗게 노출된 부분)과 맞닿게 됩니다. 아주 기판이 잘 구성되어 있군요.



5) 정심에 연장된 구리선 부분을 안테나 선 부분과 납땜하고, 기판의 접지 구리선과 커넥터 외부의 다리 한쪽도 납땜해줍니다. 글루건으로 커넥터가 움직이지 않게 고정해줍니다.(에폭시 접착제가 더 좋다고 합니다만, 가진 게 글루건뿐이라서...)



6) 외장 플라스틱을 외장 안테나에 맞게 대충 잘 잘라주면 됩니다.



7) 완성된 모습은 다음과 같습니다.
    유무선 공유기에 번들로 제공되는 안테나를 붙인 모습입니다. 더 좋은 안테나 또는 증폭기도 붙일 수 있습니다.




Posted by 훅크선장
, |
openvpn을 설치한다.

opkg update
opkg install kmod-fs-btrfs kmod-fs-ext2 kmod-fs-ext3 kmod-fs-ext4 kmod-fs-isofs kmod-fs-reiserfs kmod-fs-vfat  kmod-fs-xfs
opkg install kmod-nls-cp1250 kmod-nls-cp1251 kmod-nls-cp437 kmod-nls-cp775 kmod-nls-cp850 kmod-nls-cp852 kmod-nls-cp866 kmod-nls-iso8859-1 kmod-nls-iso8859-13 kmod-nls-iso8859-15 kmod-nls-iso8859-2 kmod-nls-koi8r kmod-nls-utf8
opkg install kmod-usb2 kmod-usb-storage kmod-usb-storage-extras block-hotplug block-mount hotplug2
opkg install --force-overwrite avahi-daemon bwm fdisk fping iftop ip iptables-utils kmod-ipv6 libnl lft lsof  luci-app-ntpc luci-app-openvpn luci-app-upnp luci-ssl miniupnpd mtr net-tools-hostname ngrep nmap ntpclient  openssh-client openvpn rsync screen snmpd sshfs tcpdump
이상 위에 있는 것들을 설치하는 것이, 다양한 네트워크 설정에 필요하다.

/etc/config/openvpn 파일을 다음과 같이 설정한다.
config 'openvpn' 'MyOpenVPNServer'
    option 'server' '10.100.200.0 255.255.255.0'
    option 'dev' 'tun0'
    option 'proto' 'tcp'
    option 'port' '1194'
    option 'keepalive' '10 120'
    option 'ca' '/etc/openvpn/ca.crt'
    option 'cert' '/etc/openvpn/cert.pem'
    option 'key' '/etc/openvpn/key.pem'
    option 'dh' '/etc/openvpn/dh.pem'
    option 'status' '/tmp/openvpn-status.log'
    option 'verb' '3'
    option 'enable' '1'

/etc/openvpn/ 폴더에 인증서 파일 4개를 복사해둔다.
ca.crt
cert.pem
key.pem
dh.pem

방화벽에서 접속을 위한 설정을 입력한다.
/etc/firewall.user 파일에 다음의 내용을 추가한다.

# OpenVPN Remote Access & Routing Rule
iptables -I INPUT 1 -p udp --dport 1194 -j ACCEPT
iptables -I INPUT 1 -p tcp --dport 1194 -j ACCEPT
iptables -I FORWARD 1 --source 10.100.200.0/24 -j ACCEPT
iptables -I FORWARD -i eth0 -o tun0 -j ACCEPT
iptables -I FORWARD -i tun0 -o eth0 -j ACCEPT
iptables -t nat -A POSTROUTING -s 10.100.200.0/24 -o eth0 -j MASQUERADE

방화벽은 공유기를 reboot 하거나, 위의 설정 명령어를 한번 실행시켜도 된다.

서비스를 시작한다.

/etc/init.d/openvpn enable
/etc/init.d/openvpn start

하면 완료된다.

Posted by 훅크선장
, |
http://blog.netnerds.net/2011/02/openwrt-pptpd-a-love-story/
에 나온 글이 있어서, 설정해서 테스트해보았습니다. (아이폰을 이용한 안전한 VPN 사용이 목적이었습니다.)

결론은 잘되는 것이었지만, 과정은 한 3시간 이상의 삽질이었습니다.

문제는 항상 라우팅과 공유기의 IP 대역인 것 같습니다.

설정파일 /etc/ppp/options.pptpd 에서
ms-dns 172.16.1.1
부분을 현재 공유기의 내부 LAN IP로 지정합니다.

그리고,
/etc/ppp/chap-secrets 파일에서 사용되는 IP 들은
#USERNAME  PROVIDER  PASSWORD  IPADDRESS
iphone  pptp-server     suprAdv4ncedPwd!       192.168.80.1
ipad    pptp-server     rlyAdv4ncedPwd!       192.168.80.11
hackbook        pptp-server     megaAdv4ncedPwd!       191.68.80.3
windows pptp-server     ttllyAdv4ncedPwd!       192.168.80.2
extra           pptp-server     megaAdv4ncedPwd! 192.68.80.4


192.168.80.x 대역을 사용하고 있는데,
여러분의 공유기가 IP 대역을 192.168.x.x 를 쓰는 게 대부분 일 것입니다.

그런 경우에는 반드시 다른 IP 대역을 사용하세요~. 
192.168.x.x 가 아니라, 아예 다른 사설 IP 대역을 그냥 아무거나 지정하세요~.
추천은 10.20.30.x 나 또는 172.16.101.x 등입니다.

위의 IP 설정때문에 무척 고생했습니다.
Posted by 훅크선장
, |