Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED]set addresses in linux
Forum Updated to NodeBB v4.3 + New Features

[SOLVED]set addresses in linux

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 2.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    toho71
    wrote on last edited by
    #1

    Hi I have seen a lot of exampels wher the command is
    @ QString ip = ui->txtAdress->text();
    QString cmd = QString("ifconfig eth0 %1 netmask 255.255.255.0 up").arg(ip);
    @
    and not this
    @ QString cmd = QString("iface eth0 %1 up").arg(ip);
    @
    the Iface doesn't seem to work but on debians configuration for static IP they recommend this method

    What should I use

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tobias.hunger
      wrote on last edited by
      #2

      That depends heavily on the distribution you are using and the network management method used.

      Some distributions use the bare utilities (ifconfig -- already deprecated in some distributions -- or the newer ip), others configure the interface via text files and startup scripts (with or without additional command line utilities), others still use network manager and of course there is always the not so widely used ConnMan.

      So you got lots of different ways to do what you want:-) Some require you to run some command(s), others are available via D-Bus interfaces. Of course you may (or may not when using Network Manager or ConnMan) require root access to do this.

      Why would you even want to change the IP in the first place?

      1 Reply Last reply
      0
      • T Offline
        T Offline
        toho71
        wrote on last edited by
        #3

        If the user wants to change the Ip, netmask or gateway on the machine from the application.
        And then if the user want to turn on dhcp will also be a command.

        My distribution is debian 6.0

        1 Reply Last reply
        0
        • T Offline
          T Offline
          toho71
          wrote on last edited by
          #4

          I used ifconfig and it works great for my purpose

          1 Reply Last reply
          0
          • F Offline
            F Offline
            fluca1978
            wrote on last edited by
            #5

            ifconfig is the widely adopted program to manage NICs. It can slightly change in its syntax, but that is the command to go if you need to be as much portable as possible. Other ways rely heavily on the distribution and will nullify the adoption of Qt as cross platform!
            By the way, while it is true that each distribution as its own way to set up addresses (text files, nm, scripts,...) each one must obey the ifconfig command.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved