티스토리 툴바

블로그 이미지
훅크선장

카테고리

분류 전체보기 (259)
사진이야기 (23)
펭귄컴퓨팅 (71)
컴퓨터보안 (55)
절름발이 프로그래머 (59)
하드웨어개조 (4)
멀알려줄까 (32)
잡다한것들 (15)
Total162,538
Today51
Yesterday155

달력

« » 2012.01
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 31        

공지사항

태그목록

시리얼 Serial 통신용 모듈을 위한 케이블을 자작하다보니, 5V DC 전원을 3.3V DC 전원으로 바꿔야 하는 상황이 생겨서,
회로도를 구해서 자작하였습니다. (USB 에서 나오는 전원은 5V 인데, TTL 용 소켓 전원은 3.3V 이어야만 합니다, 전원 안 맞추면, 보드 칩이 타버리는 상황이 생길 수도 있습니다.)

두 가지 방법이 있습니다. 

먼저 LM3940을 이용하는 방법은  
http://www.ti.com/lit/ds/symlink/lm3940.pdf 
http://obs.carnegiescience.edu/instrumentation/ccd/parts/LM3940.pdf 
(LM3940 칩 데이터시트)
에서 보여주는 바와 같이, 1A 이하의 전류에서 사용할 수 있습니다.
LM3940 칩 하나와  0.47uF, 33uF 각 한 개의 커패시터로 만들어집니다.

다음은 LM317T 룰 이용하는 방법입니다.
http://miy-makeityourself.blogspot.com/2010/08/33v-regulated-voltage-supply.html

 

회로가 좀 더 복잡합니다만, 데이터시트에는 최대 1.5A 출력까지 보장한다고 나와있습니다.
필요부품은 LM317 칩 1개, 470/330/75 오옴 저항 각 1개, 100uF/10uF/0.1uF 커패시터 각 1개 입니다.

100nF 이 곧 0.1uF 입니다. 국내 시장에서는 100nF 이런 단위를 안 쓰더군요~. 
 
Posted by 훅크선장
실험용 전원을 만들다보니, 궁금한 점이 전압을 표시하고 있으면, 실수를 안하겠다 싶어서,
다음의 DC 레귤레이터를 구매했는데,

FND 전압표시 강하형(LM2596S) DC/DC 파워모듈 
http://www.devicemart.co.kr/goods/view.php?seq=30497


찾아보니, 자작할 수 있었다는 것이다.
사는 것이 싸기는 하지만, 하드웨어 해커에게는 자작이 기쁨?

http://embedded-lab.com/blog/?p=3096 
http://www.diy-electronic-projects.com/p215-Led-display-digital-Voltmeter 
http://electronics-diy.com/ICL7107_volt_meter.php 
http://www.rcgroups.com/forums/showthread.php?t=297811 
http://www.electronics-lab.com/projects/test/014/index.html 


 
Posted by 훅크선장
 http://kevtownsend.wordpress.com/2011/12/29/reaver-a-wifi-wps-cracking-tool/ 

공격 도구는 2주 전부터 공개되었고, 벌써 버전업이 빠르게 이루어지고 있습니다.
 http://code.google.com/p/reaver-wps/downloads/list 

WPS 취약점에 대한 상세 분석내용도 나왔습니다.
 http://sviehb.files.wordpress.com/2011/12/viehboeck_wps.pdf 

BackTrack에서 도구 설치 및 사용방법도 나왔습니다.
 http://www.theprojectxblog.net/setting-up-reaver-the-wifi-protected-setup-attack-tool/ 

아직, BackTrack 한글판에는 적용을 고려하고 있습니다. 도구의 안전성과 성능이 어느정도 되면,  넣는게 수순이 아닐까요??

아마도 BackTrack 5 R2 나 6 버전에는 포함되지 않을까 합니다.
 
Posted by 훅크선장
http://wiki.openwrt.org/toh/buffalo/wzr-hp-g300h
위 링크에 있는 내용대로, 버팔로 WZR-HP-G300NH 유무선 공유기의 시리얼 포트 디버깅에 성공하였습니다.


http://www.devicemart.co.kr/goods/view.php?seq=6185
위 링크의 UART-USB 보드를 구매하였지만, 입력 전압이 틀린 관계로 별수 없이 DC-DC 레귤레이터를 제작하여 연결하였습니다.

5V DC to 3.3V DC 레귤레이터는 LM317T 룰 이용하여 제작하였습니다.
제작방법은 다음 링크를 참조하였습니다.
http://miy-makeityourself.blogspot.com/2010/08/33v-regulated-voltage-supply.html


사진에 보이는 바와 같이, Molex 커넥터를 이용하여, 3단 연결을 해서, 약간 선이 길게 나오기는 했지만, 디버깅은 잘 되는 것 같습니다.

