-
Notifications
You must be signed in to change notification settings - Fork 0
/
interface_setup.sh
58 lines (44 loc) · 1.25 KB
/
interface_setup.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# Firewall: Trusted Network Interface Update Script
# Author: Roberto Y. Guzman - [email protected]
#
# When the system runs, it creates a network that must be added to the trusted zone
# of the operating system firewall.
#
# Usage:
#
# Run the command "ifconfig" and identify the network created by the containers. (All new docker networs start with prefix "br")
#
# When you have identified the network run this file as such:
#
# "sudo ./interface_setup.sh <interface-name>"
if [ -z $1 ]
then
echo Argument required. Please use a valid interface.
exit
fi
DEFAULT_DOCKER_IFACE="docker0"
FIREWALL_IFACES=$(firewall-cmd --zone=trusted --list-interfaces)
echo Removing old interfaces . . .
for IFACE in $FIREWALL_IFACES
do
if [ $IFACE != $DEFAULT_DOCKER_IFACE ]
then
echo Remove interface: $IFACE
firewall-cmd --permanent --zone=trusted --remove-interface=$IFACE
fi
done
firewall-cmd --reload
echo Old interfaces removed.
echo Adding new interface . . .
AVAILABLE_IFACES=$(ls /sys/class/net/)
for IFACE in $AVAILABLE_IFACES
do
if [ "$IFACE" == "$1" ]
then
firewall-cmd --permanent --zone=trusted --add-interface=$1
firewall-cmd --reload
echo Added interface: $1
exit 0
fi
done
echo Invalid: Interface not found.