perlmania 스터디 장범수님의 소개로 알게된 irc 클라이언트.
콘솔모드에서 동작이 가능하고 기본적으로 UTF-8을 지원한다.
한글 사용시 charset을 cp949로 지정하면 문제없이 출력된다(xchat도 이렇게 지정했던거 같다)
젠투 portage tree에도 올라와 있다.


# emerge -S weechat
Searching...
[ Results for search key : weechat ]
[ Applications found : 1 ]

*  net-irc/weechat
     Latest version available: 0.2.6
     Latest version installed: 0.2.6
     Size of files: 1,080 kB
     Homepage:      http://weechat.flashtux.org/
     Description:   Portable and multi-interface IRC client.
     License:       GPL-3


# emerge -pv weechat

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild  N    ] app-crypt/opencdk-0.6.6  USE="-doc" 471 kB
[ebuild  N    ] dev-libs/libtasn1-1.3  USE="-doc" 1,492 kB
[ebuild  N    ] net-libs/gnutls-2.2.2  USE="nls zlib -bindist -doc -guile -lzo" 4,809 kB
[ebuild  N    ] net-irc/weechat-0.2.6  USE="perl python ssl -debug -lua -ruby -spell" 1,081 kB

Total: 4 packages (4 new), Size of downloads: 7,851 kB

# emerge weechat
# weechat-curses irc://본인아이디@서버명[:port]

] /charset cp949    # 캐릭터셋을 지정한다.(기본 UTF-8)
] /join linux           # 리눅스 채널에 들어간다.
] /quit                  # 종료한다.


자세한 사항은 아래 url 참조
http://weechat.flashtux.org/doc/en/weechat.en.html

사용자 삽입 이미지

젠투환경에서 php5와 pear

# cat /etc/portage/package.use
dev-lang/php apache apache2 mysql ctype unicode pcre session gd ftp cli iconv truetype xml cgi curl curlwrappers curl simplexml sockets spell xmlreader xmlrpc xmlwriter xsl snmp zlib

# emerge dev-lang/php
# emerge dev-php/PEAR-PEAR
# emerge dev-php/PEAR-DB


http://gentoo-wiki.com/HOWTO_PHP_5_with_PEAR


아파치를 재기동 시킨후 phpinfo 로 출력해보면 --without-pear 라고 되어있다.
이는 php의 USE FLAG 형태로 pear을 설치한게 아니라 dev-php/PEAR-PEAR 이라는 독립적인 패키지의 형태로 설치되어 있기때문인듯 싶다.

물론, pear 사용엔 이상이 없다.

아래 url을 참조한다.

http://forums.gentoo.org/viewtopic-t-585311-highlight-pear+php.html

http://forums.gentoo.org/viewtopic-t-503639-highlight-php+pear.html

1. 개요
무선인터넷을 거의 사용하지 않았기에 무선인터넷에 대한 관심이나 세팅에 별다른 노력을 기울이지 않았었다.

그러다가 이번에 perl 스터디에 참석하면서 무선인터넷 세팅의 필요성을 느끼고 작업하게 되었다.


2. 현재상황 및 시스템 상태
kernel :
Linux gentoo 2.6.19-gentoo-r5 #1 SMP Sun Oct 7 02:33:27 KST 2007 i686 Intel(R) Pentium(R) M processor 1.86GHz GenuineIntel GNU/Linux

lspci:
...
04:02.0 Ethernet controller: Atheros Communications, Inc. AR5212 802.11abg NIC (rev 01)


3. 설치

먼저, 커널에서 무선인터넷을 사용하게 하기위한 커널 컴파일 작업을 한다.
젠투위키의 How a wireless access point 문서를 참조한다


CONFIG_HOTPLUG=y 
  Bus options (PCI, PCMCIA, EISA, MCA, ISA) --->   
     Support for hot-pluggable devices

CONFIG_FW_LOADER: m/y (either one will work) 
  Generic Driver Options  --->    

Hotplug firmware loading supportCONFIG_NET_RADIO=y 
  Device Drivers --->   
     Networking support --->     
        Wireless LAN (non-hamradio) --->

madwifi 패키지를 설치한다.

# emerge madwifi-ng
# update-modules

재부팅후에 wifi 관련 모듈이 올라올 것이다.
안올라 온다면 수동으로 올리도록 하자.

# ifconfig -a

안보이던 ath0 이라는 장치가 보인다.
장치를 로드한다.

# ifconfig ath0 up

무선 access point를 검색해 본다.

# iwlist ath0 scanningath0     
Scan completed :         

Cell 01 - Address: 00:0F:66:1A:6B:12                   
     ESSID:"blah"                   
     Mode:Master                   
     Frequency:2.437 GHz (Channel 6)                   
     Quality=9/70  Signal level=-86 dBm  Noise level=-95 dBm                   
     Encryption key:off                   
    Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 6 Mb/s                             
     9 Mb/s; 12 Mb/s; 18 Mb/s; 24 Mb/s; 36 Mb/s                             
     48 Mb/s; 54 Mb/s                   
     Extra:bcn_int=100         

Cell 02 - Address: 00:50:18:00:0F:FE                   
     ESSID:"sky"                   
     Mode:Master                   
     Frequency:2.462 GHz (Channel 11)                   
     Quality=27/70  Signal level=-68 dBm  Noise level=-95 dBm                   
     Encryption key:off                   
     Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 6 Mb/s                             
    9 Mb/s; 12 Mb/s; 18 Mb/s; 24 Mb/s; 36 Mb/s                             
     48 Mb/s; 54 Mb/s                   
     Extra:bcn_int=100         

Cell 03 - Address: 00:14:6C:F9:A0:CC                   
     ESSID:"NETGEAR"                   
     Mode:Master                   
     Frequency:2.462 GHz (Channel 11)                   
     Quality=34/70  Signal level=-61 dBm  Noise level=-95 dBm                   
     Encryption key:off                   
     Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 18 Mb/s                             
     24 Mb/s; 36 Mb/s; 54 Mb/s; 6 Mb/s; 9 Mb/s                             
     12 Mb/s; 48 Mb/s                   
     Extra:bcn_int=100...

이중 하나를 선택한다.

# iwconfig ath0 essid "NETGEAR"

또는

# iwconfig ath0 ap 00:14:6C:F9:A0:CC


dhcp 클라이언트로 ip를 할당받는다.

# emerge dhcpcd
# dhcpcd ath0
# ifconfig

ath0      Link encap:Ethernet  HWaddr 00:14:A4:3C:98:3A           
           inet addr:192.168.1.9  Bcast:192.168.1.255  Mask:255.255.255.0         
           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1         
           RX packets:6450 errors:0 dropped:0 overruns:0 frame:0         
           TX packets:3719 errors:0 dropped:0 overruns:0 carrier:0
           collisions:0 txqueuelen:0          
           RX bytes:2054318 (1.9 Mb)  TX bytes:478405 (467.1 Kb)

eth0      Link encap:Ethernet  HWaddr 00:0A:E4:C2:5A:8F           
           inet addr:202.196.8.118  Bcast:61.96.8.192  Mask:255.255.255.224         
           UP BROADCAST MULTICAST  MTU:1500  Metric:1         
           RX packets:0 errors:0 dropped:0 overruns:0 frame:0         
           TX packets:0 errors:0 dropped:0 overruns:0 carrier:0         
           collisions:0 txqueuelen:1000          
           RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)         
           Interrupt:16

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:57 errors:0 dropped:0 overruns:0 frame:0         
          TX packets:57 errors:0 dropped:0 overruns:0 carrier:0         
          collisions:0 txqueuelen:0          
          RX bytes:4978 (4.8 Kb)  TX bytes:4978 (4.8 Kb)

wifi0     Link encap:UNSPEC 
          HWaddr 00-14-A4-3C-98-3A-FB-22-00-00-00-00-00-00-00-00           
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1          
          RX packets:144570 errors:0 dropped:0 overruns:0 frame:11547         
          TX packets:4283 errors:30 dropped:0 overruns:0 carrier:0         
          collisions:0 txqueuelen:199          
          RX bytes:13715975 (13.0 Mb)  TX bytes:583166 (569.4 Kb)         
          Interrupt:23

ip 할당을 제대로 받았다.
외부로 ping 을 쏴본다.

# ping yahoo.co.kr
PING yahoo.co.kr (211.115.99.172) 56(84) bytes of data

먹통이다.
라우팅 테이블을 체크해 본다.

# route
Kernel IP routing table
Destination     Gateway         Genmask     Flags Metric Ref    Use Iface
202.196.8.0     *              255.255.255.0   U     0      0        0 eth0
192.168.1.0     *               255.255.255.0   U     0      0        0 ath0
loopback        *               255.0.0.0       U     0      0        0 lo
default        202.196.8.1     0.0.0.0         UG    0      0        0 eth0

ath0 인터페이스의 default gateway 가 설정되지 않았다.
default gateway를 추가한다.

# route add default gw 192.168.1.1
# route

Kernel IP routing tableDestination     Gateway         Genmask     Flags Metric Ref    Use Iface
202.196.8.0     *              255.255.255.0   U     0      0        0 eth0
192.168.1.0     *               255.255.255.0   U     0      0        0 ath0
loopback        *               255.0.0.0       U     0      0        0 lo
default        202.196.8.1     0.0.0.0         UG    0      0        0 eth0
default         192.168.1.1     0.0.0.0         UG    0      0        0 ath0

# ping yahoo.co.kr
PING yahoo.co.kr (211.115.99.172) 56(84) bytes of data.
64 bytes from web.rc.vip.krs.yahoo.com (211.115.99.172): icmp_seq=1 ttl=45 time=4.43 ms
64 bytes from web.rc.vip.krs.yahoo.com (211.115.99.172): icmp_seq=2 ttl=45 time=2.85 ms
...

제대로 된다.
그런데 좀 이상하긴 하다.
만약, 게이트웨이를 모르면 무선 인터넷은 못쓰는 거네???
여기서 좀 많이 삽질을 한거같다.

결론은 무선 인터넷을 쓸때는 eth0 인터페이스를 죽이는 것이다.

다시 해보면,

# kill -9 `ps -ef | grep dhcpcd | grep -v grep | awk '{print $2}'`
# ifconfig ath0 down
# ifconfig eth0 down
# ifconfig ath0 up
# iwconfig ath0 essid "NETGEAR"
# dhcpcd ath0
# ifconfig

ath0      Link encap:Ethernet  HWaddr 00:14:A4:3C:98:3A           
           inet addr:192.168.1.9  Bcast:192.168.1.255  Mask:255.255.255.0         
           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1         
           RX packets:6450 errors:0 dropped:0 overruns:0 frame:0         
           TX packets:3719 errors:0 dropped:0 overruns:0 carrier:0
           collisions:0 txqueuelen:0          
           RX bytes:2054318 (1.9 Mb)  TX bytes:478405 (467.1 Kb)

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:57 errors:0 dropped:0 overruns:0 frame:0         
          TX packets:57 errors:0 dropped:0 overruns:0 carrier:0         
          collisions:0 txqueuelen:0          
          RX bytes:4978 (4.8 Kb)  TX bytes:4978 (4.8 Kb)

wifi0     Link encap:UNSPEC 
          HWaddr 00-14-A4-3C-98-3A-FB-22-00-00-00-00-00-00-00-00           
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1          
          RX packets:144570 errors:0 dropped:0 overruns:0 frame:11547         
          TX packets:4283 errors:30 dropped:0 overruns:0 carrier:0         
          collisions:0 txqueuelen:199          
          RX bytes:13715975 (13.0 Mb)  TX bytes:583166 (569.4 Kb)         
          Interrupt:23

# ping yahoo.co.kr
PING yahoo.co.kr (211.115.99.172) 56(84) bytes of data.
64 bytes from web.rc.vip.krs.yahoo.com (211.115.99.172): icmp_seq=1 ttl=45 time=4.59 ms
64 bytes from web.rc.vip.krs.yahoo.com (211.115.99.172): icmp_seq=2 ttl=45 time=5.33 ms
64 bytes from web.rc.vip.krs.yahoo.com (211.115.99.172): icmp_seq=3 ttl=45 time=5.47 ms

--- yahoo.co.kr ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2004ms
rtt min/avg/max/mdev = 4.594/5.133/5.472/0.385 ms
#


완벽하다.






사용자 삽입 이미지

4. 후기

속도적인 측면과 보안적인 측면에서 무선 인터넷을 별로 신뢰하지 않은게 사실이었다.
집에서는 유선만 사용하다가 이번에 옮긴 회사가 구로쪽이라 엄청난 Access Pointer가 검출(?) 되어 손쉽게 작업을 한거같다.
이번에 세팅하고 나니 무선인터넷도 꽤 매력이 있는거 같다.
시스템 시작시 유선 먼저 체크 후 무선 가동하면 어느정도 쓸만할거 같다.
스크립트 작업은 내일, 아니면 시간날때...
지금은 졸린다.


5. 참조 url

http://gentoo-wiki.com/HOWTO_Atheros_Wifi_Card_/_MadWifi_Install
http://gentoo-wiki.com/HOWTO_Building_a_Wireless_Access_Point


glibc 업그레이드 할려다 시스템이 완전히 망가져 다시 설치했다.
gentoo base installation을 참조한다.

이후부터는 gnome을 비롯한 데스크탑 환경에 대한 작업이다.

# emerge gnome

대략, 377개의 패키지가 설치되는데 hal 패키지 설치도중 에러가 났다.
pciutils 패키지 설치시 USE 플래그에 zlib를 제외하고 pciutils을 재컴파일 한다음 다시 시도한다.

# USE="-zlib" emerge pciutils
# emerge gnome
# rc-update add xdm default

/etc/X11/xorg.conf 편집한다.
gnome 설치가 완료된다.

사용자를 추가한다.
# useradd gentoo -m -G users,audio,wheel -s /bin/bash


gentoo 한글설정을 참조한다.

nabi를 설치한다.
# emerge nabi
# cat /etc/env.d/00basic
...
LC_ALL="ko_KR.UTF-8"
LC_LANG="ko_KR.UTF-8"
LC_MESSAGE="ko_KR.UTF-8"
LANG="ko_KR.UTF-8"
XMODIFIERS="@im=nabi"
XIM_PROGRAM="/usr/bin/nabi"

gnome의 시스템>기본설정>세션에서 nabi를 추가한다.


폰트(은진체) 설치
# emerge alee-fonts
gnome의 시스템>기본설정>폰트에서 은진체를 지정한다.
firefox에서 은진체 지정한다.

사운드설정
# emerge alsa-utils
# alsamixer
# rc-update add alsasound boot
http://gentoo-wiki.com/HOWTO_Compile_Kernel_with_ALSA 참조한다



기본 프로그램을 설치한다.
emerge mplayer xchat tcpdump wireshark


mplayer
http://special.homelinux.net/entry.php?blogid=86
/etc/env.d/00basic 파일에 다음을 추가한다.

LC_ALL="ko_KR.UTF-8"
LC_LANG="ko_KR.UTF-8"
LC_MESSAGE="ko_KR.UTF-8"
LANG="ko_KR.UTF-8"

추가후

# env-update

또는 재부팅한다.

# set | grep LANG
LANG=ko_KR.UTF-8
LC_LANG=ko_KR.UTF-8

콘솔에서 한글사용 관련은 다음 url을 참조한다.
http://dnavi.info/info/16
1. 개요
gentoo에서 qmail 및 관련 패키지를 설치하고 mail client(thunderbird) 설정을 다룬다.


2. 현재상황 및 시스템 상태
kernel : gentoo-2.6.18 (전부 다)

나의 사설네트워크의 dns서버가 세팅되어 있다. http://innu.pe.kr/tt/397 참조.
zone 파일의 MX 레코드에 1차로 mail.ddong.ac.kr, 2차로 mail2.ddong.ac.kr로 설정되었다.
우선, mail.ddong.ac.kr 세팅을 한다.
pop3서버는 mail.ddong.ac.kr과 IP는 동일하고 호스트명만 A 레코드에 추가를 하였다.
db.ddong.ac.kr에 mysql이 설치되어 있어야 한다.

즉, 이 작업이 이뤄지기 위해선,
- dns 설치(ns.ddong.ac.kr)
- mysql 설치(db.ddong.ac.kr)

이 반드시 선행되어져야 한다.


3. 설치
qmail 설치에 앞서 우선 USE flag를 손본다.

사용자 삽입 이미지



# cat /etc/make.conf
...
USE="-X -xorg -kde -gnome -gtk -gtk2 -ipv6"
# cat /etc/portage/package.use
mail-mta/netqmail maildir ssl imap mysql
net-mail/vpopmail mysql
net-mail/courier-imap berkdb fam gdbm nls -debug -ipv6


qmail 설치

qmail을 emerge 한다.
# emerge mail-mta/netqmail


/var/qmail/control/servercert.cnf 파일의 [ req_dn ] 블록을 수정한다
# cat /var/qmail/control/servercert.cnt
...
C=KO
ST=SE
L=Seoul
O=Gogi Mail Systems
OU=Automatically-generated Qmail SMTP SSL key
CN=mail.ddong.ac.kr
emailAddress=gogisnim@gmail.com


qmail의 config 파일을 emerge한다.
# emerge --config netqmail


qmail의 alias 설정을 한다.
참고로, qmail은 root로 메일을 보낼 수 없다. 그래서 root를 비롯한 타 계정으로 가는 메일을 다른 메일로 forward 시킨다. 여기선 gogisnim으로 forward 시켰다.
# cd /var/qmail/alias
# echo gogisnim > .qmail-root
# echo gogisnim > .qmail-postmaster
# echo gogisnim > .qmail-mailer-daemon


qmail 시스템의 전체적인 총괄을 담당(?)하는 데몬을 구동시킨다.
그리고, /service/ 아래에 qmail-send 심볼릭 링크를 걸어준다.
# /etc/init.d/svscan start
# rc-update add svscan default
# ln -s /var/qmail/supervise/qmail-send /service/qmail-send


qmail 설치가 끝났다. 로컬에서 gogisnim으로 메일을 보내본다.
이상이 없으면 다음으로 진행..
# ssh gogisnim@localhost
$ maildirmake .maildir
$ qmail-inject root << EOF
> test mail to root
> EOF
$ qmail-inject postmaster << EOF
> test mail to postmaster
> EOF
$ qmail-inject gogisnim << EOF
> test mail to gogisnim
> EOF
$ mutt
gogisnim에게 3통의 메일이 수신되었으면 정상이다.


vpopmail 설치

vpopmail은 다른 MTA가 시스템계정 == 메일계정 방식의 계정관리 방식에서 보다 유연하게 DB로 관리할 수 있게 한다. 무엇보다도 가상 도메인을 지원하기때문에 하나의 qmail 시스템에서 수십, 수백, 수천개의 도메인, 계정을 관리할 수 있다.
mysql이 필요한 시점이 지금이다.

# emerge vpopmail
# mysql -uroot -hdb.ddong.ac.kr -p << EOF
> create database vpopmail;
> use mysql;
> grant select,insert,update,delete,create,drop on vpopmail.* to vpopmail@mail.ddong.ac.kr identified by 'vpoppw';
> grant select,insert,update,delete,create,drop on vpopmail.* to vpopmail@smtp.ddong.ac.kr identified by 'vpoppw';
> grant select,insert,update,delete,create,drop on vpopmail.* to vpopmail@pop3.ddong.ac.kr identified by 'vpoppw';
> grant select,insert,update,delete,create,drop on vpopmail.* to vpopmail@mail2.ddong.ac.kr identified by 'vpoppw';
> flush privileges;
> EOF

위 내용은 gentoo.org의 qmail 세팅 매뉴얼에 나와있는 내용이지만 나는 이렇게 작업하지 않고 mysql_setpermission 스크립트를 이용해서 간단하게 작업했다.


vpopmail 설정파일을 수정한다.
호스트|포트|mysql사용자|mysql비번|DB명
# cat /etc/vpopmail.conf
...
# Read-only DB
db.ddong.ac.kr|0|vpopmail|vpoppw|vpopmail
# Write DB
db.ddong.ac.kr|0|vpopmail|vpoppw|vpopmail


파일의 사용자,권한을 체크한다.
gentoo에서는 이 작업이 필요없다. 확인만 한다.
# chown root:vpopmail /etc/vpopmail.conf
# chmod 640 /etc/vpopmail.conf
# chown root:vpopmail /var/vpopmail/bin/vchkpw
# chmod 4711 /var/vpopmail/bin/vchkpw


설정환경을 업데이트 한다.
# env-update && . /etc/profile


가상도메인을 추가한다.
내가 사용할 user@ddong.ac.kr 형식의 가상도메인을 여기서 설정한다.
아울러, 사용자도 추가해준다.
# /var/vpopmail/bin/vadddomain ddong.ac.kr
Password for postmaster: 1111
# /var/vpopmail/bin/vadduser gogisnim@ddong.ac.kr
Password for gogisnim@ddong.ac.kr: 2222
# /var/vpopmail/bin/vadduser ji@ddong.ac.kr
Password for ji@ddong.ac.kr: 3333

도메인삭제는 vdeldomains, 사용자삭제는 vdeluser이다.
이처럼 /var/vpopmail/bin/에 있는 vpopmail 관련 명령어들은 직관적이어서 쉽게 사용할 수 있다.
vpopmail 설정이 끝났다.
간혹, mysql/vpopmail 연동해서 permission 관련 오류가 발생하면 mysql 데몬을 재시동 시켜준다.
db # /etc/init.d/mysql restart


courier-imap 설치

courier-imap 패키지는 pop3/pop3-ssl, imap/imap-ssl 모두를 지원하는 MDA이다.
반드시 vpopmail 설치후 courier-imap를 설치해야 한다.

# emerge courier-imap
# cat /etc/courier/authlib/authdaemonrc
...
authmodulelist = "authvchkpw"
...
# cat /etc/courier-imap/pop3d.cnf
...
[ req_dn ]
C=KO
ST=SE
L=Seoul
O=Gogi Mail Systems
OU=Automatically-generated Qmail SMTP SSL key
CN=mail.ddong.ac.kr
emailAddress=gogisnim@gmail.com
...
# cat /etc/courier-imap/imap.cnf
...
[ req_dn ]
C=KO
ST=SE
L=Seoul
O=Gogi Mail Systems
OU=Automatically-generated Qmail SMTP SSL key
CN=mail.ddong.ac.kr
emailAddress=gogisnim@gmail.com
...

# mkpop3dcert
# mkimapdcert

# /etc/init.d/courier-pop3d start
# /etc/init.d/courier-imapd start
# /etc/init.d/courier-pop3d-ssl start
# /etc/init.d/courier-imap-ssl start
# rc-update add courier-pop3d default
# rc-update add courier-imapd default
# rc-update add courier-pop3d-ssl default
# rc-update add courier-imapd-ssl default

