Showing posts with label CentOS 6.6 리눅스 네트워크. Show all posts
Showing posts with label CentOS 6.6 리눅스 네트워크. Show all posts

Sunday, April 1, 2018

CentOS 6.6 리눅스 네트워크 ] 13.3 iSCSI Tape Drive / Changer 간단 구성


안녕하세요. 썬구루입니다. 이 게시물에서 mhVTL를 설치한 CentOS 가상머신을 iSCSI Target으로 구성하고 Tape Drive와 Changer(Robot)을 iSCSI 디바이스로 구성하여 윈도우 서버에서 이를 끌어다 사용하는 방법에 대해 간단하게 설명드리도록 하겠습니다.

이 게시물은 백업 엔지니어 분들에게 굉장히 유용할 것입니다. 진심으로.. ㅎㅎㅎ..
저는 테이프 라이브러리(오토로더 아님)를 가지고 있지만 시끄럽고 전기세 많이 나가기 때문에 Backup Exec와 NetBackup을 테스트할 때 이 방법을 사용하였습니다.

외국 친구들도 이 방법을 사용하여 Legato Networker, NetVault 등을 테스트하고 있습니다.


■ mhVTL 설치한 CentOS 6.4 가상머신을 iSCSI Target으로 구성

CentOS 6.4를 설치한 가상머신에 mhVTL 패키지를 설치합니다. 그리고 아래와 같이 mhVTL에 관련된 device.conf 파일을 수정하여 디바이스를 줄입니다. 그리고 mhVTL 서비스를 재시작합니다.

[root@mhvtl01 ~]# cd /etc/mhvtl
[root@mhvtl01 mhvtl]# ls
device.conf  library_contents.10  library_contents.30  mhvtl.conf
[root@mhvtl01 mhvtl]#
[root@mhvtl01 mhvtl]# vi device.conf

VERSION: 5
# VPD page format:
# <page #> <Length> <x> <x+1>... <x+n>
# NAA format is an 8 hex byte value seperated by ':'
# Note: NAA is part of inquiry VPD 0x83
#
# Each 'record' is separated by one (or more) blank lines.
# Each 'record' starts at column 1
# Serial num max len is 10.
# Compression: factor X enabled 0|1
#     Where X is zlib compression factor 1 = Fastest compression
#      9 = Best compression
#     enabled 0 == off, 1 == on
#
# fifo: /var/tmp/mhvtl
# If enabled, data must be read from fifo, otherwise daemon will block
# trying to write.
# e.g. cat /var/tmp/mhvtl (in another terminal)
Library: 10 CHANNEL: 00 TARGET: 00 LUN: 00
 Vendor identification: STK
 Product identification: L700
 Unit serial number: XYZZY_A
 NAA: 10:22:33:44:ab:00:00:00
 Home directory: /opt/mhvtl
 PERSIST: False
 Backoff: 400
# fifo: /var/tmp/mhvtl
Drive: 11 CHANNEL: 00 TARGET: 01 LUN: 00
 Library ID: 10 Slot: 01
 Vendor identification: IBM
 Product identification: ULT3580-TD5
 Unit serial number: XYZZY_A1
 NAA: 10:22:33:44:ab:00:01:00
 Compression: factor 1 enabled 1
 Compression type: lzo
 Backoff: 400
# fifo: /var/tmp/mhvtl
Drive: 12 CHANNEL: 00 TARGET: 02 LUN: 00
 Library ID: 10 Slot: 02
 Vendor identification: IBM
 Product identification: ULT3580-TD5
 Unit serial number: XYZZY_A2
 NAA: 10:22:33:44:ab:00:02:00
 Compression: factor 1 enabled 1
 Compression type: lzo
 Backoff: 400
# fifo: /var/tmp/mhvtl
Drive: 13 CHANNEL: 00 TARGET: 03 LUN: 00
 Library ID: 10 Slot: 03
 Vendor identification: IBM
 Product identification: ULT3580-TD4
 Unit serial number: XYZZY_A3
 NAA: 10:22:33:44:ab:00:03:00
 Compression: factor 1 enabled 1
 Compression type: lzo
 Backoff: 400
# fifo: /var/tmp/mhvtl
Drive: 14 CHANNEL: 00 TARGET: 04 LUN: 00
 Library ID: 10 Slot: 04
 Vendor identification: IBM
 Product identification: ULT3580-TD4
 Unit serial number: XYZZY_A4
 NAA: 10:22:33:44:ab:00:04:00
 Compression: factor 1 enabled 1
 Compression type: lzo
 Backoff: 400

# fifo: /var/tmp/mhvtl

[root@mhvtl01 mhvtl]#
[root@mhvtl01 mhvtl]# service mhvtl stop
[root@mhvtl01 mhvtl]#
[root@mhvtl01 mhvtl]# service mhvtl start
You should think updating the kernel module for these
 daemons to 0.18.15.
Please see https://sites.google.com/site/linuxvtl2/home?pli=1#mhvtl-kernel-module
mhvtl already running...
[root@mhvtl01 mhvtl]#
[root@mhvtl01 mhvtl]# lsscsi -g
[1:0:0:0]    cd/dvd  NECVMWar VMware IDE CDR10 1.00  /dev/sr0   /dev/sg0
[2:0:0:0]    disk    VMware,  VMware Virtual S 1.0   /dev/sda   /dev/sg1
[3:0:8:0]    mediumx STK      L80              0105  /dev/sch1  /dev/sg11
[3:0:9:0]    tape    STK      T10000B          0105  /dev/st4   /dev/sg6
[3:0:10:0]   tape    STK      T10000B          0105  /dev/st7   /dev/sg9
[3:0:11:0]   tape    STK      T10000B          0105  /dev/st5   /dev/sg7
[3:0:12:0]   tape    STK      T10000B          0105  /dev/st6   /dev/sg8
[root@mhvtl01 mhvtl]#

CentOS 6.4 1번 DVD ISO 파일을 가상머신에 연결하여 아래와 같이 iSCSI Target에 관련된 패키지를 설치합니다.

[root@mhvtl01 mhvtl]# cd /media/CentOS_6.4_Final/Packages/
[root@mhvtl01 Packages]#
[root@mhvtl01 Packages]# rpm -ivh libibverbs-1.1.6-5.el6.x86_64.rpm
warning: libibverbs-1.1.6-5.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing...                ########################################### [100%]
   1:libibverbs             ########################################### [100%]
[root@mhvtl01 Packages]#
[root@mhvtl01 Packages]# rpm -ivh librdmacm-1.0.17-0.git4b5c1aa.el6.x86_64.rpm
warning: librdmacm-1.0.17-0.git4b5c1aa.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing...                ########################################### [100%]
   1:librdmacm              ########################################### [100%]
[root@mhvtl01 Packages]#
[root@mhvtl01 Packages]# rpm -ivh perl-Config-General-2.44-1.el6.noarch.rpm
warning: perl-Config-General-2.44-1.el6.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID c105b9de: NOKEY
Preparing...                ########################################### [100%]
   1:perl-Config-General    ########################################### [100%]
