Advertisement
tolikpunkoff

openport

Oct 20th, 2019
715
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.66 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. if [ -z "$1" ]; then
  4.     echo "parameters: <port> [t|f]"
  5.     exit
  6. fi
  7.  
  8. echo "Open  port "$1
  9. if [ -z "$2" ]; then
  10.     #to computer
  11.     iptables -A INPUT  -p tcp --dport $1 -j ACCEPT
  12.     iptables -A OUTPUT -p tcp --sport $1 -j ACCEPT
  13.     #from computer
  14.     iptables -A INPUT  -p tcp --sport $1 -j ACCEPT
  15.     iptables -A OUTPUT -p tcp --dport $1 -j ACCEPT
  16. else
  17.     if [ "$1"="t" ]; then
  18.     #to computer
  19.     iptables -A INPUT  -p tcp --dport $1 -j ACCEPT
  20.     iptables -A OUTPUT -p tcp --sport $1 -j ACCEPT
  21.     else
  22.     #from computer
  23.     iptables -A INPUT  -p tcp --sport $1 -j ACCEPT
  24.     iptables -A OUTPUT -p tcp --dport $1 -j ACCEPT
  25.     fi
  26. fi
  27.  
  28. echo "OK"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement