{"id":518,"date":"2023-05-05T09:19:49","date_gmt":"2023-05-05T08:19:49","guid":{"rendered":"https:\/\/www.shakral.de\/blog\/?p=518"},"modified":"2023-09-01T23:52:35","modified_gmt":"2023-09-01T22:52:35","slug":"esxi-konfigtemplate","status":"publish","type":"post","link":"https:\/\/www.shakral.de\/blog\/2023\/05\/05\/esxi-konfigtemplate\/","title":{"rendered":"ESXi-Konfigtemplate"},"content":{"rendered":"<p>Sammlung an Konfigurations-Code Schnipseln f\u00fcr die Konfiguration eines ESXi-Hosts per Kommandozeile<\/p>\n\n\n\n<p>Stand 2023-05-03 auf Basis von vSphere 7.0.3<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Allgemeine Einstellungen<\/h2>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; highlight: [1,5,12]; title: ; notranslate\" title=\"\">\n#Wartungsmodus aktivieren\nesxcli system maintenanceMode set --enable=true\nvim-cmd hostsvc\/maintenance_mode_enter\n\n#Aktivieren der Troubleshooting-Optionen\nvim-cmd hostsvc\/enable_ssh\nvim-cmd hostsvc\/start_ssh\nvim-cmd hostsvc\/enable_esx_shell\nvim-cmd hostsvc\/start_esx_shell\nesxcli system settings advanced set -o \/UserVars\/SuppressShellWarning -i 1\n\n#Setzen des Hostsnames und der DNS Server\nesxcli system hostname set --host=&quot;&lt;HOSTNAME&gt;&quot;\nesxcli system hostname set --fqdn=&quot;&lt;HOSTNAME.FQDN&gt;&quot;\nesxcli network ip dns server add --server=&quot;&lt;DNS-Server#1&gt;&quot;\nesxcli network ip dns server add --server=&quot;&lt;DNS-Server#2&gt;&quot;\n\n\n\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\">Netzwerk-Konfiguration<\/h2>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; highlight: [1,5,10,14,17,20]; title: ; notranslate\" title=\"\">\n#Hinzuf\u00fcgen der Uplinks zum Standard-Switch\nesxcli network vswitch standard uplink add -v vSwitch0 -u vmnic2\nesxcli network vswitch standard uplink add -v vSwitch0 -u vmnic4\n\n#Anlegen eines zweiten Switches und zuweisen der Uplinks\nesxcli network vswitch standard add -v vSwitch1\nesxcli network vswitch standard uplink add -v vSwitch1 -u vmnic3\nesxcli network vswitch standard uplink add -v vSwitch1 -u vmnic5\n\n#Failover-Reihenfolge pro Switch\nesxcli network vswitch standard policy failover set -a=vmnic2,vmnic4 -v=vSwitch0\nesxcli network vswitch standard policy failover set -a=vmnic3,vmnic5 -v=vSwitch1\n\n#entfernen der Standardportgruppe\nesxcli network vswitch standard portgroup remove -p=&quot;VM Network&quot; -v=vSwitch0\n\n#MTU Size pro Switch einstellen\nesxcli network vswitch standard set --mtu=9126 --vswitch-name=vSwitch&quot;&lt;Switch-#&gt;&quot;\n\n#Pro Switch ausf\u00fchren\nesxcli network vswitch standard set --mtu=9126 --vswitch-name=vSwitch&quot;&lt;Switch-#&gt;&quot;\n\n<\/pre><\/div>\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">NTP<\/h2>\n\n\n\n<h4 class=\"wp-block-heading\">pre vsphere 7<\/h4>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; highlight: [1,4]; title: ; notranslate\" title=\"\">\n#Eintragen des NTP-Servers\nesxcli system ntp set --enabled=true --server=&quot;&lt;NTP-Server&gt;&quot;\n\n#Troubleshooting NTP\nwatch ntpq -pn \nntpq -c associations\n<\/pre><\/div>\n\n\n<h4 class=\"wp-block-heading\">ab vSphere 7.0.3<\/h4>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; highlight: [1,8,11,14,17]; title: ; notranslate\" title=\"\">\n#Einstellungen in eine tempor\u00f6re Textdatei schreiben\necho restrict 127.0.0.1 &gt;&gt; \/scratch\/ntpconfig.txt\necho server &quot;&amp;lt;NTP-Server-als-DNS&gt;&quot; &gt;&gt; \/scratch\/ntpconfig.txt\necho server &quot;&amp;lt;NTP-Server-#1&gt;&quot; &gt;&gt; \/scratch\/ntpconfig.txt\necho server &quot;&amp;lt;NTP-Server-#2&gt;&quot; &gt;&gt; \/scratch\/ntpconfig.txt\necho tos maxdist 30 &gt;&gt; \/scratch\/ntpconfig.txt\n\nKontrollieren der Konfigdatei\ncat \/scratch\/ntpconfigtmp.txt\n\n#Einlesen der Konfig aus der Textdatei\nesxcli system ntp set -f \/scratch\/ntpconfigtmp.txt\n\n#NTP Server neustarten und aktivieren\nesxcli system ntp set -e 1\n\n#Troubleshooting NTP\nwatch ntpq -pn \nntpq -c associations\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\">vMotion<\/h2>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; auto-links: false; highlight: [1,5,10]; title: ; notranslate\" title=\"\">\n# Erstellen  der Portgruppe mit VLAN-Zuordnung\nesxcli network vswitch standard portgroup add -p=&quot;&lt;Portgruppenname&gt;&quot; -v=vSwitch&quot;&lt;Switch-#&gt;&quot;\nesxcli network vswitch standard portgroup set -p=&quot;&lt;Portgruppenname&gt;&quot; -v=&quot;&lt;VLAN-ID fuer VMotion&gt;&quot;\n\n#Erstellen des VMKernel Interfaces \nesxcli network ip interface add --interface-name=vmk&quot;&lt;#&gt;&quot; --portgroup-name=&quot;&lt;Portgruppenname&gt;&quot;\nesxcli network ip interface ipv4 set -i=vmk&quot;&lt;#&gt;&quot; -I=&quot;&lt;VMotion-IP&gt;&quot; -N=&quot;&lt;VMotion-IP-Netzmaske&gt;&quot; -t=static\nesxcli network ip interface set --interface-name=vmk&quot;&lt;#&gt;&quot; --mtu=9000\n\n#Ausw\u00e4hlen des VMKernel-Interfaces f\u00fcr vMotion\nesxcli network ip interface tag add -i=vmk&quot;&lt;#&gt;&quot; -t=VMotion\n<\/pre><\/div>\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">NFS<\/h2>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; highlight: [1,5,9]; title: ; notranslate\" title=\"\">\n# Erstellen  der Portgruppe mit VLAN-Zuordnung\nesxcli network vswitch standard portgroup add -p=&quot;&lt;Portgruppenname&gt;&quot; -v=vSwitch&lt;Switch-#&gt;\nesxcli network vswitch standard portgroup set -p=&quot;&lt;Portgruppenname&gt;&quot; -v=&quot;&lt;VLAN-ID fuer NFS&gt;&quot;\n\n#Anlegen des VMKernel-Interfaces f\u00fcr NFS\nesxcli network ip interface add --interface-name=vmk&quot;&lt;#&gt;&quot; --portgroup-name=&quot;&lt;Portgruppenname&gt;&quot;\nesxcli network ip interface set --interface-name=vmk&quot;&lt;#&gt;&quot; --mtu=9000\n\n#Vergabe der IP-Adresse\nesxcli network ip interface ipv4 set -i=vmk2 -I=&quot;&lt;NFS-IP&gt;&quot; -N=&quot;&lt;NFS-IP-Subnetzmaske&gt;&quot; -t=static\n\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\">iSCSI<\/h2>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; highlight: [1,4,7,13,19,25,25,29,33]; title: ; notranslate\" title=\"\">\n#iSCSI Software-Adapter aktivieren\nesxcli iscsi software set --enabled=true\n\n#Auslesen der ID des iSCSI Adapters -&gt; &quot;&lt;HBA-ID&gt;&quot;\nesxcli iscsi adapter list\n\n#Erstellen Switch f\u00fcr die iSCSI-Netze\nesxcli network vswitch standard add -v=vSwitch&lt;Switch-#&gt;\nesxcli network vswitch standard uplink add -v=vSwitch&lt;Switch-#&gt; -u=&quot;&lt;iSCSI-NIC#1&gt;&quot;\nesxcli network vswitch standard uplink add -v=vSwitch&lt;Switch-#&gt; -u=&quot;&lt;iSCSI-NIC#2&gt;&quot;\nesxcli network vswitch standard policy failover set -a &quot;&lt;iSCSI-NIC#1&gt;&quot;,&quot;&lt;iSCSI-NIC#2&gt;&quot; -v vSwitch&lt;Switch-#&gt;\n\n#Portgruppen f\u00fcr iSCSI-Netz #1 erstellen\nesxcli network vswitch standard portgroup add -p=&quot;&lt;Portgruppenname#1&gt;&quot; -v=vSwitch&lt;Switch-#&gt;\nesxcli network ip interface add --interface-name=vmk&quot;&lt;#&gt;&quot; --portgroup-name=&quot;&lt;Portgruppenname#1&gt;&quot;\nesxcli network ip interface ipv4 set -i=vmk&quot;&lt;#&gt;&quot; -I=&quot;&lt;iSCSI-IP#1&gt;&quot; -N=&quot;&lt;iSCSI-IP#1-Subnetzmaske&gt;&quot; -t=static\nesxcli network vswitch standard portgroup policy failover set -a &quot;&lt;iSCSI-NIC#1&gt;&quot; -p &quot;&lt;Portgruppenname#1&gt;&quot;\n\n#Portgruppen f\u00fcr iSCSI-Netz #2 erstellen\nesxcli network vswitch standard portgroup add -p=&quot;&lt;Portgruppenname#2&gt;&quot; -v=vSwitch&lt;Switch-#&gt;\nesxcli network ip interface add --interface-name=vmk&quot;&lt;#&gt;&quot; --portgroup-name=&quot;&lt;Portgruppenname#2&gt;&quot;\nesxcli network ip interface ipv4 set -i=vmk&quot;&lt;#&gt;&quot; -I=&quot;&lt;iSCSI-IP#1&gt;&quot; -N=&quot;&lt;iSCSI-IP#1-Subnetzmaske&gt;&quot; -t=static\nesxcli network vswitch standard portgroup policy failover set -a &quot;&lt;iSCSI-NIC#2&gt;&quot; -p &quot;&lt;Portgruppenname#2&gt;&quot;\n\n#Verhindern des Failovers der iSCSI Portgruppen auf die andere Netzwerkkarte\nesxcli network vswitch standard portgroup policy failover set -a vmnic&quot;&lt;#&gt;&quot; -p &quot;&lt;Portgruppenname#1&gt;&quot;\nesxcli network vswitch standard portgroup policy failover set -a vmnic&quot;&lt;#&gt;&quot; -p &quot;&lt;Portgruppenname#2&gt;&quot;\n\n#Hinzuf\u00fcgen der iSCSI-VMKernels zum iSCSI-Software-Adapter\nesxcli iscsi networkportal add --nic=vmk&quot;&lt;#&gt;&quot; --adapter=vmhba&quot;&lt;HBA-ID&gt;&quot;\nesxcli iscsi networkportal add --nic=vmk&quot;&lt;#&gt;&quot; --adapter=vmhba&quot;&lt;HBA-ID&gt;&quot;\n\n#Registrieren der iSCSI Discovery-IP \nesxcli iscsi adapter discovery sendtarget add -a &quot;&lt;iSCSI-Discovery-IP&gt;&quot;:3260 -A vmhba&quot;&lt;HBA-ID&gt;&quot;\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\">Storage<\/h2>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; highlight: [1,3,6]; title: ; notranslate\" title=\"\">\n#Rescan der HBAs\n\nAlle\nesxcli storage core adapter rescan --all \n\nAusgew\u00e4hlte HBAs\nesxcli storage core adapter rescan --adapter=vmhba&amp;lt;&quot;ID&quot;&gt;\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\">Link zur ESXCLI Command Line Reference<\/h2>\n\n\n\n<p><a href=\"https:\/\/developer.vmware.com\/docs\/11743\/esxi-7-0-esxcli-command-reference\" data-type=\"URL\" data-id=\"https:\/\/developer.vmware.com\/docs\/11743\/esxi-7-0-esxcli-command-reference\" target=\"_blank\" rel=\"noreferrer noopener\">VMware Online Documentation ESXCLI<\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>Sammlung an Konfigurations-Code Schnipseln f\u00fcr die Konfiguration eines ESXi-Hosts per Kommandozeile Stand 2023-05-03 auf Basis von vSphere 7.0.3 Allgemeine Einstellungen Netzwerk-Konfiguration NTP pre vsphere 7 ab vSphere 7.0.3 vMotion NFS iSCSI Storage Link zur&#46;&#46;&#46;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,46,52],"tags":[],"class_list":["post-518","post","type-post","status-publish","format-standard","hentry","category-allgemein","category-virtualisierung","category-vmware"],"_links":{"self":[{"href":"https:\/\/www.shakral.de\/blog\/wp-json\/wp\/v2\/posts\/518","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.shakral.de\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shakral.de\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shakral.de\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shakral.de\/blog\/wp-json\/wp\/v2\/comments?post=518"}],"version-history":[{"count":22,"href":"https:\/\/www.shakral.de\/blog\/wp-json\/wp\/v2\/posts\/518\/revisions"}],"predecessor-version":[{"id":628,"href":"https:\/\/www.shakral.de\/blog\/wp-json\/wp\/v2\/posts\/518\/revisions\/628"}],"wp:attachment":[{"href":"https:\/\/www.shakral.de\/blog\/wp-json\/wp\/v2\/media?parent=518"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shakral.de\/blog\/wp-json\/wp\/v2\/categories?post=518"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shakral.de\/blog\/wp-json\/wp\/v2\/tags?post=518"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}