code-dumps/azure/nsg-cli-example.sh

46 lines
1.3 KiB
Bash
Raw Normal View History

2019-01-07 14:21:37 +08:00
RGNAME=IQTStreamServer-Migrated
SGNAME=IQTStreamServer-SG
az network nsg create -n $SGNAME -g $RGNAME -l "east asia"
STARTP=1001
cat <<EOF |
122.147.128.180
219.87.71.10
210.61.122.2
122.147.141.118
219.87.64.222
122.147.15.66
122.146.84.72
118.163.58.205
66.70.1.47
85.133.14.254
217.72.241.183
66.70.104.94
63.131.154.55
72.36.244.8
EOF
while read i; do
az network nsg rule create -g $RGNAME --nsg-name $SGNAME -n $STARTP --protocol 'tcp' --source-address-prefixes "$i/32" --source-port-ranges '*' --destination-address-prefixes '*' --destination-port-ranges '*' --access Allow --priority $STARTP
((STARTP++))
done
STARTP=2001
for p in 7070 8000 8001 80; do
az network nsg rule create -g $RGNAME --nsg-name $SGNAME -n $STARTP --protocol 'tcp' --source-address-prefixes "*" --source-port-ranges '*' --destination-address-prefixes '*' --destination-port-ranges $p --access Allow --priority $STARTP
((STARTP++))
done
STARTP=3001
cat <<EOF |
220.128.71.180/32
122.147.213.24/29
61.218.44.0/24
60.251.61.120/29
175.98.157.0/24
122.147.173.0/24
EOF
while read i; do
az network nsg rule create -g $RGNAME --nsg-name $SGNAME -n "CHG0186180-$STARTP" --protocol 'tcp' --source-address-prefixes $i --source-port-ranges '*' --destination-address-prefixes '*' --destination-port-ranges '22' --access Allow --priority $STARTP
((STARTP++))
done