qmail 서버에서 pop3(110), pop3-ssl(995), imap(143), imap-ssl(993) 전부 대기하게 만든다.
사용자가 mail client를 입맛대로 설정할 수 있다.
courier-imap 패키지 설치와 설정이 끝났다.


마무리작업

# cat /var/qmail/control/conf-smtpd
...
QMAIL_SMTP_CHECKPASSWORD="/var/vpopmail/bin/vchkpw"
...
# mkservercert
# ln -s /var/qmail/supervise/qmail-smtpd /service/qmail-smtpd


mail client(thunderbird) 설정

현재 thunderbird 2.0.0.6 영문버전을 사용하고 있다.

사용자 삽입 이미지
계정세팅 이미지


사용자 삽입 이미지
pop3-ssl 설정 이미지


사용자 삽입 이미지
smtp 설정 이미지


4. 후기
qmail 설치작업은 한마디로 삽질의 연속이었다.
gentoo wiki, gentoo.org, qmail.kldp.org 그리고 googling 까지..
될듯될듯 하면서도 마지막 mail client의 사용자 인증부분에서 좌절을 겪고 또 설치하고, 테스트하고..

메일세팅 작업의 노하우를 간단히 얘기하면,

MTA를 설치하고 반드시 localhost에서 주고 받는데 이상이 없는지 테스트를 한다.
테스트 하는데는 mutt와 telnet client가 좋다.(mutt로 메일보내고 telnet으로 110번 접속해서 확인)
localhost에서 이상이 없으면 다른 호스트에서 테스트를 한다.
mail client 설정할때 반드시 Thunderbird, Outlook (Express)를 비롯한 여러 프로그램에서 테스트 해본다.
처음, Outlook에서는 인증이 되는데 Thunderbird에서는 인증이 되지않아 애를 먹었다.

스팸처리와 webmail구현은 다음에 작업해서 문서로 남긴다.


5. 참조 url
http://www.gentoo.org/doc/en/qmail-howto.xml
http://gentoo-wiki.com/HOWTO_Setup_QMAIL_RELAY-CTRL_VPOPMAIL_%26_QMAILADMIN_with_a_minimum_amount_of_fuss.
http://qmail.kldp.org/
http://www.mozilla.or.kr/products/thunderbird/
http://forums.gentoo.org/viewtopic-t-539101.html
처음 gentoo 설치시 timezone을 GMT로 지정하고 설치했었다.
나중에 KST로 고치니 현재 시각과 9시간 차이가 나는것이다.

참조 url
http://kldp.org/node/78688
http://forums.gentoo.org/viewtopic-t-579129.html

# rdate -s time.bora.net
# rm -f /etc/adjtime
# rm -f /etc/localtime
# ln -s /usr/share/zoneinfo/Asia/Seoul /etc/localtime
# hwclock -w

# cat /etc/conf.d/clock
CLOCK="local"
TIMEZONE=""
CLOCK_SYSTOHC="yes"
SRM="no"
ARC="no"

# reboot
OpenVZ으로 기본적인 네트워크 구축이 끝났다.
각 서버마다 호스트명과 IP를 할당하고 DNS 서버를 설치/운영한다.


DNS 서버는 bind로 돌리고 master, slave로 구축한다.
ns1.ddong.ac.kr - master name server
ns2.ddong.ac.kr - slave name server

1. master name server 설치

1) gentoo portage에서 최신 bind(bind-9.4.1-P1)를 받아서 설치한다
# emerge bind

2) /etc/bind/named.conf 편집
# cat /etc/bind/named.conf
options {
       directory "/var/bind";
       dump-file "/var/bind/named_dump.db";
       statistics-file "/var/bind/named.stats";
       pid-file "/var/run/named/named.pid";

       // uncomment the following lines to turn on DNS forwarding,
       // and change the forwarding ip address(es) :
       //forward first;
       //forwarders {
       //      123.123.123.123;
       //      123.123.123.123;
       //};

       listen-on-v6 { none; };
       //listen-on { 127.0.0.1; };

       // to allow only specific hosts to use the DNS server:
       //allow-query {
       //      127.0.0.1;
       //};

       // if you have problems and are behind a firewall:
       //query-source address * port 53;
};
zone "." IN {
       type hint;
       file "named.ca";        // linked root.cache
};

zone "localhost" IN {
       type master;
       file "pri/localhost.zone";
       allow-update { none; };
       notify no;
};

zone "127.in-addr.arpa" IN {
       type master;
       file "pri/127.zone";
       allow-update { none; };
       notify no;
};

zone "ddong.ac.kr" IN {
       type master;
       file "zone/ddong.ac.kr.zone";
      allow-transfer { 1.1.2.200; };
       notify yes;
};

zone "1.1.in-addr.arpa" IN {
       type master;
       file "pri/ddong.ac.kr.rev.zone";
};

3) /var/bind/zone/ddong.ac.kr.zone 파일 편집
# cat /var/bind/zone/ddong.ac.kr.zone
$ORIGIN 1.1.in-addr.arpa.
$TTL 86400
@       IN      SOA     ns1.ddong.ac.kr.        gogisnim.gmail.com. (
                       2007082620      ; serial
                       3H              ; refresh
                       15M             ; retry
                       1W              ; expiry
                       1D )            ; minimum

               IN      NS      ns1.ddong.ac.kr.;
;      
               IN      MX      10      mail
               IN      MX      20      mail2
