Our scenario with 5 public ips.
Create interface aliaces for your main IP
( How to https://www.cyberciti.biz/faq/linux-creating-or-adding-new-network-alias-to-a-network-card-nic/)
# ifup eth0:1
# ifup eth0:2
# ifup eth0:3
# ifup eth0:4
Be sure that your iptables support for statistic match module.
# iptables -m statistic -h
statistic match options:
--mode mode Match mode (random, nth)
random mode:
--probability p Probability
nth mode:
--every n Match every nth packet
--packet p Initial counter value (0 <= p <= n-1, default 0)
Iptables rule for rotating source IP addresses.
# iptables -t nat -I POSTROUTING -m state --state NEW -p tcp --dport 25 -o eth0 -m statistic --mode nth --every 5 -j SNAT --to-source 213.XXX.XX.2
# iptables -t nat -I POSTROUTING -m state --state NEW -p tcp --dport 25 -o eth0 -m statistic --mode nth --every 5 -j SNAT --to-source 213.XXX.XX.3
# iptables -t nat -I POSTROUTING -m state --state NEW -p tcp --dport 25 -o eth0 -m statistic --mode nth --every 5 -j SNAT --to-source 213.XXX.XX.4
# iptables -t nat -I POSTROUTING -m state --state NEW -p tcp --dport 25 -o eth0 -m statistic --mode nth --every 5 -j SNAT --to-source 213.XXX.XX.5
# iptables -t nat -I POSTROUTING -m state --state NEW -p tcp --dport 25 -o eth0 -m statistic --mode nth --every 5 -j SNAT --to-source 213.XXX.XX.6
Toata lumea are un blog, de ce nu si eu ? Poate o sa fie si ceva interesant ... To be continue ...
luni, 3 decembrie 2018
sâmbătă, 18 august 2018
PowerShell script in schedule task cannot start a second script
In my current firstscript.ps1 i`m checking if i got allready a job started and running, if not will will give a job start for a second script.
This firstscript.ps1 i got in Schedule Task
$Env:SCRIPT_HOME - is a User Enviroment for a path
contenet example for firstscript.ps1
$maxConcurrentJobs = 1
if ((Get-Job -State 'Running').Count -eq $maxConcurrentJobs) {
$joburicurente = (Get-Job -State 'Running').Count
Write-Host -ForegroundColor RED “Mai sunt $joburicurente"
} Else {
$joburicurente = (Get-Job -State 'Running').Count
Write-Host -ForegroundColor GREEN “ Putem rula job-ul. Mai sunt $joburicurente"
#start-job -filepath $Env:SCRIPT_HOME \monitor\secondscript.ps1
$job_result = start-job -filepath $Env:SCRIPT_HOME \monitor\secondscript.ps1
$job_id = $job_result.id
while ($job_result.state -match "Running"){
Start-Sleep -seconds 5
$job_result = get-job $job_id
}
}
Tested with PowerShell 4
This firstscript.ps1 i got in Schedule Task
$Env:SCRIPT_HOME - is a User Enviroment for a path
contenet example for firstscript.ps1
$maxConcurrentJobs = 1
if ((Get-Job -State 'Running').Count -eq $maxConcurrentJobs) {
$joburicurente = (Get-Job -State 'Running').Count
Write-Host -ForegroundColor RED “Mai sunt $joburicurente"
} Else {
$joburicurente = (Get-Job -State 'Running').Count
Write-Host -ForegroundColor GREEN “ Putem rula job-ul. Mai sunt $joburicurente"
#start-job -filepath $Env:SCRIPT_HOME \monitor\secondscript.ps1
$job_result = start-job -filepath $Env:SCRIPT_HOME \monitor\secondscript.ps1
$job_id = $job_result.id
while ($job_result.state -match "Running"){
Start-Sleep -seconds 5
$job_result = get-job $job_id
}
}
Tested with PowerShell 4
luni, 23 aprilie 2018
Avoid errors when install SharePoint 2016
Error in process of Prerequisite installation
Most of errors apears when Prerequisite is not done well or when you manual install some package which require preconfiguration made by prerequisite software (prerequisiteinstaller.exe) .
So ... DONT manual install Server AppFabric, Cumulative Update 7 for AppFrabic 1.1 and WCF Data Services,use prerequisiteinstaller.exe to do it.
1. First step when u do offline installing. Download packages or use this powershell script https://www.mondor.ro/stuff/Download-SP2016-prerechizite.ps1.
Links to download:
Microsoft SQL Server 2012 SP1 Native Client
Microsoft ODBC Driver 11 for SQL Server
Microsoft Sync Framework Runtime v1.0 SP1 (x64)
Microsoft Identity Extensions
Windows Server AppFabric 1.1
Cumulative Update 7 for Microsoft AppFabric 1.1 for Windows Server
Microsoft Information Protection and Control Client
Microsoft WCF Data Services 5.6
Visual C++ Redistributable Package for Visual Studio 2015
Another visual C++ Redistributable Package for Visual Studio 2013/2012
.NET framework 4.6
2. DONT manual install Server AppFabric, Cumulative Update 7 for AppFrabic 1.1 and WCF Data Services, use prerequisiteinstaller.exe like:
prerequisiteinstaller.exe /AppFabric:C:\path-to-downloaded-files\WindowsServerAppFabricSetup_x64.exe
prerequisiteinstaller.exe /WCFDataServices:C:\path-to-downloaded-files\WcfDataServices.exe /quiet
Than install Patch for AppFabric 1.1
3. Reboot
4. Continue Normal install Sharepoint 2016
Good Luck!
Most of errors apears when Prerequisite is not done well or when you manual install some package which require preconfiguration made by prerequisite software (prerequisiteinstaller.exe) .
So ... DONT manual install Server AppFabric, Cumulative Update 7 for AppFrabic 1.1 and WCF Data Services,use prerequisiteinstaller.exe to do it.
1. First step when u do offline installing. Download packages or use this powershell script https://www.mondor.ro/stuff/Download-SP2016-prerechizite.ps1.
Links to download:
Microsoft SQL Server 2012 SP1 Native Client
Microsoft ODBC Driver 11 for SQL Server
Microsoft Sync Framework Runtime v1.0 SP1 (x64)
Microsoft Identity Extensions
Windows Server AppFabric 1.1
Cumulative Update 7 for Microsoft AppFabric 1.1 for Windows Server
Microsoft Information Protection and Control Client
Microsoft WCF Data Services 5.6
Visual C++ Redistributable Package for Visual Studio 2015
Another visual C++ Redistributable Package for Visual Studio 2013/2012
.NET framework 4.6
2. DONT manual install Server AppFabric, Cumulative Update 7 for AppFrabic 1.1 and WCF Data Services, use prerequisiteinstaller.exe like:
prerequisiteinstaller.exe /AppFabric:C:\path-to-downloaded-files\WindowsServerAppFabricSetup_x64.exe
prerequisiteinstaller.exe /WCFDataServices:C:\path-to-downloaded-files\WcfDataServices.exe /quiet
Than install Patch for AppFabric 1.1
3. Reboot
4. Continue Normal install Sharepoint 2016
Good Luck!
luni, 2 aprilie 2018
Add External SMTP Server for Nagios Notifications
On Centos 6/7
yum install mailx
locate commands.cfg
/usr/local/nagios/etc/objects/commands.cfg
Edit
vi /usr/local/nagios/etc/objects/commands.cfg
and change notify-host-by-email and notify-service-by-email into this:
# 'notify-host-by-email' command definition
define command{
command_name notify-host-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/bin/mailx -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" -S smtp-auth=login -S smtp="server.mondor.ro:25" -S from="nagios@mondor.ro" -S smtp-auth-user="nagios@mondor.ro" -S smtp-auth-password="password" $CONTACTEMAIL$
}
# 'notify-service-by-email' command definition
define command{
command_name notify-service-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /usr/bin/mailx -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" -S smtp-auth=login -S smtp="server.mondor.ro:25" -S from="nagios@mondor.ro" -S smtp-auth-user="nagios@mondor.ro" -S smtp-auth-password="password" $CONTACTEMAIL$
}
yum install mailx
locate commands.cfg
/usr/local/nagios/etc/objects/commands.cfg
Edit
vi /usr/local/nagios/etc/objects/commands.cfg
and change notify-host-by-email and notify-service-by-email into this:
# 'notify-host-by-email' command definition
define command{
command_name notify-host-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/bin/mailx -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" -S smtp-auth=login -S smtp="server.mondor.ro:25" -S from="nagios@mondor.ro" -S smtp-auth-user="nagios@mondor.ro" -S smtp-auth-password="password" $CONTACTEMAIL$
}
# 'notify-service-by-email' command definition
define command{
command_name notify-service-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /usr/bin/mailx -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" -S smtp-auth=login -S smtp="server.mondor.ro:25" -S from="nagios@mondor.ro" -S smtp-auth-user="nagios@mondor.ro" -S smtp-auth-password="password" $CONTACTEMAIL$
}
Abonați-vă la:
Postări (Atom)