[root@mhvtl01 Packages]#
[root@mhvtl01 Packages]# rpm -ivh rdma-3.6-1.el6.noarch.rpm
warning: rdma-3.6-1.el6.noarch.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing...                ########################################### [100%]
   1:rdma                   ########################################### [100%]
[root@mhvtl01 Packages]#
[root@mhvtl01 Packages]# rpm -ivh sg3_utils-1.28-4.el6.x86_64.rpm
warning: sg3_utils-1.28-4.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing...                ########################################### [100%]
 package sg3_utils-1.28-4.el6.x86_64 is already installed
[root@mhvtl01 Packages]#
[root@mhvtl01 Packages]# rpm -ivh scsi-target-utils-1.0.24-2.el6.x86_64.rpm
warning: scsi-target-utils-1.0.24-2.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing...                ########################################### [100%]
   1:scsi-target-utils      ########################################### [100%]
[root@mhvtl01 Packages]# 

iSCSI에 관련된 target.conf 파일을 아래와 같이 수정한 후 관련 서비스를 시작합니다.

[root@mhvtl01 Packages]# vi /etc/tgt/targets.conf
[root@mhvtl01 Packages]#

<target iqn.localdcv.com.sunguru:mhvtl01-changer>
 <backing-store /dev/sg6>
  device-type pt
  bs-type sg
  lun 1
 </backing-store>
 <backing-store /dev/sg7>
  device-type pt
  bs-type sg
  lun 2
 </backing-store>
 <backing-store /dev/sg8>
  device-type pt
  bs-type sg
  lun 3
 </backing-store>
 <backing-store /dev/sg9>
  device-type pt
  bs-type sg
  lun 4
 </backing-store>
 <backing-store /dev/sg11>
  device-type pt
  bs-type sg
  lun 5
 </backing-store>
</target>
initiator-address 192.168.80.192

[root@mhvtl01 Packages]#





■ iSCSI Target 추가 설정

아래와 같이 SELinux 설정을 permissive로 그리고 iSCSI 서비스 포트 3260을 iptables 방화벽에서 열어줍니다.

[root@mhvtl01 Packages]# setenforce permissive
[root@mhvtl01 Packages]#
[root@mhvtl01 Packages]# vi /etc/sysconfig/selinux

SELINUX=permissive

[root@mhvtl01 Packages]#
[root@mhvtl01 Packages]# iptables -I INPUT -p tcp -m tcp --dport 3260 -j ACCEPT
[root@mhvtl01 Packages]#
[root@mhvtl01 Packages]# service iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[  OK  ]
[root@mhvtl01 Packages]# 

■ iSCSI Target 서비스 시작

[root@mhvtl01 Packages]# service tgtd start
Starting SCSI target daemon:                               [  OK  ]
[root@mhvtl01 Packages]#
[root@mhvtl01 Packages]# tgtadm --lld iscsi --op show --mode target

Target 1: iqn.localdcv.com.sunguru:mhvtl01-changer1
    System information:
        Driver: iscsi
        State: ready
    I_T nexus information:
    LUN information:
        LUN: 0
            Type: controller
            SCSI ID: IET     00010000
            SCSI SN: beaf10
            Size: 0 MB, Block size: 1
            Online: Yes
            Removable media: No
            Prevent removal: No
            Readonly: No
            Backing store type: null
            Backing store path: None
            Backing store flags:
        LUN: 1
            Type: passthrough
            SCSI ID: IET     00010001
            SCSI SN: beaf11
            Size: 0 MB, Block size: 1
            Online: Yes
            Removable media: No
            Prevent removal: No
            Readonly: No
            Backing store type: sg
            Backing store path: /dev/sg6
            Backing store flags:
        LUN: 2
            Type: passthrough
            SCSI ID: IET     00010002
            SCSI SN: beaf12
            Size: 0 MB, Block size: 1
            Online: Yes
            Removable media: No
            Prevent removal: No
            Readonly: No
            Backing store type: sg
            Backing store path: /dev/sg7
            Backing store flags:
        LUN: 3
            Type: passthrough
            SCSI ID: IET     00010003
            SCSI SN: beaf13
            Size: 0 MB, Block size: 1
            Online: Yes
            Removable media: No
            Prevent removal: No
            Readonly: No
            Backing store type: sg
            Backing store path: /dev/sg8
            Backing store flags:
        LUN: 4
            Type: passthrough
            SCSI ID: IET     00010004
            SCSI SN: beaf14
            Size: 0 MB, Block size: 1
            Online: Yes
            Removable media: No
            Prevent removal: No
            Readonly: No
            Backing store type: sg
            Backing store path: /dev/sg9
            Backing store flags:
        LUN: 5
            Type: passthrough
            SCSI ID: IET     00010005
            SCSI SN: beaf15
            Size: 0 MB, Block size: 1
            Online: Yes
            Removable media: No
            Prevent removal: No
            Readonly: No
            Backing store type: sg
            Backing store path: /dev/sg11
            Backing store flags:
    Account information:
    ACL information:
        ALL

[root@mhvtl01 Packages]#
[root@mhvtl01 Packages]# chkconfig mhvtl on
[root@mhvtl01 Packages]# chkconfig tgtd on
[root@mhvtl01 Packages]# 

■ Windows Server 2008 R2에서 iSCSI Initiator 구성

이전 게시물을 참고하여 iSCSI Initiator로 구성합니다.



iSCSI Initiator 구성을 완료하면 작업표시줄에 있는 서버 관리자(Server Manager) 아이콘을 실행합니다. 그리고 Device Manager을 선택하여 디바이스를 확인하면 Changer와 Tape Drive 가 연결된 것을 확인할 수 있습니다.


백업 솔루션 프로그램을 설치하면 프로그램 내에 있는 디바이스 드라이버를 사용하여 관련된 디바이스 모델을 정확하게 알 수 있습니다. 이를 통해 Veritas NetBackup, EMC Legato Networker 등 백업 솔루션 테스트를 해볼 수 있습니다. 전에도 언급했듯이 백업 솔루션 엔지니어에게는 테이프 라이브러리를 다루는 것이 매우 중요하거든요. 그럼 이 게시물은 여기까지 설명드리도록 하겠습니다.






CentOS 6.6 리눅스 네트워크 ] 13.2 iSCSI Initiator 간단 구성


안녕하세요. 썬구루입니다.  이 게시물에서 CentOS 6.6 리눅스를 iSCSI Initiator으로 구성 방법에 대해 간단하게 알아보도록 하겠습니다.

이전 게시물에서 CentOS 6.6 리눅스를 가지고 iSCSI Target 을 구성하는 방법에 대해 알아보았습니다. 20GB 용량의 /dev/sdb, /dev/sdc를 iSCSI 디바이스로 구성하였죠. 그럼 이 iSCSI 디바이스를 잡아 사용할 수 있도록 리눅스, 윈도우 서버, 솔라리스를 iSCSI initiator로 구성해보도록 하겠습니다. 요즘 나오는 서버 운영체제는 iSCSI Initiator를 지원합니다.


■ iSCSI Initiator IP 주소

iSCSI Initiator 테스트를 위한 가상머신 환경은 아래와 같습니다.

가상머신
IP 주소
리눅스
 192.168.80.182
윈도우서버
 192.168.80.183