;
; host configuration
localhost       IN      A       127.0.0.1
ns1             IN      A       1.1.1.200
ns2             IN      A       1.1.2.200
ddong.ac.kr.    IN      A       1.1.1.200
www1            IN      A       1.1.1.200
www2            IN      A       1.1.2.200
www3            IN      A       1.1.3.200
mail            IN      A       1.1.1.201
mail2           IN      A       1.1.2.201
pop3            IN      A       1.1.1.201
ftp             IN      A       1.1.1.203
db              IN      A       1.1.1.204
fw              IN      A       1.1.1.10
gw              IN      A       1.1.1.10

www             IN      CNAME   www1

주의
첫 라인의 $ORIGIN 에 /etc/bind/named.conf에서 지정해준 reverse zone 영역명칭이 와야한다. 만약 ddong.ac.kr. 이되면 named 구동시 아래와 같은 메시지가 나온다
# tail -f /var/log/messages
...
Aug 29 00:42:31 ddong named[29017]: zone/ddong.ac.kr.rev.zone:3: ignoring out-of-zone data (ddong.ac.kr)
Aug 29 00:42:31 ddong named[29017]: zone/ddong.ac.kr.rev.zone:14: ignoring out-of-zone data (200.1.ddong.ac.kr)
Aug 29 00:42:31 ddong named[29017]: zone/ddong.ac.kr.rev.zone:15: ignoring out-of-zone data (200.2.ddong.ac.kr)
Aug 29 00:42:31 ddong named[29017]: zone/ddong.ac.kr.rev.zone:16: ignoring out-of-zone data (200.1.ddong.ac.kr)
...

4) named를 구동하고 부팅과 동시에 named 이 구동되게 rc-update에 등록
# /etc/init.d/named start
# rc-update add named default


2. slave name server 설치

1) gentoo portage에서 최신 bind(bind-9.4.1-P1)를 받아서 설치한다
# emerge bind

2) /etc/bind/named.conf 편집
# cat /etc/bind/named.conf
options {
       directory "/var/bind";
       dump-file "/var/bind/named_dump.db";
       statistics-file "/var/bind/named.stats";
       pid-file "/var/run/named/named.pid";

       // uncomment the following lines to turn on DNS forwarding,
       // and change the forwarding ip address(es) :
       //forward first;
       //forwarders {
       //      123.123.123.123;
       //      123.123.123.123;
       //};

       listen-on-v6 { none; };
       //listen-on { 127.0.0.1; };

       // to allow only specific hosts to use the DNS server:
       //allow-query {
       //      127.0.0.1;
       //};

       // if you have problems and are behind a firewall:
       //query-source address * port 53;
};
zone "." IN {
       type hint;
       file "named.ca";        // linked root.cache
};

zone "localhost" IN {
       type master;
       file "pri/localhost.zone";
       allow-update { none; };
       notify no;
};

zone "127.in-addr.arpa" IN {
       type master;
       file "pri/127.zone";
       allow-update { none; };
       notify no;
};

zone "ddong.ac.kr" IN {
       type slave;
       file "sl/bak.ddong.ac.kr.zone";
       masters { 1.1.1.200; };
};

zone "1.1.in-addr.arpa" IN {
       type slave;
       file "sl/bak.ddong.ac.kr.rev.zone";
       masters { 1.1.1.200; };
};

3) slave에서는 zone 파일을 설정할 필요가 없다.
master에서 zone transfer로 받아서 직접 생성해주기 때문..
주의할점은 이 상태에서 named을 구동하면 에러가 발생한다.
(named는 구동이 되지만 실제 zone transfer는 일어나지 않는다)
왜냐하면, gentoo에서 named는 root계정으로 실행되지 않고 named 계정으로 실행된다.
zone transfer가 일어날때 slave 의 zone 영역(/var/bind)은 root 권한만 쓸 수 있는데 일반계정인 named로 write하니 permission denied 가 일어나는 것이다.

http://www.isc.org/index.pl?/sw/bind/FAQ.php 참조한다.

# ls -l /var/bind
-rw-r--r-- 1 root  root  2518 Aug 27 20:39 named.ca
drwxr-xr-x 2 root  root  4096 Aug 28 01:48 pri
lrwxrwxrwx 1 root  root    23 Aug 27 20:39 root.cache -> ../../var/bind/named.ca
drwxr-xr-x 2 root  root  4096 Aug 27 20:39 sec
drwxr-xr-x 2 root  root  4096 Aug 28 02:48 sl

tail -f /var/log/messages
Aug 28 01:42:51 ns2 named[22077]: zone ddong.ac.kr/IN: Transfer started.
Aug 28 01:42:51 ns2 named[22077]: transfer of 'ddong.ac.kr/IN' from 1.1.1.200#53: connected using 1.1.2.200#48915
Aug 28 01:42:51 ns2 named[22077]: dumping master file: zone/tmp-boAPWlF76G: open: permission denied
Aug 28 01:42:51 ns2 named[22077]: transfer of 'ddong.ac.kr/IN' from 1.1.1.200#53: failed while receiving responses: permission denied
Aug 28 01:42:51 ns2 named[22077]: transfer of 'ddong.ac.kr/IN' from 1.1.1.200#53: end of transfer

named에서 쓰기 이벤트가 일어나는 곳은 sl/ 이하이다.
named에 owner 권한을 변경한다.
# chown -R named.named sl/

4) named를 구동하고 부팅과 동시에 named 이 구동되게 rc-update에 등록
# /etc/init.d/named start
# rc-update add named default


3. nslookup, dig, dnstop 사용

1) root DNS부터 검색해서 innu.pe.kr 까지 내려오기
$ nslookup
> server a.root-servers.net
> set q=ns
> kr.
> server b.dns.kr
> pe.kr.
> server c.dns.kr
> innu.pe.kr.
> server ns.80port.com
> set q=a
> innu.pe.kr
Address:    xxx.xxx.xxx.xxx#53

2) bind 버전 알아보기
$ dig @ns2.ddong.ac.kr txt chaos version.bind

