Command line to change IP, gateway, and DNS

pheromix Posted messages 2 Registration date   Status Member Last intervention   -  
pheromix Posted messages 2 Registration date   Status Member Last intervention   -
Hello everyone,

Are there DOS commands to change the IP address of a computer as well as the gateway IP address and both DNS (preferred and alternate)?

Thank you.

2 answers

  1. kaumune Posted messages 22605 Registration date   Status Contributor Last intervention   5 159
     
    Hello

    You type in a command prompt:

    netsh inter ip set address /?

    and for the DNS

    netsh interface ip set dnsservers /?

    and you have the various syntaxes

    --
    3
  2. pheromix Posted messages 2 Registration date   Status Member Last intervention   9
     

    Vous devez ajouter le paramètre interface pour spécifier l'interface réseau sur laquelle vous souhaitez appliquer la configuration. La commande correcte serait :


    netsh interface ip set address "Nom de l'interface" static 192.168.2.49 255.255.255.0 192.168.2.1

    Assurez-vous également d'utiliser l'adresse de sous-réseau appropriée (ici, 255.255.255.0 est un exemple typique).

    1
    1. kaumune Posted messages 22605 Registration date   Status Contributor Last intervention   5 159
       
      Well yes, that's normal

      Did you check the help as indicated and the entire error message?
      0
    2. pheromix Posted messages 2 Registration date   Status Member Last intervention   9 > kaumune Posted messages 22605 Registration date   Status Contributor Last intervention  
       
      Yes, here is the result:

      C:\Windows\system32>netsh inter ip set address address=192.168.2.49 gateway=192.
      168.2.1
      One or more essential parameters have not been entered.
      Check the required parameters and enter them again.
      The syntax provided for this command is not valid. Refer to the help
      for the correct syntax.

      Syntax: set address [name=]<string>
      [[source=]dhcp|static]
      [[address=]<IPv4 address>/<integer>
      [[mask=<IPv4 mask>]
      [[gateway=<IPv4 address>|none
      [gwmetric=<integer>]
      [[type=]unicast|anycast]
      [[subinterface=]<string>]
      [[store=]active|persistent]
      0
    3. kaumune Posted messages 22605 Registration date   Status Contributor Last intervention   5 159
       
      And do you think that your command matches?

      the message you quote is not complete
      missing the continuation at the bottom
      0
    4. pheromix Posted messages 2 Registration date   Status Member Last intervention   9 > kaumune Posted messages 22605 Registration date   Status Contributor Last intervention  
       
      Here is the full result:


      C:\Windows\system32>netsh inter ip set address address=192.168.2.49 gateway=192.
      168.2.1
      One or more essential parameters were not entered.
      Check the required parameters and enter them again.
      The syntax provided for this command is not valid. Consult the help
      for the correct syntax.

      Syntax: set address [name=]<string>
      [[source=]dhcp|static]
      [[address=]<IPv4 address>/<integer>
      [[mask=]<IPv4 mask>]
      [[gateway=]<IPv4 address>|none
      [gwmetric=<integer>]
      [[type=]unicast|anycast]
      [[subinterface=<string>]
      [[store=]active|persistent]

      Parameters:

      Parameter Value
      name - Name or index of the interface.
      source - One of the following values:
      dhcp: activates DHCP to configure IP addresses for
      the specified interface.
      static: disables DHCP to configure IP addresses
      for the specified interface. This value must
      be specified if an address or gateway
      is being configured.
      address - IPv4 address to add or modify, optionally
      followed by the subnet prefix length.
      mask - IP subnet mask for the specified IP address.
      gateway - One of the following values:
      <IPv4 address>: specific default gateway for
      the static IP address you are currently
      setting.
      none: no default gateway is set.
      This is the default value.
      gwmetric - Metric for the default gateway. Set this
      field only if a gateway is specified.
      type - One of the following values:
      unicast: marks the address as a unicast address.
      This is the default value.
      anycast: marks the address as an anycast address.
      subinterface - LUID of the sub-interface on which the
      default gateway resides. This parameter is only required
      on interfaces with multiple sub-interfaces.
      store - One of the following values:
      active: the value lasts only until the next
      startup.
      persistent: the value is persistent. This is the
      default value.

      Notes: used to enable or disable DHCP for the configuration of
      IP addresses. Also removes all previous static IP addresses
      and default gateways, and can add a new static IP address
      and a new default gateway.

      Examples:

      set address name="Wired Ethernet Connection" source=dhcp
      set address "Wired Ethernet Connection" static 10.0.0.9 255.0.0.0 10.0.0
      .1 1


      C:\Windows\system32>
      0
    5. kaumune Posted messages 22605 Registration date   Status Contributor Last intervention   5 159
       
      Thank you, I know it.... ;-)

      And you, doesn't it inspire you anything?
      0