솔라리스
 192.168.80.184

■ CentOS 6.6 리눅스를 iSCSI Initiator로 구성

iSCSI Initiator로 사용할 가상머신을 생성한 후 CentOS 6.6을 설치합니다. 기존 가상머신 복제를 하셔도 됩니다. CentOS 6.6 DVD 1번 ISO 파일을 가상머신에 연결한 후 아래와 같은 명령을 사용하여 iSCSI Initiator 패키지를 설치합니다.

[root@iscsi02 ~]# ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 00:0C:29:7B:A1:FC
          inet addr:192.168.80.182  Bcast:192.168.80.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe7b:a1fc/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:58 errors:0 dropped:0 overruns:0 frame:0
          TX packets:36 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:14566 (14.2 KiB)  TX bytes:2455 (2.3 KiB)
[root@iscsi02 ~]# lsblk | grep disk
sda                     8:0    0   20G  0 disk
[root@iscsi02 ~]#
[root@iscsi02 ~]# cd /media/CentOS_6.6_Final/Packages/
[root@iscsi02 Packages]# rpm -ivh iscsi-initiator-utils-6.2.0.873-13.el6.x86_64.rpm
warning: iscsi-initiator-utils-6.2.0.873-13.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing...                ########################################### [100%]
   1:iscsi-initiator-utils  ########################################### [100%]
[root@iscsi02 Packages]# 

그리고 아래와 같은 명령을 실행하여 iSCSI Target의 디바이스를 확인합니다. 그러면 IQN 주소로 내용이 출력됩니다.

[root@iscsi02 Packages]# iscsiadm -m discovery -t sendtargets -p 192.168.80.181
Starting iscsid:                                           [  OK  ]
192.168.80.181:3260,1 iqn.iscsi01.localdcv.com:server.target1
[root@iscsi02 Packages]#
[root@iscsi02 Packages]# chkconfig iscsid --list
iscsid          0:off 1:off 2:off 3:on 4:on 5:on 6:off
[root@iscsi02 Packages]# 

아래와 같은 명령을 사용하여 iSCSI Target 을 연결합니다. 그리고 연결된 iSCSI 디바이스를 확인합니다.

[root@iscsi02 Packages]# iscsiadm -m node -T iqn.iscsi01.localdcv.com:server.target1 --login
Logging in to [iface: default, target: iqn.iscsi01.localdcv.com:server.target1, portal: 192.168.80.181,3260] (multiple)
Login to [iface: default, target: iqn.iscsi01.localdcv.com:server.target1, portal: 192.168.80.181,3260] successful.
[root@iscsi02 Packages]# lsblk | grep disk
sda                     8:0    0   20G  0 disk
sdb                     8:16   0   20G  0 disk 
sdc                     8:32   0   20G  0 disk 
[root@iscsi02 Packages]# 

아래와 같이 명령을 사용하여 /dev/sdb iSCSI 디바이스에 EXT 파일시스템을 생성 후 마운트 해봅니다.

[root@iscsi02 Packages]# iscsiadm -m node -T iqn.iscsi01.localdcv.com:server.target1 --login
Logging in to [iface: default, target: iqn.iscsi01.localdcv.com:server.target1, portal: 192.168.80.181,3260] (multiple)
Login to [iface: default, target: iqn.iscsi01.localdcv.com:server.target1, portal: 192.168.80.181,3260] successful.

[root@iscsi02 Packages]# lsblk | grep disk
sda                     8:0    0   20G  0 disk
sdb                     8:16   0   20G  0 disk
sdc                     8:32   0   20G  0 disk
[root@iscsi02 Packages]#
[root@iscsi02 Packages]# pvcreate /dev/sdb
  Physical volume "/dev/sdb" successfully created
[root@iscsi02 Packages]#
[root@iscsi02 Packages]# vgcreate testvg /dev/sdb
  Volume group "testvg" successfully created
[root@iscsi02 Packages]#
[root@iscsi02 Packages]# lvcreate -L 5g -n test testvg
  Logical volume "test" created
[root@iscsi02 Packages]# lvscan
  ACTIVE            '/dev/testvg/test' [5.00 GiB] inherit
  ACTIVE            '/dev/vg_os/root' [15.80 GiB] inherit
  ACTIVE            '/dev/vg_os/swap' [4.00 GiB] inherit
[root@iscsi02 Packages]#
[root@iscsi02 Packages]# mkfs -t ext4 /dev/testvg/test
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
327680 inodes, 1310720 blocks
65536 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1342177280
40 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
 32768, 98304, 163840, 229376, 294912, 819200, 884736
Writing inode tables: done                   
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 26 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[root@iscsi02 Packages]#
[root@iscsi02 Packages]# mkdir /test
[root@iscsi02 Packages]#
[root@iscsi02 Packages]# mount /dev/testvg/test /test
[root@iscsi02 Packages]# df -h /test
Filesystem                                        Size  Used Avail Use% Mounted on
/dev/mapper/testvg-test                    4.8G   10M  4.6G   1% /test
[root@iscsi02 Packages]#
[root@iscsi02 Packages]# pvscan
  PV /dev/sdb    VG testvg   lvm2 [20.00 GiB / 15.00 GiB free]
  PV /dev/sda2   VG vg_os    lvm2 [19.80 GiB / 0    free]
  Total: 2 [39.80 GiB] / in use: 2 [39.80 GiB] / in no VG: 0 [0   ]
[root@iscsi02 Packages]# 

아래와 같은 명령을 사용하여 iSCSI 디바이스 연결을 끊습니다.

[root@iscsi02 Packages]# umount /test
[root@iscsi02 Packages]# iscsiadm -m node -T iqn.iscsi01.localdcv.com:server.target1 --logout
Logging out of session [sid: 1, target: iqn.iscsi01.localdcv.com:server.target1, portal: 192.168.80.181,3260]
Logout of [sid: 1, target: iqn.iscsi01.localdcv.com:server.target1, portal: 192.168.80.181,3260] successful.
[root@iscsi02 Packages]#
[root@iscsi02 Packages]# lsblk | grep disk
sda                     8:0    0   20G  0 disk
[root@iscsi02 Packages]# 




■ Windows Server 2008 R2을 iSCSI Initiator로 구성

Windows Server 2008 R2 평가판은 아래와 같은 사이트에서 다운로드할 수 있습니다. Windows Server 2008 R2 평가판을 설치한 수 IP 주소를 설정합니다. 그리고 제어판을 실행하여 아래와 같이 iSCSI initiator 관련 내용을 찾습니다. 그리고 iSCSI Initiator를 실행합니다. 그러면 아래와 같은 화면이 나타납니다.


아래 그림과 같이 Target 부분에 iSCSI Target IP 주소인 192.168.80.181을 입력한 후 Quick Connect 버튼을 선택합니다.


설정이 완료되면 아래와 같이 연결된 내용을 확인할 수 있습니다.


작업표시줄에 있는 서버 관리자 (Server Manager)를 실행한 후 Storage > Disk Management를 선택하면 iSCSI 디바이스가 연결, 인식되어 있는 것을 확인할 수 있습니다.


새 볼륨을 추가, NTFS 파일시스템을 생성한 후 E:\ 드라이브에 연결해봅니다. 이제 iSCSI 디바이스에 생성된 NTFS 파일시스템 위에 파일을 저장할 수 있습니다.


Windows Server 2008 R2에 대한 iSCSI Initiator 테스트를 종료하기 위해 제어판에서 iSCSI Initiator를 실행한 후 아래 그림과 같이 Discovery 탭(Tab)에서 Remove  버튼을 선택합니다.


그러면 관련된 정보는 사라지고 iSCSI 디바이스 연결은 끊어집니다.




■ Solaris 10을 iSCSI Initiator로 구성

Solaris 10은 아래와 같은 웹사이트에서 다운로드할 수 있습니다.

http://www.oracle.com/technetwork/server-storage/solaris10/downloads/index.html

아래와 같은 명령을 사용하여 iSCSI Target과 연결합니다. 연결하기 전 format 명령을 사용하면 c1t0d0 디스크 하나만 보이는 것을 확인할 수 있습니다.

-bash-3.00# iscsiadm modify discovery --sendtargets enable
-bash-3.00#
-bash-3.00# format
Searching for disks...done

AVAILABLE DISK SELECTIONS:
       0. c1t0d0 <DEFAULT cyl 2607 alt 2 hd 255 sec 63>
          /pci@0,0/pci15ad,1976@10/sd@0,0
Specify disk (enter its number): ^D
-bash-3.00#
-bash-3.00# iscsiadm add discovery-address 192.168.80.181
-bash-3.00#

iSCSI Target과 연결 후 아래와 같이 format 명령을 사용하면 iSCSI 디바이스가 연결된 것을 확인할 수 있다. format 명령을 사용하여 파티션 분할 후 newfs 명령으로 UFS 파일시스템을 만들어 아래와 같이 /test 디렉터리에 연결해봅니다.

-bash-3.00# format
Searching for disks...
The device does not support mode page 3 or page 4,
or the reported geometry info is invalid.
WARNING: Disk geometry is based on capacity data.
The current rpm value 0 is invalid, adjusting it to 3600
The device does not support mode page 3 or page 4,
or the reported geometry info is invalid.
WARNING: Disk geometry is based on capacity data.
The current rpm value 0 is invalid, adjusting it to 3600
done
c2t2d0: configured with capacity of 19.98GB
c2t3d0: configured with capacity of 19.98GB

AVAILABLE DISK SELECTIONS:
       0. c1t0d0 <DEFAULT cyl 2607 alt 2 hd 255 sec 63>
          /pci@0,0/pci15ad,1976@10/sd@0,0
       1. c2t2d0 <IET-VIRTUAL-DISK-0001 cyl 2608 alt 2 hd 255 sec 63>
          /iscsi/disk@0000iqn.iscsi01.localdcv.com%3Aserver.target10001,1
       2. c2t3d0 <IET-VIRTUAL-DISK-0001 cyl 2608 alt 2 hd 255 sec 63>
          /iscsi/disk@0000iqn.iscsi01.localdcv.com%3Aserver.target10001,2
Specify disk (enter its number): 1
selecting c2t2d0
[disk formatted]
Disk not labeled.  Label it now? y
Warning: error setting drive geometry.
Warning: error writing VTOC.
Warning: no backup labels
Write label failed

FORMAT MENU:
        disk       - select a disk
        type       - select (define) a disk type
        partition  - select (define) a partition table
        current    - describe the current disk
        format     - format and analyze the disk
        fdisk      - run the fdisk program
        repair     - repair a defective sector
        label      - write label to the disk
        analyze    - surface analysis
        defect     - defect list management
        backup     - search for backup labels
        verify     - read and display labels
        save       - save new disk/partition definitions
        inquiry    - show vendor, product and revision
        volname    - set 8-character volume name
        !<cmd>     - execute <cmd>, then return
        quit
format> fdisk
No fdisk table exists. The default partition for the disk is:
  a 100% "SOLARIS System" partition
Type "y" to accept the default partition,  otherwise type "n" to edit the
 partition table.
y
format> p

PARTITION MENU:
        0      - change `0' partition
        1      - change `1' partition
        2      - change `2' partition
        3      - change `3' partition
        4      - change `4' partition
        5      - change `5' partition
        6      - change `6' partition
        7      - change `7' partition
        select - select a predefined table
        modify - modify a predefined partition table
        name   - name the current table
        print  - display the current table
        label  - write partition map and label to the disk
        !<cmd> - execute <cmd>, then return
        quit
partition> 0
Part      Tag    Flag     Cylinders        Size            Blocks
  0 unassigned    wm       0               0         (0/0/0)           0
Enter partition id tag[unassigned]:
Enter partition permission flags[wm]:
Enter new starting cyl[0]:
Enter partition size[0b, 0c, 0e, 0.00mb, 0.00gb]: $
partition> print
Current partition table (unnamed):
Total disk cylinders available: 2607 + 2 (reserved cylinders)
Part      Tag    Flag     Cylinders        Size            Blocks
  0 unassigned    wm       0 - 2606       19.97GB    (2607/0/0) 41881455
  1 unassigned    wm       0               0         (0/0/0)           0
  2     backup    wu       0 - 2606       19.97GB    (2607/0/0) 41881455
  3 unassigned    wm       0               0         (0/0/0)           0
  4 unassigned    wm       0               0         (0/0/0)           0
  5 unassigned    wm       0               0         (0/0/0)           0
  6 unassigned    wm       0               0         (0/0/0)           0
  7 unassigned    wm       0               0         (0/0/0)           0
  8       boot    wu       0 -    0        7.84MB    (1/0/0)       16065
  9 unassigned    wm       0               0         (0/0/0)           0
partition> label
Ready to label disk, continue? y
partition> quit

FORMAT MENU:
        disk       - select a disk
        type       - select (define) a disk type
        partition  - select (define) a partition table
        current    - describe the current disk
        format     - format and analyze the disk
        fdisk      - run the fdisk program
        repair     - repair a defective sector
        label      - write label to the disk
        analyze    - surface analysis
        defect     - defect list management
        backup     - search for backup labels
        verify     - read and display labels
        save       - save new disk/partition definitions
        inquiry    - show vendor, product and revision
        volname    - set 8-character volume name
        !<cmd>     - execute <cmd>, then return
        quit
format> quit
-bash-3.00# newfs /dev/rdsk/c2t2d0s0
newfs: construct a new file system /dev/rdsk/c2t2d0s0: (y/n)?
-bash-3.00# newfs /dev/rdsk/c2t2d0s0
newfs: construct a new file system /dev/rdsk/c2t2d0s0: (y/n)? y
Warning: inode blocks/cyl group (431) >= data blocks (246) in last
    cylinder group. This implies 3950 sector(s) cannot be allocated.
/dev/rdsk/c2t2d0s0:     41877504 sectors in 6816 cylinders of 48 tracks, 128 sectors
        20448.0MB in 426 cyl groups (16 c/g, 48.00MB/g, 5824 i/g)