; <<>> DiG 9.3.2 <<>> @ns2.ddong.ac.kr txt chaos version.bind
; (1 server found)
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 13391
;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 0

;; QUESTION SECTION:
;version.bind.                  CH      TXT

;; ANSWER SECTION:
version.bind.           0       CH      TXT     "9.4.1-P1"

;; AUTHORITY SECTION:
version.bind.           0       CH      NS      version.bind.

;; Query time: 1 msec
;; SERVER: 1.1.2.200#53(1.1.2.200)
;; WHEN: Tue Aug 28 03:43:46 2007
;; MSG SIZE  rcvd: 65

위의 9.3.2는 dig의 버전이고 아래 "9.4.1-P1" 이 name server의 bind 버전이다.

3) reverse dns가 제대로 작동하는지 테스트
# dig @ns1.ddong.ac.kr 204.1.1.1.in-addr.arpa ptr
; <<>> DiG 9.4.1-P1 <<>> @ns1.ddong.ac.kr 204.1.1.1.in-addr.arpa ptr
; (1 server found)
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 55312
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1

;; QUESTION SECTION:
;204.1.1.1.in-addr.arpa.                IN      PTR

;; ANSWER SECTION:
204.1.1.1.in-addr.arpa. 86400   IN      PTR     db.ddong.ac.kr.

;; AUTHORITY SECTION:
1.1.in-addr.arpa.       86400   IN      NS      ns1.ddong.ac.kr.

;; ADDITIONAL SECTION:
ns1.ddong.ac.kr.        86400   IN      A       1.1.1.200

;; Query time: 1 msec
;; SERVER: 1.1.1.200#53(1.1.1.200)
;; WHEN: Wed Aug 29 01:37:02 2007
;; MSG SIZE  rcvd: 102

또는

# dig -x 1.1.1.204
; <<>> DiG 9.4.1-P1 <<>> -x 1.1.1.204
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 20304
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1

;; QUESTION SECTION:
;204.1.1.1.in-addr.arpa.                IN      PTR

;; ANSWER SECTION:
204.1.1.1.in-addr.arpa. 86400   IN      PTR     db.ddong.ac.kr.

;; AUTHORITY SECTION:
1.1.in-addr.arpa.       86400   IN      NS      ns1.ddong.ac.kr.

;; ADDITIONAL SECTION:
ns1.ddong.ac.kr.        86400   IN      A       1.1.1.200

;; Query time: 0 msec
;; SERVER: 1.1.1.200#53(1.1.1.200)
;; WHEN: Wed Aug 29 01:38:46 2007
;; MSG SIZE  rcvd: 102



4) dnstop으로 dns query 모니터링
# dnstop eth0

사용자 삽입 이미지


사용자 삽입 이미지

dig, nslookup, host 의 command는 bind-tools 패키지에 포함되어 있다.
dnstop command는 dnstop 패키지에 포함되어 있다.

집에 굴러다니는 장비가

ThinkPad R52 노트북 1대
AMD Sempron 데스크탑 1대
Compaq ProLiant DL360 1u 서버 1대
케이블 모뎀 1대 (내꺼 아님)
zio INB3040SR V2 4포트짜리 공유기 1대

그외 잡다구리한 컴퓨터 부품들...


DL360이 방화벽 겸 공유기 역할을 할 것이고 데스크탑 pc는 가상서버(OpenVZ 기반)를 운영할 것이다.
노트북은 순수하게 데스크탑 용도.

---|모뎀|---|방화벽|---|공유기|(실제 hub 역할을 하게된다)
                                   |    |
                                   |    |
                          |노트북| |데스크탑|


1. 방화벽 서버 세팅
1) gentoo를 설치한다.

2) 네트웍 설정을 한다.
# cat /etc/conf.d/net

# 외부 네트웍을 연결하는 인터페이스
iface_eth0="dhcp"
config_eth0=( "dhcp" )
modules_eth0=( "dhcpcd" )
dhcp_eth0="nodns nontp nonis"

# 내부 네트웍을 연결하는 인터페이스
config_eth1=( "1.1.1.1 netmask 255.255.0.0" )

3) dhcp 서버로부터 유동ip를 제대로 받아오는지 확인한다.
이부분이 가장 시간허비한 부분인데 Compaq ProLiant DL360에서 dhcp 클라이언트 문제 를 참조.
참고로, 모뎀을 끄고 몇분있다 다시 켜도 못받아 오는 경우가 있다.
이럴땐 모든 랜케이블 다 뽑고 컴퓨터 전원 다 뽑고 밖에서 담배한대 피우고 들어와서 다시 작업하자.

4) iptables 설치를 한다.
emerge iptables로 한번에 끝낼 수 있지만 현재 portage tree에 올라온 버전은 1.3.5 인데 netfilter.org에서 1.3.8까지 나왔다.
그리고 무엇보다도 patch-o-matic 으로 특정기능, 이를테면 string matching 이나 특정 국가 접속차단 같은 기능을 추가하려면 커널을 다시 컴파일 해야한다. iptables는 어플리케이션 기반이 아니고 커널기반에서 작동한다. 기억..

# cd /usr/src/linux
# wget http://netfilter.org/어쩌구저쩌구/iptables-1.3.8.tar.bz2
# wget http://netfilter.org/블라블라블라/patch-o-matic-20070821.tar.bz2
# bzip2 -cd iptables-1.3.8.tar.bz2 | tar xvf -
# ln -s iptables-1.3.8 iptables
# bzip2 -cd patch-o-matic-20070821.tar.bz2 | tar xvf -
# cd patch-o-matic-20070821
# ./runme --download
# ./runme all
패치할 항목을 선택한다.
N : 안한다. 다음
y : 선택
b : 이전으로
t : 적합한지 테스트
# cd ../linux
# make menuconfig
이렇게 하면 방금 추가한 항목들이 나타난다.
# make && make modules_install
모듈로 선택한 놈들을 /etc/modules.autoload.d/kernel-2.6 에 추가한다.
mod_insert.sh 스크립트를 이용한다.
grub 수정/재설정하고 재부팅한다.

