Skip to content

Instantly share code, notes, and snippets.

@Miladbr
Created July 31, 2022 11:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Miladbr/6710b9255d15be115d41599b138342f9 to your computer and use it in GitHub Desktop.
Save Miladbr/6710b9255d15be115d41599b138342f9 to your computer and use it in GitHub Desktop.
Persist an esxi firewall rule for outgoing syslog traffic
# Append below lines in /etc/rc.local.d/local.sh.
# Change host_address and host_port according to your syslog server configuartion.
/bin/cat > /etc/vmware/firewall/persistsyslog.xml << EOF
<!-- remote syslog configuration -->
<ConfigRoot>
<service>
<id>persistsyslog</id>
<rule id='0000'>
<direction>outbound</direction>
<protocol>udp</protocol>
<porttype>dst</porttype>
<port>host_port</port>
</rule>
<enabled>false</enabled>
<required>false</required>
</service>
</ConfigRoot>
EOF
/sbin/esxcli network firewall refresh
/sbin/esxcli network firewall unload
/sbin/esxcli network firewall load
/sbin/esxcli network firewall ruleset set -e true -r persistsyslog
/sbin/esxcli network firewall ruleset set -e false -r syslog
/sbin/esxcli system syslog config set --loghost udp://host_address:host_port
/sbin/esxcli system syslog reload
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment