리눅스 - bash: iptables: command not found
리눅스에서 iptables 내용을 확인하려고 했는데
아래와 같이 에러 메세지가 나왔다.
# iptables -L
bash: iptables: command not found
iptables의 위치가 PATH에 등록되어 있지 않아 위치를 찾지 못하고 있다.
iptables는 /sbin/ 아래 위치하고 있다. 이 위치를 $PATH에 추가해둔다.
sbin]$ ll ip*
-rwxr-xr-x 1 root root 169992 2월 23 2012 ip
-rwxr-xr-x 1 root root 59472 2월 23 2012 ip6tables
-rwxr-xr-x 1 root root 62968 2월 23 2012 ip6tables-restore
-rwxr-xr-x 1 root root 62824 2월 23 2012 ip6tables-save
-rwxr-xr-x 1 root root 18120 2월 23 2012 ipmaddr
-rwxr-xr-x 1 root root 60952 2월 23 2012 iptables
-rwxr-xr-x 1 root root 67032 2월 23 2012 iptables-restore
-rwxr-xr-x 1 root root 63192 2월 23 2012 iptables-save
-rwxr-xr-x 1 root root 22200 2월 23 2012 iptunnel
command line에서는 아래와 같이 추가하면 된다.
# export PATH=$PATH:/sbin/
그러나 매번 로그인할때마다 입력하니 번거로우니 .bash_profile에 추가하여 자동으로 반영되게 하자.
vi .bash_profile
---------------
PATH=$PATH:$HOME/bin:/sbin/
export PATH
-----------------
을 .bash_profile에 추가후 source .bash_profile하여 변경사항을 시스템에 반영한다.
이제 iptables이 정상적으로 작동하는 것을 확인할 수 있다.