-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfedora_init.sh
37 lines (31 loc) · 1.29 KB
/
fedora_init.sh
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
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/bash
dnf install -y policycoreutils-python-utils
# set ssh port
echo "ssh port? (22)"
read ssh_port
ssh_port="${ssh_port:-22}"
if [[ $ssh_port -ne 22 ]] ; then
sed -i "s/^#Port.*/Port ${ssh_port}/" /etc/ssh/sshd_config
semanage port -a -t ssh_port_t -p tcp $ssh_port
sed "/port=/s/port=\"22\"/port=\"${ssh_port}\"/" /usr/lib/firewalld/services/ssh.xml > /etc/firewalld/services/ssh.xml
firewall-cmd --reload
fi
echo -e "\n\n"
ip address show scope global
echo -e "\n\n"
echo "Type a interface name that you want to set to trusted zone (empty to skip)"
read trusted_interface
if [[ -n $trusted_interface ]] ; then
firewall-cmd --permanent --zone=trusted --change-interface="$trusted_interface"
firewall-cmd --reload
fi
echo "Type a interface name that you want to set to external zone (empty to skip)"
read external_interface
if [[ -n $external_interface ]] ; then
firewall-cmd --permanent --zone=external --change-interface="$external_interface"
firewall-cmd --permanent --new-policy NAT_trust_to_ext
firewall-cmd --permanent --policy NAT_trust_to_ext --add-ingress-zone trusted
firewall-cmd --permanent --policy NAT_trust_to_ext --add-egress-zone external
firewall-cmd --permanent --policy NAT_trust_to_ext --set-target ACCEPT
firewall-cmd --reload
fi