๋ฆฌ๋ ์ค ์๋ฒ๋ฅผ ์ด์ํ ๋ ๊ฐ์ฅ ๊ธฐ๋ณธ์ ์ธ ๋ณด์ ์ค์ ์ค ํ๋๋ ๋ฐฉํ๋ฒฝ ๊ด๋ฆฌ์ ๋๋ค.
๋ค์ ์ด์์ฒด์ ์์๋ ์ ํต์ ์ผ๋ก **iptables**๊ฐ ๊ธฐ๋ณธ ๋ฐฉํ๋ฒฝ์ผ๋ก ์ฌ์ฉ๋์์ต๋๋ค.
๋ํ์ ์ธ OS
๋ค๋ง CentOS7 ์ดํ์๋ ๊ธฐ๋ณธ์ ์ผ๋ก
**firewalld**๊ฐ ์ฌ์ฉ๋๋ฉฐ ๋ด๋ถ์ ์ผ๋ก iptables๋ฅผ ์ฌ์ฉํฉ๋๋ค.
์ด๋ฒ ๊ธ์์๋ iptables์ ๊ธฐ๋ณธ ๊ฐ๋ ๊ณผ ์ค์ ๋ฐฉ๋ฒ์ ์์๋ณด๊ฒ ์ต๋๋ค.
iptables๋ Linux ์ปค๋์ Netfilter ์์คํ ์ ๊ธฐ๋ฐ์ผ๋ก ๋์ํ๋ ๋ฐฉํ๋ฒฝ ๊ด๋ฆฌ ๋๊ตฌ์ ๋๋ค.
iptables๋ฅผ ์ฌ์ฉํ๋ฉด ๋ค์๊ณผ ๊ฐ์ ์์ ์ด ๊ฐ๋ฅํฉ๋๋ค.
iptables๋ Table โ Chain โ Rule ๊ตฌ์กฐ๋ก ๋์ํฉ๋๋ค.
๊ตฌ์กฐ ์
text
Table
โ Filter
โ โ INPUT
โ โ OUTPUT
โ โ FORWARD
์ฒด์ธ์ค๋ช
INPUT - ์๋ฒ๋ก ๋ค์ด์ค๋ ํธ๋ํฝ
OUTPUT - ์๋ฒ์์ ๋๊ฐ๋ ํธ๋ํฝ
FORWARD - ๋ค๋ฅธ ๋คํธ์ํฌ๋ก ์ ๋ฌ๋๋ ํธ๋ํฝ
ํ์ฌ ์ค์ ๋ ๊ท์น ํ์ธ
bash
sudo iptables -L -n -v
์ค๋ช
์๋ฒ ๋ณด์์ ์ํด ๊ธฐ๋ณธ ์ ์ฑ ์ ์ค์ ํฉ๋๋ค.
bash
sudo iptables -P INPUT DROP
sudo iptables -P OUTPUT ACCEPT
sudo iptables -P FORWARD DROP
์ค๋ช
INPUT โ ๊ธฐ๋ณธ ์ฐจ๋จ
OUTPUT โ ๊ธฐ๋ณธ ํ์ฉ
bash
sudo iptables -A INPUT -p tcp --dport 22 -j ACCEPT
์ค๋ช
bash
sudo iptables -A INPUT -p tcp -s 192.168.1.10 --dport 22 -j ACCEPT
bash
sudo iptables -A INPUT -s 192.168.1.100 -j DROP
bash
sudo iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
์ด ๊ท์น์ ์๋ฒ ๋ฐฉํ๋ฒฝ ์ค์ ์์ ๊ฑฐ์ ํ์์ ์ผ๋ก ์ฌ์ฉ๋ฉ๋๋ค.
ํ์ฌ ๊ท์น ํ์ธ
bash
iptables -L --line-numbers
์ญ์
bash
sudo iptables -D INPUT 1
Ubuntu์ ๋ค๋ฅด๊ฒ CentOS์์๋ iptables ์๋น์ค๊ฐ ๊ท์น์ ์ ์ฅํฉ๋๋ค.
์ ์ฅ
bash
service iptables save
๋๋
bash
/etc/init.d/iptables save
์ ์ฅ ์์น
file
/etc/sysconfig/iptables
์ด ํ์ผ์ด ์ฌ๋ถํ ํ์๋ ์ ์ฉ๋๋ ๊ท์น ํ์ผ์ ๋๋ค.
์๋น์ค ์์
bash
systemctl start iptables
์๋น์ค ์ํ ํ์ธ
bash
systemctl status iptables
๋ถํ ์๋ ์์
bash
systemctl enable iptables
CentOS7๋ถํฐ ๊ธฐ๋ณธ ๋ฐฉํ๋ฒฝ์
๐ firewalld
์ ๋๋ค.
๊ตฌ์กฐ
text
firewalld
โ
iptables
โ
Linux Netfilter
๊ทธ๋์ iptables๋ฅผ ์ง์ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ๋ ์์ง๋ง
๋ณดํต firewalld๋ฅผ ์ฌ์ฉํฉ๋๋ค.
OS ๊ธฐ๋ณธ ๋ฐฉํ๋ฒฝ
CentOS6 - iptables
CentOS7 - firewalld
Ubuntu - UFW
Debian - iptables / nftables
๐ก ์ค์ ์๋ฒ ์ด์ ํ
์์ฆ Linux ๋ฐฉํ๋ฒฝ ๊ตฌ์กฐ๋ ์ด๋ ๊ฒ ๋ฐ๋๊ณ ์์ต๋๋ค.
text
nftables
โ
iptables (ํธํ ๊ณ์ธต)
๊ทธ๋์ ์ต์ ๋ฐฐํฌํ์์๋
์ฌ์ฉ์ด ์ ์ ๋๊ณ ์์ต๋๋ค.