blob: 0669e7fa5145e10ca70e5daffdaa483953280884 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
#!/usr/bin/env bash
allow_proto_port() {
sudo iptables -I INPUT -p $1 --dport $2 -j ACCEPT;
sudo ip6tables -I INPUT -p $1 --dport $2 -j ACCEPT;
}
allow_port() {
[[ $# != 1 ]] && echo "Invalid command: firewall allow <port>" && exit 1;
allow_proto_port tcp $1;
allow_proto_port udp $1;
}
restore_table() {
sudo iptables-restore < ~/dump/iptables-backup;
}
cmd="$1"; shift;
case "$cmd" in
allow) allow_port "$@" ;;
restore) restore_table ;;
*) echo "Invalid command" && exit 1 ;;
esac;
|