아래 코드로 간단하게 해결.

void ConfigureNetwork(char *ip, char *subnetmask, char *gateway)
{
    char command[255];
    sprintf(command, "ifconfig eth0 %s netmask %s up", ip, subnetmask);
    system(command);
   
    sprintf(command, "route add default gw %s", gateway);
    system(command);

    sleep(2);
    // 보나스로 gateway에 ping 3번 날려줌
    sprintf(command, "ping %s -c 3", gateway);
    system(command);
}


+ Recent posts