diff options
author | Christian Breunig <christian@breunig.cc> | 2025-01-13 19:39:50 +0100 |
---|---|---|
committer | Christian Breunig <christian@breunig.cc> | 2025-02-03 07:16:07 +0100 |
commit | 04d296a3446fa8488add17ce1ec7931d43c4a4d0 (patch) | |
tree | 1d57133cf77f39d62b310a1c36cb4a3d43b959f2 | |
parent | e143e496e28b9d6d5803278fa76a14bf2bc2304e (diff) | |
download | vyos-1x-04d296a3446fa8488add17ce1ec7931d43c4a4d0.tar.gz vyos-1x-04d296a3446fa8488add17ce1ec7931d43c4a4d0.zip |
syslog: T6989: add new source-address CLI option for outgoing connections
-rw-r--r-- | data/templates/rsyslog/rsyslog.conf.j2 | 4 | ||||
-rw-r--r-- | interface-definitions/system_syslog.xml.in | 1 | ||||
-rwxr-xr-x | src/conf_mode/system_syslog.py | 7 |
3 files changed, 12 insertions, 0 deletions
diff --git a/data/templates/rsyslog/rsyslog.conf.j2 b/data/templates/rsyslog/rsyslog.conf.j2 index efb23ca7d..779ae8d04 100644 --- a/data/templates/rsyslog/rsyslog.conf.j2 +++ b/data/templates/rsyslog/rsyslog.conf.j2 @@ -113,6 +113,10 @@ if prifilt("{{ tmp | join(',') }}") then { template="SyslogProtocol23Format" {% endif %} TCP_Framing="{{ 'octed-counted' if remote_options.format.octet_counted is vyos_defined else 'traditional' }}" +{% if source_address is vyos_defined %} + # Sender IP address + Address="{{ source_address }}" +{% endif %} {% if vrf is vyos_defined %} Device="{{ vrf }}" {% endif %} diff --git a/interface-definitions/system_syslog.xml.in b/interface-definitions/system_syslog.xml.in index acc7b4747..f47a95f09 100644 --- a/interface-definitions/system_syslog.xml.in +++ b/interface-definitions/system_syslog.xml.in @@ -100,6 +100,7 @@ #include <include/syslog-facility.xml.i> </children> </node> + #include <include/source-address-ipv4-ipv6.xml.i> #include <include/interface/vrf.xml.i> </children> </node> diff --git a/src/conf_mode/system_syslog.py b/src/conf_mode/system_syslog.py index 78840a5f5..ce806a540 100755 --- a/src/conf_mode/system_syslog.py +++ b/src/conf_mode/system_syslog.py @@ -78,6 +78,13 @@ def verify(syslog): verify_vrf(syslog) + if 'source_address' in syslog: + syslog_vrf = None + if 'vrf' in syslog: + syslog_vrf = syslog['vrf'] + if not is_addr_assigned(syslog['source_address'], syslog_vrf): + raise ConfigError('No interface with given address specified!') + def generate(syslog): if not syslog: if os.path.exists(rsyslog_conf): |