question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

VSwitches and promiscuous mode

See original GitHub issue

I can create a vswitch and a portgroup. I can set security policy for the port group and set the promiscuous mode for it. But if I set the security policy for vswitch, I get an error. Is there a way to set VSwitch promiscuous mode?

    vss_spec = vim.host.VirtualSwitch.Specification()
    vss_spec.numPorts = 32
    vss_spec.bridge = vim.host.VirtualSwitch.BondBridge(nicDevice=["vmnic1"])

    # security_policy = vim.host.NetworkPolicy.SecurityPolicy()
    # security_policy.allowPromiscuous = True
    # security_policy.forgedTransmits = True
    # security_policy.macChanges = False
    # vss_spec.policy = vim.host.NetworkPolicy(security=security_policy)

    host_network_system.AddVirtualSwitch(vswitchName=vss_name, spec=vss_spec)

Issue Analytics

  • State:open
  • Created 8 years ago
  • Comments:11

github_iconTop GitHub Comments

1reaction
prziborowskicommented, Aug 9, 2016

@jeffreyxie888 if you have access to the vswitch config, then this should be relatively easy to do.

host = si.content.rootFolder.childEntity[0].hostFolder.childEntity[0].host[0]
networkSystem = host.configManager.networkSystem
networkConfig = networkSystem.networkConfig
vswitch0 = networkConfig.vswitch[0]
spec = vswitch0.spec
spec.policy.security.allowPromiscuous = True
networkSystem.UpdateVirtualSwitch(vswitch0.name, spec)

For brevity I’ve just picked the first host of the first datacenter, and the first vswitch out of the list. The HostVirtualSwitchConfig is: http://pubs.vmware.com/vsphere-60/index.jsp#com.vmware.wssdk.apiref.doc/vim.host.VirtualSwitch.Config.html (and in my above snippet that is what vswitch0 is)

0reactions
ckottecommented, Oct 13, 2018

Ok. I got it. You need to set every parameter if you want to configure one of the policies on a standard switch. If you forgot a single parameter or have a wrong value, you will get Invalid Argument without any hint what the error could be…

This sample code works for me:

vss_spec = vim.host.VirtualSwitch.Specification()
vss_spec.numPorts = 64  # 128 works as well
vss_spec.bridge = vim.host.VirtualSwitch.BondBridge()
vss_spec.bridge.nicDevice = ['vmnic6', 'vmnic7']
# vss_spec.bridge.beacon = vim.host.VirtualSwitch.BeaconConfig()
# vss_spec.bridge.beacon.interval = 1
# vss_spec.bridge.linkDiscoveryProtocolConfig = vim.host.LinkDiscoveryProtocolConfig()
# vss_spec.bridge.linkDiscoveryProtocolConfig.protocol = 'cdp'
# vss_spec.bridge.linkDiscoveryProtocolConfig.operation = 'listen'
# vss_spec.mtu = 9000
vss_spec.policy = vim.host.NetworkPolicy()
vss_spec.policy.security = vim.host.NetworkPolicy.SecurityPolicy()
vss_spec.policy.security.allowPromiscuous = False
vss_spec.policy.security.forgedTransmits = False
vss_spec.policy.security.macChanges = False
vss_spec.policy.offloadPolicy = vim.host.NetOffloadCapabilities()
vss_spec.policy.offloadPolicy.tcpSegmentation = True
vss_spec.policy.offloadPolicy.zeroCopyXmit = True
vss_spec.policy.offloadPolicy.csumOffload = True
vss_spec.policy.shapingPolicy = vim.host.NetworkPolicy.TrafficShapingPolicy()
vss_spec.policy.shapingPolicy.enabled = False
# vss_spec.policy.shapingPolicy.enabled = True
# vss_spec.policy.shapingPolicy.averageBandwidth = 100000 * 1000
# vss_spec.policy.shapingPolicy.peakBandwidth = 100000 * 1000
# vss_spec.policy.shapingPolicy.burstSize = 102400 * 1024
vss_spec.policy.nicTeaming = vim.host.NetworkPolicy.NicTeamingPolicy()
vss_spec.policy.nicTeaming.notifySwitches = True
vss_spec.policy.nicTeaming.rollingOrder = False
# Default values
vss_spec.policy.nicTeaming.failureCriteria = vim.host.NetworkPolicy.NicFailureCriteria()
vss_spec.policy.nicTeaming.failureCriteria.fullDuplex = False
vss_spec.policy.nicTeaming.failureCriteria.percentage = 0
vss_spec.policy.nicTeaming.failureCriteria.checkErrorPercent = False
vss_spec.policy.nicTeaming.failureCriteria.checkDuplex = False
vss_spec.policy.nicTeaming.failureCriteria.checkBeacon = False
vss_spec.policy.nicTeaming.failureCriteria.speed = 10
vss_spec.policy.nicTeaming.failureCriteria.checkSpeed = 'minimum'
vss_spec.policy.nicTeaming.nicOrder = vim.host.NetworkPolicy.NicOrderPolicy()
vss_spec.policy.nicTeaming.nicOrder.activeNic = ['vmnic6', 'vmnic7']
vss_spec.policy.nicTeaming.nicOrder.standbyNic = []
vss_spec.policy.nicTeaming.policy = 'loadbalance_srcid'
vss_spec.policy.nicTeaming.reversePolicy = True
network_mgr = self.host_system.configManager.networkSystem
network_mgr.UpdateVirtualSwitch(vswitchName=self.switch, spec=vss_spec)

Beacon, LDP, and MTU doesn’t need to be set. Everything else needs to be set.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuring promiscuous mode on a virtual switch or ...
Click the Configuration tab. ; In the Hardware section, click Networking. ; Click Properties of the virtual switch for which you want to...
Read more >
Configuring a vSwitch with promiscuous mode
Configuring a vSwitch with promiscuous mode · Click on Add Networking · Select Virtual Machine Port Group for a Standard Switch · Confirm...
Read more >
vNetwork : reject-promiscuous-mode - 'vswitch' | Tenable®
Promiscuous mode is disabled by default on the ESXI Server, and this is the recommended setting. However, there might be a legitimate reason...
Read more >
Why should I enable promiscuous mode? - Server Fault
In a nutshell, promiscuous mode allows a VM to use arbitrary MAC addresses and to listen to all traffic on the vSwitch (still...
Read more >
The virtual switch Promiscuous Mode policy must be set to ...
Promiscuous Mode is disabled by default on the ESXi Server, and this is the recommended setting. Promiscuous Mode can be set at the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found