Wednesday, September 13, 2017

How to Replace and Rewrite Sender Address in Postfix

I am setting up Postfix on a Linux server because I want to send mail independently. I need to change sender address because the default sender is from user@server.local.

This config changes sender addresses from both local originated, and relayed SMTP mail traffic:
# nano /etc/postfix/main.cf:
sender_canonical_classes = envelope_sender, header_sender
sender_canonical_maps =  regexp:/etc/postfix/sender_canonical_maps
smtp_header_checks = regexp:/etc/postfix/header_check
Rewrite envelope address from email originating from the server
# nano /etc/postfix/sender_canonical_maps:
/.+/    newsender@example.com
Rewrite from address in SMTP relayed e-mail
# nano /etc/postfix/header_check:
/From:.*/ REPLACE From: newsender@example.com

Sunday, March 5, 2017

Mikrotik Beep Song Indonesia: Apose

Sunday morning, composing "Apose" folk song from Biak, Papua, Indonesia on Mikrotik using beep command.
# Mikrotik beep song "Apose"
# Wahyu Wijanarko - http://wahyu.com
:beep length=300ms frequency=783.99
:delay 350ms
:beep length=300ms frequency=1046.50
:delay 350ms
:beep length=300ms frequency=1318.51
:delay 700ms
:beep length=300ms frequency=1174.66
:delay 175ms
:beep length=300ms frequency=1318.51
:delay 350ms
:beep length=300ms frequency=1174.66
:delay 175ms
:beep length=300ms frequency=1046.50
:delay 700ms
:beep length=300ms frequency=783.99
:delay 350ms
:beep length=300ms frequency=1046.50
:delay 350ms
:beep length=300ms frequency=1318.51
:delay 700ms
:beep length=300ms frequency=1318.51
:delay 175ms
:beep length=300ms frequency=1174.66
:delay 175ms
:beep length=300ms frequency=1318.51
:delay 175ms
:beep length=300ms frequency=1396.91
:delay 175ms
:beep length=300ms frequency=1174.66
:delay 700ms
:beep length=300ms frequency=783.99
:delay 350ms
:beep length=300ms frequency=987.77
:delay 350ms
:beep length=300ms frequency=1174.66
:delay 700ms
:beep length=300ms frequency=1396.91
:delay 175ms
:beep length=300ms frequency=1567.98
:delay 350ms
:beep length=300ms frequency=1396.91
:delay 175ms
:beep length=300ms frequency=1318.51
:delay 700ms
:beep length=300ms frequency=1174.66
:delay 175ms
:beep length=300ms frequency=1318.51
:delay 350ms
:beep length=300ms frequency=1174.66
:delay 175ms
:beep length=300ms frequency=1046.50
:delay 1400ms
:beep length=300ms frequency=783.99
:delay 350ms
:beep length=300ms frequency=1046.50
:delay 350ms
:beep length=300ms frequency=1396.91
:delay 350ms
:beep length=600ms frequency=1318.51
:delay 1400ms
:beep length=300ms frequency=783.99
:delay 350ms
:beep length=300ms frequency=987.77
:delay 350ms
:beep length=300ms frequency=1174.66
:delay 350ms
:beep length=600ms frequency=1046.50
:delay 1400ms
:beep length=300ms frequency=783.99
:delay 350ms
:beep length=300ms frequency=1046.50
:delay 350ms
:beep length=300ms frequency=1396.91
:delay 350ms
:beep length=600ms frequency=1318.51
:delay 1400ms
:beep length=300ms frequency=783.99
:delay 350ms
:beep length=300ms frequency=987.77
:delay 350ms
:beep length=300ms frequency=1174.66
:delay 350ms
:beep length=600ms frequency=1046.50

Tuesday, February 28, 2017

How to Block Youtube and Facebook Using Mikrotik DNS Cache

Create script to check DNS cache in Mikrotik, put ni system - scheduler, make it run every 1 minute.
:local ADDRLIST "BLOCKWEBSITE"
:local DOMAIN "youtube.com|facebook.com|fbcdn.net"
# Find CNAME record
:local DOMAINNAME
:foreach i in=[/ip dns cache all find where (name~"($DOMAIN)") && (type="CNAME") ] do={
  :set DOMAINNAME [/ip dns cache all get $i data];
  :set DOMAIN "$DOMAIN|$DOMAINNAME";
   delay delay-time=10ms
}
# Find A record
:foreach i in=[/ip dns cache all find where (name~"($DOMAIN)") && (type="A") ] do={
  :local DOMAINIP [/ip dns cache get $i address];
  delay delay-time=10ms
  :if ( [/ip firewall address-list find where address=$DOMAINIP] = "") do={
    /ip firewall address-list add address=$DOMAINIP list=$ADDRLIST timeout="00:10:00" comment=[/ip dns cache get $i name];
  }
}
Block request to public DNS outside Mikrotik
/ip firewall nat
add chain=dstnat action=dst-nat to-addresses=192.168.123.8 to-ports=53 protocol=tcp dst-port=53
add chain=dstnat action=dst-nat to-addresses=192.168.123.8 to-ports=53 protocol=udp dst-port=53
Block the desired IPs that already listed in address list
/ip firewall filter
add action=drop chain=forward comment="Block Website" disabled=no dst-address-list=BLOCKWEBSITE