다음은 D-Link DIR-825를 시리얼 디버깅 시도할 차례입니다.
개봉박두~~.

다음은 시리얼 디버깅되는 내용을 캡쳐한 것입니다.
-------------------------------------------------------

BUFFALO U-BOOT Ver 1.07
AP83--539 (ar9100) U-boot 0.0.12
64 MB
Memory Test (address line)
Memory Test start(0x00000000) end(0x04000000) size(67108864)
Data line test start:0x00000000 pattern 0x00000001 0x00000003 0x00000007 0x0000000F 0x00000005 0x00000015 0x00000055 0xAAAAAAAA
Address line test start:0x00000000 len:0x4000000 pattern 0xAAAAAAAA 0x55555555 
Fill test patnum:5
fill Pattern 5555AAAA  Writing...   Reading...
fill Pattern AAAA5555  Writing...   Reading...
fill Pattern 0000FFFF  Writing...   Reading...
fill Pattern FFFF0000  Writing...   Reading...
fill Pattern AAAAAAAA  Writing...   Reading...
Top of RAM usable for U-Boot at: 84000000
Reserving 275k for U-Boot at: 83fb8000
Reserving 256k for malloc() at: 83f78000
Reserving 44 Bytes for Board Info at: 83f77fd4
Reserving 36 Bytes for Global Data at: 83f77fb0
Reserving 128k for boot params() at: 83f57fb0
Stack Pointer at: 83f57f98
Now running in RAM - U-Boot at: 83fb8000
Dev ID2:2222
Dev ID3:2201
Name: AMD-SPANSION Flash id: 0x1227E, Size: 33554432 bytes.
Flash: 32 MB
In:    serial
Out:   serial
Err:   serial
Memory Test
uboot use  83F57FB0 - 84000000
Memory Test start(80000000) end(83F00000) size(03F00000)
Pattern 00000000  Writing...  Reading...
Memory Test OK
### buf_ver=[1.07] U-Boot Ver.=[1.07]
### build_date(env)=[Dec 21 2009 - 10:37:11] build_date(bin)=[Dec 21 2009 - 10:37:11]
ag7100_enet_initialize...
: cfg1 0xf cfg2 0x7114
RTL8366 series driver, reading model-id...
  ID:0x6027, REV:0x6
rtl8366sr_phy_setup  ethUnit=0
Realtek 8366SR switch ID 0x8366
Realtek Greeen Ethernet Setup
eth0: 02:aa:bb:cc:dd:1a
eth0 up
: cfg1 0xf cfg2 0x7114
RTL8366 series driver, reading model-id...
eth1: 02:aa:bb:cc:dd:1a
eth1 up
eth0  02:AA:BB:CC:DD:1A
, eth1  02:AA:BB:CC:DD:1A

Trying eth0
eth0 is duplex
eth0 link down
FAIL
Trying eth1
eth1 link down
FAIL

tftp server(receive) go, waiting:4[sec]
Trying eth1
eth1 link down
FAIL
Trying eth0
eth0 is duplex
eth0 link down
FAIL
Load address: 0x81f00000

Abort
no file was loaded.
### main_loop entered: bootdelay=4

### main_loop: bootcmd="bootm 0xbe060000"
Hit any key to stop autoboot:  0
ar7100> help
autoscr - run script from memory
?       - alias for 'help'
TFTPS   - boot image via network as TFTP server
base    - print or set address offset
bdinfo  - print Board Info structure
boot    - boot default, i.e., run 'bootcmd'
bootd   - boot default, i.e., run 'bootcmd'
bootelf - Boot from an ELF image in memory
bootm   - boot application image from memory
bootp    - boot image via network using BootP/TFTP protocol
bootvx  - Boot vxWorks from an ELF image
chpart    - change active partition
cmp     - memory compare
coninfo - print console devices and information
cp      - memory copy
crc32   - checksum calculation
dhcp    - invoke DHCP client to obtain IP/boot params
echo    - echo args to console
erase   - erase FLASH memory
exit    - exit script
flinfo  - print FLASH memory information
fsinfo    - print information about filesystems
fsload    - load binary file from a filesystem image
go      - start application at address 'addr'
help    - print online help
iminfo  - print header information for application image
imls    - list all images found in flash
itest    - return true/false on integer compare
ledb    - LED test blink
ledoff  - LED test off
ledon   - LED test on
ledt    - LED test toggle
loadb   - load binary file over serial line (kermit mode)
loads   - load S-Record file over serial line
loady   - load binary file over serial line (ymodem mode)
loop    - infinite loop on address range
ls    - list files in a directory (default /)
md      - memory display
mii     - MII utility commands
mm      - memory modify (auto-incrementing)
mtdparts- define flash/nand partitions
mtest   - simple RAM test
mw      - memory write (fill)
nfs    - boot image via network using NFS protocol
nm      - memory modify (constant address)
ping    - send ICMP ECHO_REQUEST to network host
printenv- print environment variables
protect - enable or disable FLASH write protection
rarpboot- boot image via network using RARP/TFTP protocol
reset   - Perform RESET of the CPU
run     - run commands in an environment variable
saveenv - save environment variables to persistent storage
set_inspection - set/unset inspection mode
setenv  - set environment variables
sleep   - delay execution for some time
test    - minimal test like /bin/sh
tftpboot- boot image via network using TFTP protocol
version - print monitor version
ar7100> version