super-block backups (for fsck -F ufs -o b=#) at:
 32, 98464, 196896, 295328, 393760, 492192, 590624, 689056, 787488, 885920,
Initializing cylinder groups:
........
super-block backups for last 10 cylinder groups at:
 40898592, 40997024, 41095456, 41193888, 41292320, 41390752, 41489184,
 41587616, 41686048, 41784480
-bash-3.00#
-bash-3.00# mkdir /test
-bash-3.00#
-bash-3.00# mount /dev/dsk/c2t2d0s0 /test
-bash-3.00# df -hF ufs
Filesystem             size   used  avail capacity  Mounted on
/dev/dsk/c1t0d0s0       16G   3.8G    12G    25%    /
/dev/dsk/c2t2d0s0       20G    20M    19G     1%    /test
-bash-3.00#

아래와 같은 명령을 사용하여 iSCSI Target과 연결을 끊습니다. 그리고 format 명령을 사용하면 iSCSI 디바이스 연결도 끊어진 것을 확인할 수 있습니다.

-bash-3.00# umount /test
-bash-3.00#
-bash-3.00# df -hF ufs
Filesystem             size   used  avail capacity  Mounted on
/dev/dsk/c1t0d0s0       16G   3.8G    12G    25%    /
-bash-3.00#
-bash-3.00# iscsiadm list discovery-address 192.168.80.181
Discovery Address: 192.168.80.181:3260
-bash-3.00#
-bash-3.00# iscsiadm remove discovery-address 192.168.80.181
-bash-3.00#
-bash-3.00# iscsiadm list discovery-address 192.168.80.181
192.168.80.181: not found
-bash-3.00#
-bash-3.00# format
Searching for disks...done

AVAILABLE DISK SELECTIONS:
       0. c1t0d0 <DEFAULT cyl 2607 alt 2 hd 255 sec 63>
          /pci@0,0/pci15ad,1976@10/sd@0,0
Specify disk (enter its number): ^D
-bash-3.00#

이 게시물에서 iSCSI 서비스를 통해 Raw Device를 공유할 수 있다는 것을 알았습니다. NAS 디스크 스토리지의 기능을 사용하여 iSCSI를 현업에서 사용하고 있습니다. 우리는 비싼 스토리지를 사용할 수 없기 때문에 CentOS 6.6 리눅스를 가지고 구현한 것이고요. ^^

다음 게시물에서 Backup Tape Drive와 Changer를 iSCSi 디바이스로 사용하는 방법에 대해 간단히 알아보도록 하겠습니다.






CentOS 6.6 리눅스 네트워크 ] 13.1 iSCSI Target 간단 구성


안녕하세요. 썬구루입니다. 이 게시물에서는 CentOS 6.6 리눅스를 iSCSI Target으로 구성 방법에 대해 간단하게 알아보도록 하겠습니다.

디스크 스토리지 연결 방식은 DAS, NAS, SAN으로 나누어지는데 여기서 요즘 NAS 디스크 스토리지는 NFS, CIFS, iSCSI를 지원합니다. NFS나 CIFS는 이미 앞에서 언급하고 구성해보았기 때문에 기억하고 있을 것이라 생각됩니다. 이는 스토리지에서 지원하는 파일시스템을 사용하는 것이죠.

저희가 CentOS 6.6을 사용했었고 그 기반에 NFS 서버와 Samba 서버를 구성한 것이기 때문에 CentOS 6.6의 EXT 파일시스템을 사용한 것입니다. iSCSI는 Internet SCSI(Smail Computer System Interface)를 나타내며 SCSI 프로토콜을 IP 패킷에 실어 전달할 수 있는 다시 말해 IP 기반 스토리지 네트워킹 기술을 사용할 수 있도록 해주는 기술입니다.

이는 이미 파일시스템이 만들어진 파일시스템 공유가 아닌 Raw Device를 네트워크를 통해 공유할 수 있도록 만들어주는 기술입니다.

서버의 하드 디스크, 테이프 드라이브, 로봇 디바이스 등을 iSCSI를 통해 다른 서버로 공유해줄 수 있는 것입니다. 만약 iSCSI를 통해 공유 받은 하드디스크를 리눅스(Linux)가 사용한다면 EXT 파일시스템을 만들어 사용할 수 있고 윈도우(Windows)가 사용한다면 NTFS, 솔라리스(Solaris)가 사용한다면 UFS 또는 ZFS 파일시스템을 만들어 사용할 수 있습니다. 왜? Raw Device를 공유하는 것이기 때문입니다.

그래서 여러분들은 VMware Workstation 환경에서 아래와 같은 공유 디바이스(또는 파일시스템)를 만들어 사용할 수 있습니다.

▶ NFS
▶ CIFS
▶ Shared SCSI
▶ iSCSI
▶ Tape drive
▶ Changer (Tape Library Robot)

이러한 공유 디바이스(또는 파일시스템)을 가지고 아래와 같은 서비스를 테스트할 수 있습니다.

▶ WEB/WAS 이중화
▶ 클러스터 파일시스템 (Cluster Filesystem)
▶ 클러스터 서버 (Cluster Server)
▶ 서버 가상화 (Server Virtualization)
▶ 데스크탑 가상화 (Desktop Virtualization)
▶ 클라우드 서비스 (Cloud Service)
▶ Oracle RAC
▶ 백업 솔루션 (Veritas NetBackup, Dell NetVault, Legato Networker)

어잇~!!! iSCSI 설명하다가 배가 산으로 갔군요. CentOS 6.6 리눅스를 가지고 간단하게 iSCSI Targer으로 구성해보도록 하겠습니다. iSCSI에서는 서버를 iSCSI Target, 클라이언트를 iSCSI Initiator라 합니다.

■ CentOS 6.6 리눅스에 iSCSI Target 패키지 설치

iSCSI Target 테스트를 위한 가상머신 환경은 아래와 같습니다.

사 양
내 용
CPU
 1 CPU / 2 Cores
MEM
 2GB
HDD
 20GB  /dev/sda   운영체제
 20GB  /dev/sdb   iSCSI 디바이스
 20GB  /dev/sdc   iSCSI 디바이스
NIC
 1Gbps
OS
 CentOS 6.6

iSCSI Target을 구성하기 위해 아래와 같은 패키지가 CentOS 6.6에 설치되어야 합니다.

libibverbs-1.1.8-3.el6.x86_64.rpm
librdmacm-1.0.18.1-1.el6.x86_64.rpm
perl-Config-General-2.52-1.el6.noarch.rpm
rdma-6.6_3.15-1.el6.noarch.rpm
sg3_utils-1.28-6.el6.x86_64.rpm
scsi-target-utils-1.0.24-16.el6.x86_64.rpm

iSCSI Target으로 구성할 가상머신에 CentOS 6.6 1번 DVD ISO 파일을 연결하고 아래와 같은 명령을 사용하여 관련 패키지를 설치합니다.

[root@iscsi01 ~]# cd /media/CentOS_6.6_Final/Packages/
[root@iscsi01 Packages]#
[root@iscsi01 Packages]# rpm -ivh libibverbs-1.1.8-3.el6.x86_64.rpm
warning: libibverbs-1.1.8-3.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing...                ########################################### [100%]
   1:libibverbs             ########################################### [100%]
