{"id":452,"date":"2008-06-12T15:56:36","date_gmt":"2008-06-12T14:56:36","guid":{"rendered":"https:\/\/www.networknet.nl\/apps\/wp\/archives\/452"},"modified":"2008-06-28T20:21:46","modified_gmt":"2008-06-28T19:21:46","slug":"esx-esxcfg-vswitch-and-special-vlan-switch","status":"publish","type":"post","link":"https:\/\/www.networknet.nl\/apps\/wp\/archives\/452","title":{"rendered":"ESX: esxcfg-vswitch and special vlan switch"},"content":{"rendered":"<p>If you need to create 5 or more of Virtual Port groups on a vSwtich and you don&#8217;t want to use the VI client than logon on the service console and run the commands below.<\/p>\n<p>For creating a new Virtual Port Group use:<\/p>\n<div class=\"terminal\">esxcfg-vswitch -A NAME-TO-GIVE vSwitch0<\/div>\n<p>Assigning a special VLAN to this a Virtual Port Group:<\/p>\n<div class=\"terminal\">esxcfg-vswitch -v VLANID -p PORTGROUP vSwitch0<\/div>\n<p>With these two simple commands I was able to push my sh script and create same &#8220;Networking&#8221; configuration on dozen of my ESX servers.<\/p>\n<div class=\"terminal\">[root@ESX-02 root]# esxcfg-vswitch -A VLAN282 vSwitch0<br \/>[root@ESX-02 root]# esxcfg-vswitch -A VLAN283 vSwitch0<br \/>[root@ESX-02 root]# esxcfg-vswitch -A VLAN284 vSwitch0<br \/>[root@ESX-02 root]# esxcfg-vswitch -A VLAN285 vSwitch0<br \/>[root@ESX-02 root]# esxcfg-vswitch -A VLAN299 vSwitch0<br \/>[root@ESX-02 root]# esxcfg-vswitch -A VLAN220 vSwitch0<br \/>[root@ESX-02 root]# esxcfg-vswitch -v 282 -p VLAN282 vSwitch0<br \/>[root@ESX-02 root]# esxcfg-vswitch -v 283 -p VLAN283 vSwitch0<br \/>[root@ESX-02 root]# esxcfg-vswitch -v 284 -p VLAN284 vSwitch0<br \/>[root@ESX-02 root]# esxcfg-vswitch -v 285 -p VLAN285 vSwitch0<br \/>[root@ESX-02 root]# esxcfg-vswitch -v 299 -p VLAN299 vSwitch0<br \/>[root@ESX-02 root]# esxcfg-vswitch -v 220 -p VLAN220 vSwitch0<\/div>\n<p> <\/p>\n<p>esxcfg-vswitch [options] [vswitch[:ports]]<\/p>\n<p style=\"font-size: 11pt; margin: 0in; font-family: 'Courier New'\"><span style=\"mso-spacerun: yes\">&nbsp; <\/span>-a|&#8211;add<span style=\"mso-spacerun: yes\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Add a new virtual switch.<\/p>\n<p style=\"font-size: 11pt; margin: 0in; font-family: 'Courier New'\"><span style=\"mso-spacerun: yes\">&nbsp; <\/span>-d|&#8211;delete<span style=\"mso-spacerun: yes\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Delete the virtual switch.<\/p>\n<p style=\"font-size: 11pt; margin: 0in; font-family: 'Courier New'\"><span style=\"mso-spacerun: yes\">&nbsp; <\/span>-l|&#8211;list<span style=\"mso-spacerun: yes\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>List all the virtual switches.<\/p>\n<p style=\"font-size: 11pt; margin: 0in; font-family: 'Courier New'\"><span style=\"mso-spacerun: yes\">&nbsp; <\/span>-L|&#8211;link=pnic<span style=\"mso-spacerun: yes\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Set pnic as an uplink for the vswitch.<\/p>\n<p style=\"font-size: 11pt; margin: 0in; font-family: 'Courier New'\"><span style=\"mso-spacerun: yes\">&nbsp; <\/span>-U|&#8211;unlink=pnic<span style=\"mso-spacerun: yes\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Remove pnic from the uplinks for the vswitch.<\/p>\n<p style=\"font-size: 11pt; margin: 0in; font-family: 'Courier New'\"><span style=\"mso-spacerun: yes\">&nbsp; <\/span>-M|&#8211;add-pg-uplink<span style=\"mso-spacerun: yes\">&nbsp;&nbsp;&nbsp; <\/span>Add an uplink to the list of uplinks for a portgroup<\/p>\n<p style=\"font-size: 11pt; margin: 0in; font-family: 'Courier New'\"><span style=\"mso-spacerun: yes\">&nbsp; <\/span>-N|&#8211;del-pg-uplink<span style=\"mso-spacerun: yes\">&nbsp;&nbsp;&nbsp; <\/span>Delete an uplink from the list of uplinks for a portgroup<\/p>\n<p style=\"font-size: 11pt; margin: 0in; font-family: 'Courier New'\"><span style=\"mso-spacerun: yes\">&nbsp; <\/span><span style=\"background: yellow; mso-highlight: yellow\">-p|&#8211;pg=portgroup<span style=\"mso-spacerun: yes\">&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Specify a portgroup for operation<\/span><\/p>\n<p style=\"font-size: 11pt; margin: 0in; font-family: 'Courier New'\"><span style=\"mso-spacerun: yes\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Use ALL to set VLAN IDs on all portgroups<\/p>\n<p style=\"font-size: 11pt; margin: 0in; font-family: 'Courier New'\"><span style=\"mso-spacerun: yes\">&nbsp; <\/span><span style=\"background: yellow; mso-highlight: yellow\">-v|&#8211;vlan=id<span style=\"mso-spacerun: yes\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Set vlan id for portgroup specified by -p<\/span><\/p>\n<p style=\"font-size: 11pt; margin: 0in; font-family: 'Courier New'\"><span style=\"mso-spacerun: yes\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>0 would disable the vlan<\/p>\n<p style=\"font-size: 11pt; margin: 0in; font-family: 'Courier New'\"><span style=\"mso-spacerun: yes\">&nbsp; <\/span>-c|&#8211;check<span style=\"mso-spacerun: yes\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Check to see if a virtual switch exists.<\/p>\n<p style=\"font-size: 11pt; margin: 0in; font-family: 'Courier New'\"><span style=\"mso-spacerun: yes\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Program outputs a 1 if it exists, 0 otherwise.<\/p>\n<p style=\"font-size: 11pt; margin: 0in; font-family: 'Courier New'\"><span style=\"mso-spacerun: yes\">&nbsp; <\/span><span style=\"background: lime; mso-highlight: lime\">-A|&#8211;add-pg=name<span style=\"mso-spacerun: yes\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Add a new portgroup to the virtual switch.<\/span><\/p>\n<p style=\"font-size: 11pt; margin: 0in; font-family: 'Courier New'\"><span style=\"mso-spacerun: yes\">&nbsp; <\/span>-D|&#8211;del-pg=name<span style=\"mso-spacerun: yes\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Delete the portgroup from the virtual switch.<\/p>\n<p style=\"font-size: 11pt; margin: 0in; font-family: 'Courier New'\"><span style=\"mso-spacerun: yes\">&nbsp; <\/span>-C|&#8211;check-pg=name<span style=\"mso-spacerun: yes\">&nbsp;&nbsp;&nbsp; <\/span>Check to see if a portgroup exists.<span style=\"mso-spacerun: yes\">&nbsp; <\/span>Program<\/p>\n<p style=\"font-size: 11pt; margin: 0in; font-family: 'Courier New'\"><span style=\"mso-spacerun: yes\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>outputs a 1 if it exists, 0 otherwise.<\/p>\n<p style=\"font-size: 11pt; margin: 0in; font-family: 'Courier New'\"><span style=\"mso-spacerun: yes\">&nbsp; <\/span>-B|&#8211;set-cdp<span style=\"mso-spacerun: yes\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Set the CDP status for a given virtual switch.<\/p>\n<p style=\"font-size: 11pt; margin: 0in; font-family: 'Courier New'\"><span style=\"mso-spacerun: yes\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>To set pass one of &#8220;down&#8221;, &#8220;listen&#8221;, &#8220;advertise&#8221;, &#8220;both&#8221;.<\/p>\n<p style=\"font-size: 11pt; margin: 0in; font-family: 'Courier New'\"><span style=\"mso-spacerun: yes\">&nbsp; <\/span>-b|&#8211;get-cdp<span style=\"mso-spacerun: yes\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Print the current CDP setting for this switch.<\/p>\n<p style=\"font-size: 11pt; margin: 0in; font-family: 'Courier New'\"><span style=\"mso-spacerun: yes\">&nbsp; <\/span>-m|&#8211;mtu=MTU<span style=\"mso-spacerun: yes\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Set MTU for the vswitch. <\/p>\n<p style=\"font-size: 11pt; margin: 0in; font-family: 'Courier New'\"><span style=\"mso-spacerun: yes\">&nbsp; <\/span>-r|&#8211;restore<span style=\"mso-spacerun: yes\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Restore all virtual switches from the configuration file<\/p>\n<p style=\"font-size: 11pt; margin: 0in; font-family: 'Courier New'\"><span style=\"mso-spacerun: yes\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>(FOR INTERNAL USE ONLY).<\/p>\n<p style=\"font-size: 11pt; margin: 0in; font-family: 'Courier New'\"><span style=\"mso-spacerun: yes\">&nbsp; <\/span>-h|&#8211;help<span style=\"mso-spacerun: yes\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Show this message.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you need to create 5 or more of Virtual Port groups on a vSwtich and you don&#8217;t want to use the VI client than logon on the service console and run the commands below. For creating a new Virtual Port Group use: esxcfg-vswitch -A NAME-TO-GIVE vSwitch0 Assigning a special VLAN to this a Virtual Port Group: esxcfg-vswitch -v VLANID -p PORTGROUP vSwitch0 With these two simple commands I was able to push my sh script and create same &#8220;Networking&#8221; configuration on dozen of my ESX servers. [root@ESX-02 root]# esxcfg-vswitch -A VLAN282 vSwitch0[root@ESX-02 root]# esxcfg-vswitch -A VLAN283 vSwitch0[root@ESX-02 root]# esxcfg-vswitch -A VLAN284 vSwitch0[root@ESX-02 root]# esxcfg-vswitch -A VLAN285 vSwitch0[root@ESX-02 root]# esxcfg-vswitch -A VLAN299 vSwitch0[root@ESX-02 root]# esxcfg-vswitch -A VLAN220 vSwitch0[root@ESX-02 root]# esxcfg-vswitch -v 282 -p VLAN282 vSwitch0[root@ESX-02 root]# esxcfg-vswitch -v 283 -p VLAN283 vSwitch0[root@ESX-02 root]# esxcfg-vswitch -v 284 -p VLAN284 vSwitch0[root@ESX-02 root]# esxcfg-vswitch -v 285 -p VLAN285 vSwitch0[root@ESX-02 root]# esxcfg-vswitch -v 299 -p VLAN299 vSwitch0[root@ESX-02 root]# esxcfg-vswitch -v 220 -p VLAN220 vSwitch0 esxcfg-vswitch [options] [vswitch[:ports]] &nbsp; -a|&#8211;add&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Add a new virtual switch. &nbsp; -d|&#8211;delete&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Delete the virtual switch. &nbsp; -l|&#8211;list&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; List all the virtual switches. &nbsp; -L|&#8211;link=pnic&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set pnic as an uplink for the vswitch. &nbsp; -U|&#8211;unlink=pnic&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Remove pnic from the uplinks for the vswitch. &nbsp; -M|&#8211;add-pg-uplink&nbsp;&nbsp;&nbsp; Add an uplink to the list of uplinks for a portgroup &nbsp; -N|&#8211;del-pg-uplink&nbsp;&nbsp;&nbsp; Delete an uplink from the list of uplinks for a portgroup &nbsp; -p|&#8211;pg=portgroup&nbsp;&nbsp;&nbsp;&nbsp; Specify a portgroup for operation &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Use ALL to set VLAN IDs on all portgroups &nbsp; -v|&#8211;vlan=id&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set vlan [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[400],"tags":[418,37,147,11,81],"class_list":["post-452","post","type-post","status-publish","format-standard","hentry","category-esx-vmware","tag-commandline","tag-esx","tag-howto","tag-script","tag-vlan"],"_links":{"self":[{"href":"https:\/\/www.networknet.nl\/apps\/wp\/wp-json\/wp\/v2\/posts\/452","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.networknet.nl\/apps\/wp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.networknet.nl\/apps\/wp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.networknet.nl\/apps\/wp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.networknet.nl\/apps\/wp\/wp-json\/wp\/v2\/comments?post=452"}],"version-history":[{"count":0,"href":"https:\/\/www.networknet.nl\/apps\/wp\/wp-json\/wp\/v2\/posts\/452\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.networknet.nl\/apps\/wp\/wp-json\/wp\/v2\/media?parent=452"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.networknet.nl\/apps\/wp\/wp-json\/wp\/v2\/categories?post=452"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.networknet.nl\/apps\/wp\/wp-json\/wp\/v2\/tags?post=452"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}