Skip to content

Instantly share code, notes, and snippets.

@akanehara
Last active November 28, 2022 02:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akanehara/a2948ae8b38af62436e38d4f6ea651b7 to your computer and use it in GitHub Desktop.
Save akanehara/a2948ae8b38af62436e38d4f6ea651b7 to your computer and use it in GitHub Desktop.
iptablesスニペット
# 接続先で遮断
iptables -I INPUT -p tcp --tcp-flags ALL,SYN SYN -s ${SRC_ADDR} --dport ${PORT} -j DROP
iptables -I INPUT -p tcp -s ${SRC_ADDR} --dport ${PORT} -j REJECT
# 接続元で遮断
iptables -I OUTPUT -p tcp -d ${DEST_ADDR} --dport ${PORT} -j REJECT
iptables -I OUTPUT -p tcp --tcp-flags ALL,SYN SYN -d ${DEST_ADDR} --dport ${PORT} -j DROP
# 何か入力するまで遮断
{ CMD='sudo iptables $op OUTPUT -p tcp --dport 9200 -j REJECT'; op=-I;eval "$CMD"; read; op=-D; eval "$CMD" ;}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment