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

Enable IPv4 forwarding at rooter startup #2429

Merged
merged 4 commits into from
Dec 20, 2024
Merged
Changes from all commits
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
10 changes: 10 additions & 0 deletions utils/rooter.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ def run(*args):
stdout, stderr = p.communicate()
return stdout, stderr

def enable_ip_forwarding(sysctl="/usr/sbin/sysctl"):
log.debug("Enabling IPv4 forwarding")
run([sysctl, "-w" "net.ipv4.ip_forward=1"])


def check_tuntap(vm_name, main_iface):
"""Create tuntap device for qemu vms"""
Expand Down Expand Up @@ -763,6 +767,7 @@ def drop_disable(ipaddr, resultserver_port):
parser.add_argument("socket", nargs="?", default="/tmp/cuckoo-rooter", help="Unix socket path")
parser.add_argument("-g", "--group", default="cape", help="Unix socket group")
parser.add_argument("--systemctl", default="/bin/systemctl", help="Systemctl wrapper script for invoking OpenVPN")
parser.add_argument("--sysctl", default="/usr/sbin/sysctl", help="Path to sysctl")
parser.add_argument("--iptables", default="/sbin/iptables", help="Path to iptables")
parser.add_argument("--iptables-save", default="/sbin/iptables-save", help="Path to iptables-save")
parser.add_argument("--iptables-restore", default="/sbin/iptables-restore", help="Path to iptables-restore")
Expand All @@ -786,9 +791,14 @@ def drop_disable(ipaddr, resultserver_port):
if not settings.iptables or not path_exists(settings.iptables):
sys.exit("The `iptables` binary is not available, eh?!")

if not settings.sysctl or not path_exists(settings.sysctl):
sys.exit("The `sysctrl` binary is not available, eh?!")

if os.getuid():
sys.exit("This utility is supposed to be ran as root.")

enable_ip_forwarding(settings.sysctl)

if path_exists(settings.socket):
path_delete(settings.socket)

Expand Down
Loading