<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
Hi Peter,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
If the decision can be made with the source IP or hostname, it is pretty easy to do.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
You can create multiple filters, each corresponding to one known source IP: netmask(), or hostname: host().</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
Then you can create embedded log statements. Don't forget to add flags(final), or it will flow through that branch.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
An example configuration:</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<div style="color: rgb(212, 212, 212); background-color: rgb(30, 30, 30); font-family: "Droid Sans Mono", monospace, monospace, "Droid Sans Fallback"; font-weight: normal; font-size: 14px; line-height: 19px;">
<div><span>@version: 3.30</span></div>
<div style="color: rgb(212, 212, 212); background-color: rgb(30, 30, 30); font-family: "Droid Sans Mono", monospace, monospace, "Droid Sans Fallback"; font-weight: normal; font-size: 14px; line-height: 19px;">
<br>
</div>
# One network source, which collects logs from various hosts<br>
<div><span>source s_network {</span></div>
<div><span> network(port(12345))</span><span style="color: rgb(106, 153, 85);">;</span></div>
<div><span>}</span><span style="color: rgb(106, 153, 85);">;</span></div>
<div style="color: rgb(212, 212, 212); background-color: rgb(30, 30, 30); font-family: "Droid Sans Mono", monospace, monospace, "Droid Sans Fallback"; font-weight: normal; font-size: 14px; line-height: 19px;">
<br>
</div>
# One known host, with the IP 127.0.0.1<br>
<div><span>filter f_host1 {</span></div>
<div><span> netmask(</span><span style="color: rgb(206, 145, 120);">"127.0.0.1"</span><span>)</span><span style="color: rgb(106, 153, 85);">;</span></div>
<div><span>}</span><span style="color: rgb(106, 153, 85);">;</span></div>
<div style="color: rgb(212, 212, 212); background-color: rgb(30, 30, 30); font-family: "Droid Sans Mono", monospace, monospace, "Droid Sans Fallback"; font-weight: normal; font-size: 14px; line-height: 19px;">
<br>
</div>
# Another known host with the IP 127.0.0.2<br>
<div><span>filter f_host2 {</span></div>
<div><span> netmask(</span><span style="color: rgb(206, 145, 120);">"127.0.0.2"</span><span>)</span><span style="color: rgb(106, 153, 85);">;</span></div>
<div><span>}</span><span style="color: rgb(106, 153, 85);">;</span></div>
<div style="color: rgb(212, 212, 212); background-color: rgb(30, 30, 30); font-family: "Droid Sans Mono", monospace, monospace, "Droid Sans Fallback"; font-weight: normal; font-size: 14px; line-height: 19px;">
<br>
</div>
# The destination, where host1's logs will be forwarded to<br>
<div><span>destination d_network1 {</span></div>
<div><span> network(</span><span style="color: rgb(206, 145, 120);">"localhost"</span><span> port(23456))</span><span style="color: rgb(106, 153, 85);">;</span></div>
<div><span>}</span><span style="color: rgb(106, 153, 85);">;</span></div>
<span style="color: rgb(212, 212, 212); background-color: rgb(30, 30, 30); display: inline !important;">
<div style="color: rgb(212, 212, 212); background-color: rgb(30, 30, 30); font-family: "Droid Sans Mono", monospace, monospace, "Droid Sans Fallback"; font-weight: normal; font-size: 14px; line-height: 19px;">
<span style="color: rgb(212, 212, 212); background-color: rgb(30, 30, 30); display: inline !important;"><br>
</span></div>
# The destination, where host2's logs will be forwarded to</span><br>
<div><span>destination d_network2 {</span></div>
<div><span> network(</span><span style="color: rgb(206, 145, 120);">"localhost"</span><span> port(23457))</span><span style="color: rgb(106, 153, 85);">;</span></div>
<div><span>}</span><span style="color: rgb(106, 153, 85);">;</span></div>
<br>
<div><span>log {</span></div>
<div><span> source(s_network)</span><span style="color: rgb(106, 153, 85);">;</span></div>
<div style="color: rgb(212, 212, 212); background-color: rgb(30, 30, 30); font-family: "Droid Sans Mono", monospace, monospace, "Droid Sans Fallback"; font-weight: normal; font-size: 14px; line-height: 19px;">
<br>
</div>
# First branch, for host1 -> destination1<br>
<div><span> log {</span></div>
<div><span> filter(f_host1)</span><span style="color: rgb(106, 153, 85);">;</span></div>
<div><span> destination(d_network1)</span><span style="color: rgb(106, 153, 85);">;</span></div>
<div><span> flags(final)</span><span style="color: rgb(106, 153, 85);">; # Don't forget to stop processing</span></div>
<div><span> }</span><span style="color: rgb(106, 153, 85);">;</span></div>
<div style="color: rgb(212, 212, 212); background-color: rgb(30, 30, 30); font-family: "Droid Sans Mono", monospace, monospace, "Droid Sans Fallback"; font-weight: normal; font-size: 14px; line-height: 19px;">
<br>
</div>
# Second branch, for host2 -> destination2<br>
<div><span> log {</span></div>
<div><span> filter(f_host2)</span><span style="color: rgb(106, 153, 85);">;</span></div>
<div><span> destination(d_network2)</span><span style="color: rgb(106, 153, 85);">;</span></div>
<div><span> flags(final)</span><span style="color: rgb(106, 153, 85);">; <span style="color: rgb(106, 153, 85); background-color: rgb(30, 30, 30); display: inline !important;"># Don't forget to stop processing</span></span></div>
<div><span> }</span><span style="color: rgb(106, 153, 85);">;</span></div>
<div><span>}</span><span style="color: rgb(106, 153, 85);">;</span></div>
</div>
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
You can use inline filters too, if it is more convenient. With this, you do not need to define f_host1 and f_host2:</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<div style="color: rgb(212, 212, 212); background-color: rgb(30, 30, 30); font-family: "Droid Sans Mono", monospace, monospace, "Droid Sans Fallback"; font-weight: normal; font-size: 14px; line-height: 19px;">
<div><span>log {</span></div>
<div><span> source(s_network)</span><span style="color: rgb(106, 153, 85);">;</span></div>
<br>
<div><span> </span><span style="color: rgb(106, 153, 85);"># First branch, for 127.0.0.1 -> destination1</span></div>
<div><span> log {</span></div>
<div><span> filter { netmask(</span><span style="color: rgb(206, 145, 120);">"127.0.0.1"</span><span>)</span><span style="color: rgb(106, 153, 85);">; };</span></div>
<div><span> destination(d_network1)</span><span style="color: rgb(106, 153, 85);">;</span></div>
<div><span> flags(final)</span><span style="color: rgb(106, 153, 85);">; # Don't forget to stop processing</span></div>
<div><span> }</span><span style="color: rgb(106, 153, 85);">;</span></div>
<br>
<div><span> </span><span style="color: rgb(106, 153, 85);"># Second branch, for 127.0.0.2 -> destination2</span></div>
<div><span> log {</span></div>
<div><span> filter { netmask(</span><span style="color: rgb(206, 145, 120);">"127.0.0.2"</span><span>)</span><span style="color: rgb(106, 153, 85);">; };</span></div>
<div><span> destination(d_network2)</span><span style="color: rgb(106, 153, 85);">;</span></div>
<div><span> flags(final)</span><span style="color: rgb(106, 153, 85);">; # Don't forget to stop processing</span></div>
<div><span> }</span><span style="color: rgb(106, 153, 85);">;</span></div>
<div><span>}</span><span style="color: rgb(106, 153, 85);">;</span></div>
</div>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
Cheers,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
Attila</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> syslog-ng <syslog-ng-bounces@lists.balabit.hu> on behalf of Peter Griggs <peter@petergriggs.co.uk><br>
<b>Sent:</b> Tuesday, January 12, 2021 2:31 PM<br>
<b>To:</b> Syslog-ng users' and developers' mailing list <syslog-ng@lists.balabit.hu><br>
<b>Subject:</b> [syslog-ng] Filtering Destination by Source</font>
<div> </div>
</div>
<style>
<!--
@font-face
{font-family:"Cambria Math"}
@font-face
{font-family:Calibri}
p.x_MsoNormal, li.x_MsoNormal, div.x_MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif}
a:link, span.x_MsoHyperlink
{color:#0563C1;
text-decoration:underline}
a:visited, span.x_MsoHyperlinkFollowed
{color:#954F72;
text-decoration:underline}
span.x_EmailStyle17
{font-family:"Calibri",sans-serif;
color:windowtext}
.x_MsoChpDefault
{font-family:"Calibri",sans-serif}
@page WordSection1
{margin:72.0pt 72.0pt 72.0pt 72.0pt}
div.x_WordSection1
{}
-->
</style>
<div lang="EN-GB" link="#0563C1" vlink="#954F72">
<div style="background-color:#FFEB9C; width:100%; border-style:solid; border-color:#9C6500; border-width:1pt; padding:2pt; font-size:10pt; line-height:12pt; font-family:'Calibri'; color:Black; text-align:left">
<span style="color:#9C6500; font-weight:bold">CAUTION:</span> This email originated from outside of the organization. Do not follow guidance, click links, or open attachments unless you recognize the sender and know the content is safe.</div>
<br>
<div>
<div class="x_WordSection1">
<p class="x_MsoNormal">Hello,</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">We have a lot of network logs all being pointed to a central syslog however this is a mix of vendors (Cisco / Juniper / Checkpoint) etc. is there a way of splitting the destination file by vendor type / or source IP address? We ingest
this data into Splunk so want to get the source typing right however I am unable to get the sources to point to various listeners and I would prefer.</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">Thanks</p>
<p class="x_MsoNormal">Peter.</p>
</div>
</div>
</div>
</body>
</html>