U-Boot 1.1.4 for BUFFALO AIRSTATION (Dec 21 2009 - 10:37:11)
ar7100>

Posted by 훅크선장
아래 링크 내용을 참고하였음.
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 훅크선장
http://verejun.blogspot.com/2011/05/ubuntu.html

패키지들은 패키지 툴을 이용해 설치하게 되는데 우분투에서 사용하는 패키지 툴에는 apt, dpkg, aptitude가 있다.
먼저 apt는 온라인 리포지토리에서 패키지를 다운로드받고 설치하는데 사용 된다. 이 때 보통 로컬환경(오프라인)상에서도 사용할 수 있지만 정상적으로 사용하기 위해서는 온라인 환경에서 사용하는 것이 좋다.
dpkg는 cd-rom이나 다른 디스크장치에 있는 .deb 파일을 제어하는 경우에 일반적으로 사용되며, dpkg 명령어는 시스템 소프트웨어에 대한 설정이나 설치 및 정보를 얻는데 사용되는 옵션을 가진다.
이제 각 패키지 툴에서 사용하는 명령어들을 하나하나 살펴보자.
1. apt
실질적으로 apt는 dpkg와 함께 동작한다. 하지만 필요한 소프트웨어의 검색, 다운로드, 설치, 업그레이드, 검사 등 대부분의 패키지 관리작업을 apt 단독으로 가능하다.
$ sudo apt-get update
:  /etc/apt/sources.list를 참조로 사용할 수 있는 패키지 DB를 업데이트 한다.
$ apt-cache search 키워드
: 패키지 데이터베이스 중 주어진 키워드를 대소문자 구분 없이 검색하여 키워드를 포함하는 패키지명과 해당 설명을 출력한다.
$ sudo apt-get install 패키지명
: 패키지명을 데이터베이스에서 찾아보고 해당패키지를 다운로드 받아 설치한다. 이 때 패키지의 신뢰성을 gpg키를 사용 검증한다.
$ sudo apt-get -d install 패키지명
: 패키지를 설치는 하지 않고 /var/cache/apt/archives/ 디렉토리에 다운로드 받는다.
$ apt-cache show 패키지명
: 주어진 패키지명에 해당하는 소프트웨어에 대한 정보를 본다.
$ sudo apt-get upgrade
: 설치 되어있는 모든 프로그램 패키지에 대한 최신 업데이트를 검사한 후, 다운로드 받아 설치한다.
$ sudo apt-get dist-upgrade
: 전체 시스템을 새로운 버젼으로 업그레이드 한다. 이때 패키지 삭제도 실시된다.
단, 일반적으로 사용되는 업그레이드 방법은 아님!
$ sudo apt-get autoclean
: 불안전하게 다운로드된 패키지나 오래된 패키지의 삭제.
$ sudo apt-get clean
: 디스크 공간 확보를 위해 /var/cache/apt/archives/ 에 캐쉬된 모든 패키지 삭제
$ sudo apt-get 옵션 remove 패키지명
: 해당 패키지와 그 설정파일을 삭제한다. (옵션에 --purge 를 넣으면 설정파일을 제외하고 삭제. 옵션 없을시 전부 삭제)
$ sudo apt-get -f install
: 깨어진 패키지를 위해 정상여부를 확인
$ apt-config -V
: 설치된 APT툴의 버전을 출력
$ sudo apt-key list
: APT가 알고 있는 gpg키 목록의 출력
$ apt-cache stats
: 설치된 모든 패키지에 대한 상태정보를 출력
$ apt-cache depends
: 패키지가 설치되어 있는지 여부에 관계 없이 그 의존성을 출력한다.
$ apt-cache pkgnames
: 시스템에 설치되어 있는 모든 패키지 목록을 보여준다.
2.dpkg
이 툴의 경우 APT보다는 낮은 수준에서 작업이 수행된다. APT는 우분투의 소프트웨어를 관리하기 위해 내부적으로 이 dpkg를 이용한다. 보통 APT명령 만으로 충분하지만... 시스템에 있는 특정 파일이 어떤 패키지에 포함되는지 등의 확인 작업을 수행하기위해 dpkg 명령이 필요한 것이다.
$ dpkg -C  .deb파일
: 주어진 .deb파일이 설치한 파일의 목록을 본다.(해당 파일이 있는 곳에서 실행하거나 파일명앞에 절대 경로를 붙여준다.)
$ dpkg -I  .deb파일
: 주어진 .deb파일에 대한 정보를 본다.
$ dpkg -P  패키지명
: 패키지에 대한 정보를 보여준다.
$ dpkg -S  파일명
: 파일명 또는 경로가 포함된 패키지들을 검색한다.
$ dpkg -l
: 설치된 패키지 목록을 보여준다.
$ dpkg -L  패키지명
: 이 패키지로부터 설치된 모든 파일목록을 볼수 있다.
$ dpkg -s  패키지명
: 주어진 패키지의 상태를 본다
$ sudo dpkg -i  .deb파일
: 주어진 파일을 설치한다.
$ sudo dpkg -r  패키지명
: 시스템에서 해당 패키지를 삭제한다. (단, 삭제시 파일들은 남겨둔다.)
$ sudo dpkg -P  패키지명
: 해당 패키지와 해당 패키지의 설정파일을 모두 삭제한다.
$ sudo dpkg -x  .deb파일  디랙토리
: 파일에 포함되어있는 파일들을 지정된 디렉토리에 풀어놓는다. 단, 주의 할점은 이명령시 해당 디렉토리를 초기화 시켜버리므로 주의하여야 한다!
3. aptitude
앞에서 배운 dpkg와 APT의 경우 제대로 사용하기 위해서는 좀더 많은 지식을 요구한다. 그에 비하여 aptitude의 경우 주요 패키지 작업 과정을 자동화하여 가능한 쉽게 작업할 수 있도록 해주므로 보다 쉽게 할 수 있다. 고로 보다 많이 사용하게 될 것이... 옳지만... 아직은 인터넷 상에서 APT나 dpkg를 사용한 패키지 설치 정보가 많다는 점에서... 장래에 많이 사용하게 될 듯하다^^
$ sudo aptitude
: 실행시 curses인터페이스로 시작된다. Ctrl+t를 사용하면 메뉴에 접근할 수 있으며, q키로프로그램을 종료 시킬 수 있다.
$ aptitude help
: 도움말 보기
$ aptitude search 키워드
: 해당 키워드와 일치하는 패키지를 보여준다.
$ sudo aptitude update
: APT리포지트로들로부터 사용 가능한 패키지를 업데이트 한다.
$ sudo aptitude upgrade
: 모든 패키지를 최신으로 업그레이드 한다.
$ aptitude show 패키지명
: 해당 패키지의 설치 여부에 관계 없이 주어진 패키지에 대한 정보를 보여준다.
$ sudo aptitude download 패키지명
: 해당 패키지를 설치하지는 않고 다운로드만 받는다
$ sudo aptitude clean
: /var/cache/apt/archives디렉토리에 다운로드되어 있는 모든 .deb파일을 삭제한다.
$ sudo aptitude autoclean
: /var/cache/apt/archives디렉토리에 있는 오래된 .deb파일을 전부 삭제한다.
$ sudo aptitude install 패키지명
: 해당 패키지를 시스템에 설치한다.
$ sudo aptitude remove 패키지명
: 시스템으로부터 주어진 패키지를 삭제 한다.
$ sudo aptitude dist-upgrade
: 모든 패키지를 가장 최신 버전으로 업그레이드 시킨다. 이때, 필요한 경우 패키지를 삭제하거나 추가 한다.
참고로, 위 내용 다 넘기고 요즘 우분투의 경우 '프로그램 > 추가/제거' 메뉴나 '시스템 > 관리 > 스넵틱스관리자' 에서 쉽게 패키지를 선택하고 설치하거나 삭제 할 수 있다. 아니면 .deb파일을 받아 마우스로 클릭만 해주면 자동으로 패키지 관리자가 실행되어 설치 하게 되어있다.
하지만, 위 내용을 알고 있어야 보다 깊은 단계로 나아갈 수 있고 또 보다 세부적인 관리, 추가, 삭제가 가능하기에 알아 두는게 좋다고 본다.
이 글은 http://tpholic.com/xe/5102649 에서 가져왔음을 밝힙니다.
 
Posted by 훅크선장

BackTrack 5 R1 中文 Live DVD ISO (GNOME 64bit)

特别 for POC

BackTrack 5 R1 汉化安装中文输入


便下载

FTP Server: hook7346.ignorelist.com
FTP Port: 21
FTP ID: poc2011

FTP PW:  Quiz => 中国的语言 拼音 英语记录跟韩国的语言一样)


If You can not guess the password, Leave your E-Mail address

I will send you the FTP Download information, soon or later.





Posted by 훅크선장