5) 방화벽 정책을 설정한다.
# cat /root/firewall.sh
#!/bin/sh
..
IPTABLES="/sbin/iptables"
EXTERN_IP=`/sbin/ifconfig eth0 | grep "inet addr" | awk '{print $2}' | sed -e "s/.*://"`
..
# iptables의 string matching 기능, 네이트온 접속을 차단한다
$IPTABLES -A FORWARD -p tcp -m string --string "nateon.nate.com" --algo bm --to 65535 -j DROP

# 내부에서 밖으로 빠져나가는 패킷은 eth0에서 받은 유동 ip로 변환한다.
$IPTABLES -t nat -A POSTROUTING -o eth0 -j SNAT --to $EXTERN_IP

# 패킷의 적합여부 체크
$IPTABLES -A FORWARD -o eth0 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
$IPTABLES -A FORWARD -o eth1 -m state --state ESTABLISHED,RELATED -j ACCEPT
...

# cat /etc/conf.d/local.start
/root/firewall.sh &> /dev/null


2. 방화벽에 물리는 노트북, 데스크탑 세팅
간단하다.
네트웍 정보에서 방화벽의 eth1 인터페이스 영역의 정보를 입력한다.
노트북 :
ip 1.1.1.50
mask : 255.255.0.0
gw : 1.1.1.1 (방화벽 eth1 의 ip)

데스크탑 :
ip 1.1.1.100
mask : 255.255.0.0
gw : 1.1.1.1 (방화벽 eth1 의 ip)


issue

a. patch-o-matic 에서 geoip(국가별 필터링) 추가하고 커널 컴파일 했는데 오류가 나옴. 원인을 찾아야 함.

b. string matching 기능이 그다지 신뢰할 만하지 않다는 것이다.
네이트온 접속을 차단하기 위해 ethereal로 패킷분석해 걸러낼 문자열을(예를들어 natoon.nate.com) 추가했지만 이는 네이트온 패킷에서만 나오는 것인지 다른 프로그램에서도 나오는 것인지 확실히 구분하기가 모호하다.
그리고 구글이나 일반 웹페이지에서 검색어로 natoon.nate.com 하면 그냥 거부가 되니 분명 문제가 있다.
L7 filtering 을 연구해봐야 겠다.
http://l7-filter.sourceforge.net/

c. 방화벽 구축후
http://www.netfilter.org/ 접속이 안된다. 다른곳은 이상없는데.. 우째 이런일이 ~~


하루쯤 지나니 이상없이 접속할 수 있다.


집에서 NAT 환경을 구현하기 위해 저사양의 pc를 찾다가 구석탱이에 처박혀 있는 ProLiant DL360(이하 DL360)이 눈에 들어왔다.
예전 IDC에 넣어두고 개인서버를 돌릴때 중고(30만원)로 구매한거 였는데 회선비용이 너무 비싸 1년여 돌리다 빼와서 집구석에 쳐박혀 있던 중...

단지, ethernet adapter 가 2개라는 이유다.

DL360은 Intel EtherExpress 100 모델의 ethernet adapter를 2개 가지고 있다.
헷갈리게시리 nic1, nic2 이런 식으로 되어있다.

nic1 = eth0
nic2 = eth1

그런데, 바뀌는 경우도 봤다(Gentoo 설치시 net-setup 할때)

어쨌든 기존에 깔려있던 CentOS 4.X 버전을 밀어버리고 Gentoo 를 설치했다(이제는 X를 설치하지 않는 Gentoo 설치가 휠씬 쉽게 느껴진다)

외부 ip를 담당하는 eth0에는 유동ip 할당, 내부 ip를 담당하는 eth1에는 고정ip 할당..

문제는 케이블 모뎀의 dhcp 서버를 찾기위해 Gentoo에서 dhcp 클라이언트를 설치했는데도 ip를 받아내지 못한다는 거였다.

모뎀을 껐다가 다시 켜고 시스템을 껐다가 다시 켜도 마찬가지다.
부팅시 이런 메시지가 나온다.
Apr 11 00:09:28 kaylee dhcpcd[2162]: eth0: ignoring packet with xid 605093888 as it's not ours (617566766)
Apr 11 00:09:29 kaylee dhcpcd[2162]: eth0: ignoring packet with xid 1040056063 as it's not ours (617566766)
Apr 11 00:09:29 kaylee dhcpcd[2162]: eth0: ignoring packet with xid 1040056063 as it's not ours (617566766)
Apr 11 00:09:32 kaylee dhcpcd[2162]: eth0: ignoring packet with xid -1031143425 as it's not ours (617566766)

gentoo forum에서 검색해 찾은 문제의 메시지다.

http://forums.gentoo.org/viewtopic-t-552662-highlight-ignoring+packet.html

해결책은 너무나 간단하다.

현재 gentoo 시스템(커널버전 2.6.21)에서  portage 싱크시키고 설치한 dhcpcd 버전이 3.0.16 이었다.
이 버전에서 ip를 받아오는 부분에 문제가 있다는 얘기를 예전에도 들은거 같았는데 깜박 잊었었다.

dhcp로 ip를 받아올때 아무런 문제가 없는 내 노트북의 dhcpcd 버전을 확인해보니 2.0.5 다.

역시나,

dhcpcd를 지우고 다운그레이드한 dhcpcd를 설치했다.

# emerge --unmerge dhcpcd
# emerge dhcpcd-2.0.5-r1.ebuild
# emerge --version
2.0.5
어쩌구 저쩌구...

재부팅하니 이상없이 ip를 받아온다.