I'm writing a network traffic simulator for various services (those of you active on the discords have probably seen me ask this a few times). More specifically, it is for a CCDC backend.
I need this system to change it's IP address randomly. Currently I do this by running bash commands. I don't feel like this is the correct way for Rust. Are there system calls available? I didn't find any crates for this specific issue.
My method below has an issue where the network service breaks and I end up needing to restart it. I feel like
See code here:
There aren't any system calls to change the IP to my knowledge. After searching the web I found out that the iproute2 package (containing the
ip command you are currently using) uses Netlink to communicate with the kernel. After staring at the iproute2 source code, I'm quite sure that you can find out how ip changes ip addresses by understanding the function
static int ipaddr_modify(int cmd, int flags, int argc, char **argv)
on line 1009 in the
There is the netlink-sys crate you could use if you want to build a tool like
ip yourself. I can't tell you how much effort this is, so if you decide to go down that road, good luck!
Oh interesting, thank you! I'll look into this!