[root@iscsi01 Packages]#
[root@iscsi01 Packages]# rpm -ivh librdmacm-1.0.18.1-1.el6.x86_64.rpm
warning: librdmacm-1.0.18.1-1.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing...                ########################################### [100%]
   1:librdmacm              ########################################### [100%]
[root@iscsi01 Packages]#
[root@iscsi01 Packages]# rpm -ivh perl-Config-General-2.52-1.el6.noarch.rpm
warning: perl-Config-General-2.52-1.el6.noarch.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing...                ########################################### [100%]
   1:perl-Config-General    ########################################### [100%]
[root@iscsi01 Packages]#
[root@iscsi01 Packages]# rpm -ivh rdma-6.6_3.15-1.el6.noarch.rpm
warning: rdma-6.6_3.15-1.el6.noarch.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing...                ########################################### [100%]
   1:rdma                   ########################################### [100%]
[root@iscsi01 Packages]#
[root@iscsi01 Packages]# rpm -ivh sg3_utils-1.28-6.el6.x86_64.rpm
warning: sg3_utils-1.28-6.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing...                ########################################### [100%]
   1:sg3_utils              ########################################### [100%]
[root@iscsi01 Packages]#
[root@iscsi01 Packages]# rpm -ivh scsi-target-utils-1.0.24-16.el6.x86_64.rpm
warning: scsi-target-utils-1.0.24-16.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing...                ########################################### [100%]
   1:scsi-target-utils      ########################################### [100%]
[root@iscsi01 Packages]#
[root@iscsi01 Packages]# service tgtd status
tgtd is stopped
[root@iscsi01 Packages]#
[root@iscsi01 Packages]# lsblk
NAME                  MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                     8:0    0   20G  0 disk
├─sda1                  8:1    0  200M  0 part /boot
└─sda2                  8:2    0 19.8G  0 part
  ├─vg_os-root (dm-0) 253:0    0 15.8G  0 lvm  /
  └─vg_os-swap (dm-1) 253:1    0    4G  0 lvm  [SWAP]
sdb                     8:16   0   20G  0 disk
sdc                     8:32   0   20G  0 disk
sr0                    11:0    1  4.3G  0 rom  /media/CentOS_6.6_Final
[root@iscsi01 Packages]# 

■ iSCSI Target 디바이스 구성

/etc/tgt/targets.conf 파일의 제일 아래에 아래와 같은 내용을 추가하였습니다.

[root@iscsi01 Packages]# tail /etc/tgt/targets.conf

<target iqn.iscsi01.localdcv.com:server.target1>
  backing-store /dev/sdb
  backing-store /dev/sdc
</target>

[root@iscsi01 Packages]# 

■ iSCSI Target 추가 설정

아래와 같이 SELinux 설정을 permissive로 그리고 iSCSI 서비스 포트 3260을 iptables 방화벽에서 열어줍니다.

[root@iscsi01 Packages]# setenforce permissive
[root@iscsi01 Packages]#
[root@iscsi01 Packages]# vi /etc/sysconfig/selinux

SELINUX=permissive

[root@iscsi01 Packages]#
[root@iscsi01 Packages]# iptables -I INPUT -p tcp -m tcp --dport 3260 -j ACCEPT
[root@iscsi01 Packages]#
[root@iscsi01 Packages]# service iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[  OK  ]
[root@iscsi01 Packages]# 

■ iSCSI Target 서비스 시작

아래와 같이 service 명령을 사용하여 iSCSI Target 서비스인 tgtd를 시작시킵니다. 그리고 tgt-admin 명령으로 iSCSI Target 디바이스를 확인합니다.

[root@iscsi01 Packages]# service tgtd start
Starting SCSI target daemon:                               [  OK  ]
[root@iscsi01 Packages]#
[root@iscsi01 Packages]# chkconfig tgtd on
[root@iscsi01 Packages]#
[root@iscsi01 Packages]# tgt-admin -s

Target 1: iqn.iscsi01.localdcv.com:server.target1
    System information:
        Driver: iscsi
        State: ready
    I_T nexus information:
    LUN information:
        LUN: 0
            Type: controller
            SCSI ID: IET     00010000
            SCSI SN: beaf10
            Size: 0 MB, Block size: 1
            Online: Yes
            Removable media: No
            Prevent removal: No
            Readonly: No
            Backing store type: null
            Backing store path: None
            Backing store flags:
        LUN: 1
            Type: disk
            SCSI ID: IET     00010001
            SCSI SN: beaf11
            Size: 21475 MB, Block size: 512
            Online: Yes
            Removable media: No
            Prevent removal: No
            Readonly: No
            Backing store type: rdwr
            Backing store path: /dev/sdb
            Backing store flags:
        LUN: 2
            Type: disk
            SCSI ID: IET     00010002
            SCSI SN: beaf12
            Size: 21475 MB, Block size: 512
            Online: Yes
            Removable media: No
            Prevent removal: No
            Readonly: No
            Backing store type: rdwr
            Backing store path: /dev/sdc
            Backing store flags:
    Account information:
    ACL information:
        ALL

[root@iscsi01 Packages]# 

여기까지 iSCSI Target 간단 구성에 대해 알아보았습니다. 다음 게시물에서 리눅스, 윈도우 서버, 솔라리스를 가지고 iSCSI Initiator를 만들어보도록 하겠습니다.






CentOS 6.6 리눅스 네트워크 ] 12.1 iptables 리눅스 방화벽 간단 구성


안녕하세요. 썬구루입니다. 이 게시물에서는 CentOS 리눅스 iptable 방화벽 구성 방법에 대해 간단하게 알아보도록 하겠습니다.

요즘에는 보안이 많이 중요해졌습니다. 일 년에 한두 번은 대형 해킹 사고가 터지고 있습니다. 전산실에는 네트워크 보안을 담당하는 방화벽이 있긴 하지만 개별 서버 시스템에 대해서도 보안에 각별한 신경을 쓰고 있습니다. 서버 보안, 네트워크 보안, 응용 보안, 코드 보안 등등..

요즘 운영체제는 보안 기능이 기본 탑재되어 있습니다. 윈도우는 윈도우 방화벽이, 솔라리스는 IPFilter가 리눅스는 iptables이 보안 기능을 제공합니다. 또는 Red Castle이나 Red Owl 같은 상용 보안 프로그램을 운영체제에 설치하여 운영하는 곳도 있습니다. 우리는 이 게시물에서 iptables을 가지고 간단하게 보안 설정하는 방법에 대해 알아보도록 하겠습니다. 상세 내용은 다른 것과 마찬가지로 올해 말 또는 내년 초에 올리도록 하겠습니다.

■ iptables이란?

리눅스 운영체제에 기본 탑재된 패킷 필터링 툴(Tool)이자 OS 방화벽입니다. iptables는 방화벽 기능을 구현할 수 있게 해주는 프레임워크를 제공하는 Netfilter이며 이는 프로젝트명입니다.


1). iptables 기능

iptables는 아래와 같은 기능을 제공합니다.

▶ 상태 추적 기능

  - 방화벽을 통과하는 모든 패킷에 대한 상태를 추적하여 메모리에 기억
  - 기존의 연결을 가장하여 접근할 경우 메모리와 저장된 목록과 비교 후 차단

