Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to configure firewalld #30

Merged
merged 3 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions scripts/network/prepare-tap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@ which ip &>/dev/null || stop "Don't have the ip tool"
which whoami &>/dev/null || stop "Don't have the whoami tool"
which iptables &>/dev/null || stop "Don't have the iptables tool"
which sysctl &>/dev/null || stop "Don't have the sysctl tool"
which firewall-cmd &>/dev/null || stop "Don't have the firewal-cmd tool"

ADDRESS="192.168.0.1/16"
NAME="tun0"
ADDRESS="10.0.0.1/16"
NAME="berserker0"
USER="$(whoami)"
CONFIGURE_IPTABLE="false"
CONFIGURE_FIREWALD="false"
erthalion marked this conversation as resolved.
Show resolved Hide resolved
CONFIGURE_TUNTAP_IF_EXISTS="false"

while getopts ":a:t:u:io" opt; do
while getopts ":a:t:u:i:fo" opt; do
case $opt in
a) ADDRESS="${OPTARG}"
;;
Expand All @@ -33,6 +35,8 @@ while getopts ":a:t:u:io" opt; do
;;
i) CONFIGURE_IPTABLE="true"
;;
f) CONFIGURE_FIREWALD="true"
;;
o) CONFIGURE_TUNTAP_IF_EXISTS="true"
;;
\?) echo "Invalid option -$OPTARG" >&2
Expand All @@ -58,6 +62,12 @@ ip link set "${NAME}" up
echo "Assigning address ${ADDRESS} to device ${NAME}..."
ip addr add "${ADDRESS}" dev "${NAME}"

if [[ "${CONFIGURE_FIREWALD}" == "true" ]];
erthalion marked this conversation as resolved.
Show resolved Hide resolved
then
echo "Adding to the trusted zone..."
firewall-cmd --zone=trusted --add-interface="${NAME}"
fi

if [[ "${CONFIGURE_IPTABLE}" == "true" ]];
then
echo "Enabling ip forward..."
Expand Down
2 changes: 1 addition & 1 deletion src/worker/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ impl NetworkWorker {
&self,
addr: Ipv4Address,
) -> (Interface, FaultInjector<Tracer<TunTapInterface>>, i32) {
let device_name = "tun0";
let device_name = "berserker0";
let device = TunTapInterface::new(&device_name, Medium::Ip).unwrap();
let fd = device.as_raw_fd();

Expand Down
Loading