Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

how to GATEWAY and DNS Setting? in linux



  • Hi.

    my system linux.

    how to IP and MASK and GATEWAY and DNS Setting?

    I use the QProccess?

    If so, what should I Command?

    my source code

    QString ip = ui->lineEdit->text();
    QString mask = ui->lineEdit_2->text();
    QString cmd = QString("ifconfig eth0 %1 netmask %2 up").arg(ip,mask);

            QProcess *qProc = new QProcess(this);
            qProc->execute(cmd);

  • Lifetime Qt Champion

    Hi,

    First thing, you need to check that you have the rights to call ifconfig.

    Then you can grab the output from QProcess and parse it to get the data you want.