▶ 포트 포워딩 기능 내장

  - NAT 기능을 자체적으로 포함 ( 공유기 기능으로 생각하면 편리함. )

▶ 향상된 매칭 기능

  - 기본 매칭 정보인 IP 주소와 포트 주소뿐만 아니라 다양한 매칭 기능 제공
  - 현재 연결 상태, MAC 주소, IP 헤더의 TOS 등 여러 가지 조건을 이용한 세부적인 필터링 가능

2). iptables의 4개 테이블

다른 방화벽 프로그램에 비해 빠르며 IP 패킷에 대한 제어가 가능합니다. Iptables는 다음과 같은 4개 테이블이 존재합니다. 그리고 이 게시물에서 Filter만 다룹니다.

▶ Filter : iptables의 패킷 필터링 담당
▶ NAT : 네트워크 주소 변환(Network Address Translation)의 약자로 IP 주소를 변환시키는 역할
▶ Mangle : 패킷 데이터를 변경하는 특수 규칙을 적용하거나 성능 향상을 위한 TOS 설정
▶ Raw : 넷필터의 연결 추적 하위시스템과 독립적으로 동작해야 하는 규칙을 설정

3). iptables의 Filter table 3개 체인 (Chain)

▶ INPUT : 외부에서 들어오는 패킷을 담당하는 체인
▶ OUTPUT : 외부로 나가는 패킷을 담당하는 체인
▶ FORWARD : 외부에서 다른 시스템 또는 네트워크로 전달되는 패킷을 담당하는 체인

4). iptables이 적용되는 시기

▶ iptables 서비스가 적용될 때
▶ iptables 명령을 통해 규칙을 적용시킬 때 즉시 적용


■ iptables 기본 명령

1). iptables 기본 명령

기본 명령
내 용
-A Chain
 규칙을 아래에 추가하기 위해 사용
-D Chain
 규칙을 삭제
-D Chain RULENUM
 해당 번호 규칙을 삭제
-I Chain
 규칙 삽입
-R Chain RULENUM
 해당 번호 규칙 변경
-L [Chain]
 전체 또는 특정 체인 규칙보기
-F [Chain]
 전체 또는 특정 체인 초기화

2). iptables 명령어 Match 옵션

Match
내 용
-p PROTOCOL
 프로토콜 이름 또는 숫자 (tcp, udp, icmp, all 등)
-s ADDRESS/MASK
 근원지 IP 주소
-d ADDRESS/MASK
 목적지 IP 주소
--sport PORT
 근원지 포트 주소
--dport PORT
 목적지 포트 주소

3). iptables 명령어 Target

Target은 매치되는 패킷을 어떻게 처리할지 지정하는 부분입니다.

Target 옵션
내 용
-j ACCEPT
 패킷 허용
-j DROP
 패킷 폐기
-j REJECT
 패킷 거부

4). ping(IPMP) 신호 거부 테스트

WAS01(192.168.80.22) 가상머신에 iptables를 활성화한 후 방화벽 정책 추가로 ping 신호가 거부되는지 테스트합니다.

[root@was01 ~]# hostname
was01
[root@was01 ~]# ifconfig eth0

eth0      Link encap:Ethernet  HWaddr 00:0C:29:3E:63:0B
          inet addr:192.168.80.22  Bcast:192.168.80.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe3e:630b/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:29787 errors:0 dropped:0 overruns:0 frame:0
          TX packets:16687 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:30793923 (29.3 MiB)  TX bytes:4034939 (3.8 MiB)

[root@was01 ~]# service iptables start
iptables: Applying firewall rules:                         [  OK  ]
[root@was01 ~]#
[root@was01 ~]# chkconfig iptables on
[root@was01 ~]#
[root@was01 ~]# iptables -L

Chain INPUT (policy ACCEPT)
target     prot opt source               destination 
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED
ACCEPT     icmp --  anywhere             anywhere     
ACCEPT     all  --  anywhere             anywhere     
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:ssh
REJECT     all  --  anywhere             anywhere            reject-with icmp-host-prohibited

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination 
REJECT     all  --  anywhere             anywhere            reject-with icmp-host-prohibited

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

[root@was01 ~]#
[root@was01 ~]# iptables -I INPUT -p icmp -j DROP
[root@was01 ~]#
[root@was01 ~]# iptables -L | grep icmp

DROP       icmp --  anywhere             anywhere     
ACCEPT     icmp --  anywhere             anywhere     
REJECT     all  --  anywhere             anywhere            reject-with icmp-host-prohibited
REJECT     all  --  anywhere             anywhere            reject-with icmp-host-prohibited

[root@was01 ~]# 

Windows 8.1 가상머신에서 WAS01로 ping 테스트를 하면 ping 신호가 처리가 되지 않는 것을 확인할 수 있습니다.


아래와 같은 명령을 사용하여 추가한 정책을 삭제하면 다시 ping 테스트가 정상 처리되는 것을 확인할 수 있습니다.

[root@was01 ~]# iptables -D INPUT -p icmp -j DROP
[root@was01 ~]#
[root@was01 ~]# iptables -L | grep icmp
ACCEPT     icmp --  anywhere             anywhere     
REJECT     all  --  anywhere             anywhere            reject-with icmp-host-prohibited
REJECT     all  --  anywhere             anywhere            reject-with icmp-host-prohibited
[root@was01 ~]# 




■ CentOS 가상머신 iptables 활성화

1). WEB01 가상머신 ( HTTPD : 80 포트 사용 )

[root@web01 ~]# vi /etc/sysconfig/iptables

# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT

[root@web01 ~]#
[root@web01 ~]# service iptables start
iptables: Applying firewall rules:                         [  OK  ]
[root@web01 ~]#
[root@web01 ~]# chkconfig iptables on
[root@web01 ~]# 

또는

[root@web01 sysconfig]# iptables -L --line-number
Chain INPUT (policy ACCEPT)
num  target     prot opt source               destination 
1    ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED
2    ACCEPT     icmp --  anywhere             anywhere     
3    ACCEPT     all  --  anywhere             anywhere     
4    ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:ssh
5    REJECT     all  --  anywhere             anywhere            reject-with icmp-host-prohibited
Chain FORWARD (policy ACCEPT)
num  target     prot opt source               destination 
1    REJECT     all  --  anywhere             anywhere            reject-with icmp-host-prohibited
Chain OUTPUT (policy ACCEPT)
num  target     prot opt source               destination 
[root@web01 sysconfig]# iptables -I INPUT 5 -p tcp -m tcp --dport 80 -j ACCEPT
[root@web01 sysconfig]#
[root@web01 sysconfig]# iptables -L --line-number
Chain INPUT (policy ACCEPT)
num  target     prot opt source               destination 
1    ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED
2    ACCEPT     icmp --  anywhere             anywhere     
3    ACCEPT     all  --  anywhere             anywhere     
4    ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:ssh
5    ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:http
6    REJECT     all  --  anywhere             anywhere            reject-with icmp-host-prohibited
Chain FORWARD (policy ACCEPT)
num  target     prot opt source               destination 
1    REJECT     all  --  anywhere             anywhere            reject-with icmp-host-prohibited
Chain OUTPUT (policy ACCEPT)
num  target     prot opt source               destination 
[root@web01 sysconfig]#
[root@web01 sysconfig]# service iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[  OK  ]
[root@web01 sysconfig]#
[root@web01 sysconfig]# more iptables
# Generated by iptables-save v1.4.7 on Mon Oct 17 11:48:38 2016
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [10:1155]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
# Completed on Mon Oct 17 11:48:38 2016
[root@web01 sysconfig]#

2). WEB01 가상머신 (mod_jk : 8009 포트 사용(HTTPD와 Tomcat 연동), Tomcat : 8080 포트 사용)

[root@was01 ~]# vi /etc/sysconfig/iptables

# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8009 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT

[root@was01 ~]#
[root@was01 ~]# service iptables start
[root@was01 ~]# service iptables stop
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Unloading modules:                               [  OK  ]
[root@was01 ~]#
[root@was01 ~]# service iptables start
iptables: Applying firewall rules:                         [  OK  ]
[root@was01 ~]#
[root@was01 ~]# chkconfig iptables on
[root@was01 ~]# 

Windows 8.1 가상머신의 웹브라우저를 사용하여 주소창에 웹서버 IP 또는 도메인 이름을 입력하여 접속되는지 확인을 합니다. 아래와 같이 나온다면 iptables이 WEB01과 WAS01에 잘 구성된 것입니다.


3). DB01 가상머신 (MySQL : 3306 포트 사용)

[root@db01 ~]# vi /etc/sysconfig/iptables

# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT

[root@db01 ~]# service iptables start
iptables: Applying firewall rules:                         [  OK  ]
[root@db01 ~]#
[root@db01 ~]# chkconfig iptables on
[root@db01 ~]# 

Windows 8.1 가상머신의 웹브라우저를 사용하여 주소창에 도메인 주소와 파일을 입력하여 서비스가 되는지 확인합니다.


4). DB02 가상머신 (Oracle 11g Express : 1521 포트 사용)

[root@db02 ~]# vi /etc/sysconfig/iptables

# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 1521 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT

[root@db02 ~]#
[root@db02 ~]# service iptables start
iptables: Applying firewall rules:                         [  OK  ]
[root@db02 ~]#
[root@db02 ~]# chkconfig iptables on
[root@db02 ~]# 

Windows 8.1 가상머신의 웹브라우저를 사용하여 주소창에 도메인 주소와 Oracle 11g Express 접속 테스트를 확인할 수 있는 파일인 oracle.jsp을 입력하여 서비스가 되는지 확인합니다.





5). DB03 가상머신 (Oracle 12c Standard : 1521 포트 사용)

[root@db03 ~]# vi /etc/sysconfig/iptables

# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 1521 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT

[root@db03 ~]#
[root@db03 ~]# service iptables start
iptables: Applying firewall rules:                         [  OK  ]
[root@db03 ~]#
[root@db03 ~]# chkconfig iptables on
[root@db03 ~]# 


6). DNS 가상머신 (BIND : 53 포트 사용)

[root@dns ~]# vi /etc/sysconfig/iptables

# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 53 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 53 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT

[root@dns ~]# service iptables start
iptables: Applying firewall rules:                         [  OK  ]

[root@dns ~]# chkconfig iptables on
[root@dns ~]# 

Windows 8.1 가상머신의 명령창(cmd)에서 아래와 같이 도메인 이름 풀이가 잘 되는지 확인합니다.


7). NFS01 가상머신 (NFS : 111, 2049 포트 사용)

WEB01 가상머신에서 마운트 된 /data01을 아래와 같이 언마운트 합니다.

[root@web01 ~]# df
Filesystem           1K-blocks    Used Available Use% Mounted on
/dev/mapper/vg_os-root
                      16177064 2696240  12652408  18% /
tmpfs                   957724     224    957500   1% /dev/shm
/dev/sda1               194241   33170    150831  19% /boot
192.168.80.12:/data01         16177152 2743552  12605184  18% /data01
[root@web01 ~]#
[root@web01 ~]# umount /data01

NFS01 가상머신에서 아래와 같이 iptables을 설정하고 서비스를 시작합니다.

[root@nfs01 ~]# vi /etc/sysconfig/iptables

# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 2049 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 2049 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 111 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 111 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT

[root@nfs01 ~]#
[root@nfs01 ~]# service iptables start
iptables: Applying firewall rules:                         [  OK  ]
[root@nfs01 ~]#
[root@nfs01 ~]# chkconfig iptables on
[root@nfs01 ~]# 

WEB01에서 NFS01 공유 디렉터리를 다시 마운트 합니다. 마운트가 된다면 방화벽 정책이 정상적으로 설정된 것입니다.

[root@web01 ~]# mount /data01
[root@web01 ~]# df
Filesystem           1K-blocks    Used Available Use% Mounted on
/dev/mapper/vg_os-root
                      16177064 2696236  12652412  18% /
tmpfs                   957724     224    957500   1% /dev/shm
/dev/sda1               194241   33170    150831  19% /boot
192.168.80.12:/data01                16177152 2743552  12605184  18% /data01
[root@web01 ~]# 

8). Samba01 가상머신 (Samba : 137, 138, 139, 445 포트 사용)

아래와 같이 Samba 서비스 포트를 설정하고 그리고 iptables 서비스를 실행합니다.

[root@samba01 ~]# vi /etc/sysconfig/iptables

# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 137 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 138 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 139 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 445 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT

[root@samba01 ~]#
[root@samba01 ~]# service iptables start
iptables: Applying firewall rules:                         [  OK  ]
[root@samba01 ~]#
[root@samba01 ~]# chkconfig iptables on
[root@samba01 ~]# 

Windows 8.1 가상머신에서 탐색기를 이용하여 Samba01 가상머신의 공유 디렉터리에 접근한 후 파일을 생성합니다.


Samba01 서버에서 관련 디렉터리(폴더)가 잘 생성되었는지 확인합니다. 생성이 되었다면 정상적으로 Samba 서비스가 되는 것입니다.

[root@samba01 samba]# ls -l /public01/
total 30844
drwxr-xr-x. 2 nobody nobody     4096 Jul 27 16:35 새 폴더
-rw-r--r--. 1 root   root   31580160 Jul 27 06:22 etc.tar
[root@samba01 samba]# 

9). DHCP NTP 가상머신 (DHCP : 67 포트 사용, NTP : 123 포트 사용)

[root@dhcpntp ~]# vi /etc/sysconfig/iptables

# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p udp --dport 67 -j ACCEPT
-A INPUT -p udp --dport 123 -m state --state NEW -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
[root@dhcpntp ~]#
[root@dhcpntp ~]#
[root@dhcpntp ~]# service iptables start
iptables: Applying firewall rules:                         [  OK  ]
[root@dhcpntp ~]#
[root@dhcpntp ~]# chkconfig iptables on
[root@dhcpntp ~]# 

DHCP 테스트를 위해 Windows 8.1 가상머신을 DHCP 클라이언트로 구성한 후 DHCP 서버로부터 IP 주소를 받을 수 있도록 설정합니다. IP를 정상적으로 받아오면 아래와 같이 출력됩니다.


여기까지 iptables 리눅스 방화벽 간단 구성에 대해 알아보았습니다.