Nominate our 2022 Qt Champions!

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);

  • Lifetime Qt Champion


    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.