Problem to set gateway using c++ program
Hi,
I'm trying to set the gateway with my c++ program. My function receive the gateway on the first parameter. The return of execution of ioctl() is 0, so it's working good, but when I run the "route" command on console, the configured gateway isn't there. Check the output and the function below: $ route Quote:
Code:
int gateWayConfig(string gateWay) { Could someone help me to solve this issue? I tried to use system() function to set the gateway using: system("route del default"); system("route add default gw 10.100.40.1 dev eth0"); But didn't work too. :/ Thanks in advance |
Did you run as root ?
|
Hi Sergei,
Yes, I was running the program as root. I discovered right now the problem: I was setting interface down to set mac address and the gateway config was going to hell with the "ifconfig eth0 down" command. :P sorry, my fault. Thanks anyway. |
Hi Sergei,
Yes, I was running the program as root. I discovered right now the problem: I was setting interface down to set mac address and the gateway config was going to hell with the "ifconfig eth0 down" command. :P sorry, my fault. Thanks anyway. |
All times are GMT -5. The time now is 08:28 AM. |