Skip to content

Commit d0f4e88

Browse files
freysteinndbaluta
authored andcommitted
Added FirewallD support to scripts
The default action on Fedora and RHEL-based distributions that use FirewallD is to ban DHCP requests. Instead of telling people to turn off their firewall, I recommend adding the tap interfaces to the FirewallD trusted zone. This commit adds automatic support to the create_net.sh and cleanup-net.sh scripts that set up the tap interfaces. Due to many distributions using FirewallD these days, I opted for using the following command to check if FirewallD is available: if [ -e $(which --skip-alias firewall-cmd) ]; then sudo firewall-cmd --zone=trusted --change-interface=$device fi However, we will have to create a better solution for this in the future. Signed-off-by: Frey Alfredsson <[email protected]>
1 parent ddc2c2b commit d0f4e88

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

tools/labs/qemu/cleanup-net.sh

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22

33
DNSMASQ=/tmp/dnsmasq
44

5-
for i in lkt-tap0 lkt-tap1 lkt-tap-smbd; do
6-
if ! ip a s dev &> /dev/null $i; then
5+
for device in lkt-tap0 lkt-tap1 lkt-tap-smbd; do
6+
if ! ip a s dev &> /dev/null $device; then
77
continue
88
fi
9-
if [ -f $DNSMASQ-$i.pid ]; then
10-
sudo kill `cat $DNSMASQ-$i.pid`
9+
if [ -f $DNSMASQ-$device.pid ]; then
10+
sudo kill $(cat $DNSMASQ-$device.pid)
1111
fi
12-
sudo rm $DNSMASQ-$i.leases
13-
sudo ip tuntap del $i mode tap
12+
sudo rm $DNSMASQ-$device.leases
13+
if [ -e $(which --skip-alias firewall-cmd) ]; then
14+
sudo firewall-cmd --zone=trusted --remove-interface=$device
15+
fi
16+
sudo ip tuntap del $device mode tap
1417
done

tools/labs/qemu/create_net.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ sudo /sbin/ip link set dev "$device" down
3737
sudo /sbin/ip address add $subnet.1/24 dev "$device"
3838
sudo /sbin/ip link set dev "$device" up
3939

40+
if [ -e $(which --skip-alias firewall-cmd) ]; then
41+
sudo firewall-cmd --zone=trusted --change-interface=$device
42+
fi
43+
4044
sudo dnsmasq --port=0 --no-resolv --no-hosts --bind-interfaces \
4145
--interface $device -F $subnet.2,$subnet.20 --listen-address $subnet.1 \
4246
-x /tmp/dnsmasq-$device.pid -l /tmp/dnsmasq-$device.leases || true

0 commit comments

Comments
 (0)