elf0r
Goto Top

TCP/IP Einstellungen via Batch ändern

Hi,

ich würde gerne mittels einer batchdatei die Eigenschaften der LAN-Verbindung ändern nur weiss ich leider noch nicht so ganz wie. Habe es schonmal mit "netsh" ausprobiert aber das funktioniert bei der IP, der Subnetmask und dem Gateway nicht.

Danke schonmal im Vorraus.

Christian

Content-Key: 24287

Url: https://administrator.de/contentid/24287

Printed on: April 25, 2024 at 15:04 o'clock

Member: Atti58
Atti58 Jan 23, 2006 at 14:57:55 (UTC)
Goto Top
Warum sollte das nicht gehen? Die M$-Hilfe sagt:

"To view the command syntax, click a command:

set address

Configures an IP address and a default gateway on a specified interface.

Syntax
set address [name=]InterfaceName [source=]{dhcp | static [addr=]IPAddress [mask=]SubnetMask [gateway=]{none | DefaultGateway [[gwmetric=]GatewayMetric]}}

Parameters
[name =] InterfaceName
Required. Specifies the name of the interface for which you want to configure address and gateway information. The InterfaceName parameter must match the name of the interface as specified in Network Connections. If InterfaceName contains spaces, use quotation marks around the text (for example, "Interface Name").
[source=]{dhcp | static [addr=]IPAddress [mask=]SubnetMask [gateway=]{none | DefaultGateway [[gwmetric=]GatewayMetric]}}
Required. Specifies whether the IP address to configure originates from a Dynamic Host Configuration Protocol (DHCP) server or is static. If the address is static, IPAddress specifies the address to configure, and SubnetMask specifies the subnet mask for the IP address being configured. If the address is static, you must also specify whether you want to leave the current default gateway (if any) in place or configure one for the address. If you configure a default gateway, DefaultGateway specifies the IP address of the default gateway to be configured, and GatewayMetric specifies the metric for the default gateway to be configured.
"

Gruß

Atti
Mitglied: 22736
22736 Jan 24, 2006 at 09:51:28 (UTC)
Goto Top
Hi Christian,

was funktioniert denn nicht? Gibt es Fehlermeldungen? Wie sieht die von Dir ausprobierte netsh-Befehlszeile aus?

Viele Grüße

Peter
Member: eLf0r
eLf0r Jan 24, 2006 at 16:32:54 (UTC)
Goto Top
Hallo Peter,
so sieht mein Script aus:

rem IP,Subnetmask und Gateway hinzufügen
netsh set address "LAN-Verbindung" static 192.168.0.1 255.255.255.0 192.168.0.2
rem DNS Server 1 hinzufügen
netsh interface ip add dns "LAN-Verbindung" 192.168.0.2
rem DNS Server 2 hinzufügen
netsh interface ip add dns "LAN-Verbindung" 192.168.0.3

Die DNS-Server werden auch hinzugefügt aber bei dem rest sagt er "Der folgende Befehl wurde nicht gefunden: set address "LAN-Verbindung" static 192.168.0.1 255.255.255.0 192.168.0.2" . und wenn ich die ganze zeile ohne netsh schreibt er das die umgebungsvariable adress "LAN-Verbindung" nicht definiert ist.

Gruss
Christian
Member: colis
colis Jan 24, 2006 at 19:39:56 (UTC)
Goto Top
Hi Christian

Ich glaube so geht das nicht.
Bei mir sieht die Batchdatei so aus
netsh interface ip set address name="LAN-Verbindung" source=static addr=192.168.10.243 mask=255.255.255.
Wenn du einen Gatway eintragen willst, musst du noch nach der Gatewayadresse den gwmetric=Wert anhängen.

Tschau Andre
Ich hoffe ich habe helfen können
Mitglied: 22736
22736 Jan 24, 2006 at 20:04:44 (UTC)
Goto Top
Das folgende Beispiel stellt für "LAN-Verbindung" die IP-Adresse 192.168.5.100, die Subnetzmaske 255.255.255.0, das Standardgateway 192.168.5.1 und Metrik 1 ein:

netsh interface ip set address "LAN-Verbindung" ^
static 192.168.5.100 255.255.255.0 192.168.5.1 1


Umstellung auf DHCP geht so:

netsh interface ip set address "LAN-Verbindung" dhcp
Member: Kai999
Kai999 May 30, 2006 at 12:51:40 (UTC)
Goto Top
Wie sieht es denn aus wenn man zusätzlich den DNS server ändern will?