Cloud System Engineer

보안을 위한 네트워크 설계 본문

리눅스/centos

보안을 위한 네트워크 설계

클라우드 엔지니어 2021. 2. 24. 22:53

방화벽이란?
외부와 내부에 전달되는 트래픽을 정책에 의해서 허용/거부 역할을 하는 컴퓨터나 장치를 말한다.

내부의 사용자는 외부의 인터넷을 사용하면서 외부에서는 내부로 침입할 수 없게 하는 방법 중 사설 ip라고 불리는 주소를 사용함

사설 ip 주소는 

10.0.0.0 ~10.255.255.255
172.16.0.0 ~182.31.255.255
192.168.0.0 ~192.168.255.255 범위가 있다.

 

 

 

사설ip =유선_연결_1
공인ip =ens33

사설 ip 주소의 컴퓨터가 외부의 인터넷으로 접속할 수 있게 하는 방법을 ip 마스커레이팅(masquerading) 이라고한다.

 

server 에서 iptable 설치

 

dnf -y install iptables-services

 

systemctl start iptables

systemctl enable iptables

 

리눅스 웹서버 ip/ gateway 설정

 

 

 

10.1.1.1 게이트웨이가 밖으로나가는 정책이 설정되어 있지않아 외부 접속 불가.

 

 

똑같이 리눅스 클라이언트도 ip=10.1.1.0 으로 설정하고 게이트웨이틑 10.1.1.1로 바꿔준다

 

 

클라이언트와 웹서버 끼리는 같은 대역이기 떄문에 서로 핑 가능

 

 

 

방화벽 컴퓨터에서 사설ip로 연결하기 위한 네트워크 카드 추가

 

 

 

네트워크 카드가 새로 추가 되어있다.

 

방화벽 컴퓨터에서 사설 ip와 연결하기 위한 게이트웨이 설정

 

[root@localhost ~]# gedit /etc/sysctl.conf 

 

[root@localhost ~]# echo 1 > /proc/sys/net/ipv4/ip_forward
[root@localhost ~]# cat /proc/sys/net/ipv4/ip_forward
1

 

포워딩 하기 위함

 

 

정책 초기화

[root@localhost ~]# iptables --policy FORWARD DROP
[root@localhost ~]# iptables --policy INPUT DROP
[root@localhost ~]# iptables --policy OUTPUT DROP

 

 

방화벽 pc 에서 방화벽을 열어서 마스커레이딩 체크

 

 

현재 정책설정이 되어 있지않아서 외부로 접속 불가

 

 

정책 설정
iptables --append INPUT --in-interface 유선_연결_1 --source 10.1.1.0/24 --match state --state NEW,ESTABLISHED --jump ACCEPT

 

iptables --append OUTPUT --out-interface 유선_연결_1 --destination 10.1.1.0/24 --match state --state NEW,ESTABLISHED --jump ACCEPT

 

iptables --append FORWARD --in-interface 유선_연결_1 --source 10.1.1.0/24 --destination 0.0.0.0/0 --match state --state NEW,ESTABLISHED --jump ACCEPT

 

iptables --append FORWARD --in-interface ens33 --destination 10.1.1.0/24 --match state --state NEW,ESTABLISHED --jump ACCEPT

 

iptables --table nat --append POSTROUTING --out-interface ens33 --jump MASQUERADE //외부로 인터넷 되기하기위함

 

iptables-save > /etc/sysconfig/iptables //ip테이블에저장

systemctl restart network

 

 

 

외부로 핑 간다.

 

인터넷도 들어가진다.

 

 

win_client 에서 ftp 서버 설정

 

리눅스 클라이언트에서 사설 ip 대역에있는 win_client  ftp 접속

 

 

win_client 에서 접속기록을 봤지만 , 192.168.111.100 공인ip 로 접속이 되어있다.

사설 ip 가 공인 ip로 바껴서 나갔다.

즉 외부에서 내부 ip를 알지 못한다 -> 보안성 증가

 

 

http = 80 접속 정책 

 

웹 클라이언트에서 웹서버 설치

 

dnf -y install httpd

 

방화벽
firewall-cmd --permanent --add-service=http
firewall-cmd --reload

 

cd /var/www/html

touch index.html

vi index.html

 

</h1> hellow_world ! </h1>

 

systemctl restart httpd
systemctl enable httpd

 

리눅스 클라이언트에서 웹접속

 

윈도우에서는 열리지 않는다 http 에대한 정책 설정이 필요하다.

 

윈도우 에서 웹서버 연결

iptables --table nat --append PREROUTING --proto tcp --in-interface ens33 --dport 80 --jump DNAT --to-destination 10.1.1.20

 

iptables-save > /etc/sysconfig/iptables //iptable에 저장
systemctl restart network

 

win_client 가 192.168.111.100에서 http를 요청하면 10.1.1.20 웹서버로 연결시켜준다.

 

 

'리눅스 > centos' 카테고리의 다른 글

리눅스마스터 1급 백업 명령어 모음  (0) 2021.10.03
kvm  (0) 2021.03.17
클라우드 서비스  (0) 2021.02.15
라운드 로빈  (0) 2021.02.14
마스터 네임 서버  (0) 2021.02.14