25 กันยายน 2565

MikroTik OpenVPN Server and Client

Server ip : 192.168.10.1
OpenVPN server bind ip : 172.28.10.1
protocol : udp
auth : sha512
cipher : aes256

client
username : user1
password : user1
user1's ip : 172.28.10.100
allow one connection per user
verify both server certificate and client certificate


OpenVPN server

/certificate
add name=CA common-name=ca key-usage=key-cert-sign,crl-sign days-valid=3650
add name=Server common-name=server key-usage=digital-signature,key-encipherment,tls-server days-valid=3650
add name=Client common-name=client key-usage=tls-client days-valid=3650

sign CA
sign Server ca=CA
sign Client ca=CA
set Server trusted=yes

export-certificate CA file-name=CA type=pkcs12 export-passphrase=""
export-certificate Client file-name=Client type=pkcs12 export-passphrase=12345678

/ppp 
profile add name=ovpn local-address=172.28.10.1 use-ipv6=no use-encryption=yes only-one=yes
secret add name=user1 password=user1 service=ovpn profile=ovpn remote-address=172.28.10.100

/interface ovpn-server server set enabled=yes protocol=udp default-profile=ovpn certificate=Server require-client-certificate=yes tls-version=only-1.2 auth=sha512 cipher=aes256-cbc


OpenVPN client

/certificate
import name=CA file-name=CA.p12 passphrase=""
import name=Client file-name=Client.p12 passphrase=12345678

/interface ovpn-client add connect-to=192.168.10.1 protocol=udp user=user1 password=user1 certificate=Client verify-server-certificate=yes tls-version=only-1.2 auth=sha512 cipher=aes256-cbc use-peer-dns=no add-default-route=no disabled=no

24 กรกฎาคม 2561

LDAP + SSL + SASL

yum -y install openldap compat-openldap openldap-clients openldap-servers openldap-servers-sql openldap-devel
systemctl start slapd
systemctl enable slapd
netstat -antup | grep -i 389
slappasswd -h {SSHA} -s XXXXX
vi db.ldif
ldapmodify -Y EXTERNAL  -H ldapi:/// -f db.ldif
vi monitor.ldif
ldapmodify -Y EXTERNAL  -H ldapi:/// -f monitor.ldif
cp /usr/share/openldap-servers/DB_CONFIG.example /var/lib/ldap/DB_CONFIG
chown ldap:ldap /var/lib/ldap/*
ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/cosine.ldif
ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/nis.ldif
ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/inetorgperson.ldif
vi base.ldif
ldapadd -x -W -D "cn=admin,dc=local" -f base.ldif
ldapsearch -x cn=admin -b dc=local
firewall-cmd --permanent --add-service=ldap
firewall-cmd --reload
vi /etc/rsyslog.conf
systemctl restart rsyslog
openssl req -new -x509 -nodes -out /etc/openldap/certs/localldap.crt -keyout /etc/openldap/certs/localldap.key -days 1460
chown -R ldap:ldap /etc/openldap/certs/local*
ll /etc/openldap/certs/local*
vi certs.ldif
ldapmodify -Y EXTERNAL  -H ldapi:/// -f certs.ldif
slaptest -u
cd  /etc/openldap/certs/
openssl genrsa -out localrootCA.key 2048
openssl req -x509 -new -nodes -key localrootCA.key -sha256 -days 1024 -out localrootCA.pem
openssl genrsa -out localldap.key 2048
openssl req -new -key localldap.key -out localldap.csr
openssl x509 -req -in localldap.csr -CA localrootCA.pem -CAkey localrootCA.key -CAcreateserial -out localldap.crt -days 1460 -sha256
chown -R ldap:ldap /etc/openldap/certs/local*
vi certs.ldif
ldapmodify -Y EXTERNAL  -H ldapi:/// -f certs.ldif
slaptest -u
vi /etc/sysconfig/slapd
systemctl restart slapd
netstat -antup | grep -i 636
netstat -antup | grep slapd
firewall-cmd --permanent --add-service=ldaps
firewall-cmd --reload
vi raj.ldif
ldapadd -x -W -D "cn=admin,dc=local" -f raj.ldif
ldapsearch -x cn=raj -b dc=local
vi entries.ldif
ldapadd -x -W -D "cn=admin,dc=local" -f entries.ldif
yum install cyrus-sasl-ldap
vim /etc/sysconfig/saslauthd
vi /etc/saslauthd.conf
systemctl restart saslauthd
testsaslauthd -u yann.boutin -r ybn.fr -p password
testsaslauthd -u yann.boutin -r ybn.fr -p passwordd
testsaslauthd -u yann.boutin -p password -f /run/saslauthd/mux

Ref
- https://www.itzgeek.com/how-tos/linux/centos-how-tos/step-step-openldap-server-configuration-centos-7-rhel-7.html
- https://www.itzgeek.com/how-tos/linux/centos-how-tos/configure-openldap-with-ssl-on-centos-7-rhel-7.html
- http://www.ybn.fr/linux-technical-library/smtp-authentication

22 มิถุนายน 2561

Install WordPress on CentOS 7 with SELinux

https://techblog.jeppson.org/2016/10/install-wordpress-centos-7/

sudo mkdir /var/www/html/wordpress/wp-content/uploads
sudo chown apache:apache /var/www/html/wordpress/wp-content/uploads
sudo semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/html/wordpress/wp-content/uploads(/.*)?"
sudo restorecon -Rv /var/www/html/wordpress/wp-content/uploads
 

sudo semanage fcontext -a -t httpd_sys_content_t /var/www/html/wordpress/
sudo restorecon -v /var/www/html/wordpress/ 

sudo chcon -t httpd_sys_rw_content_t /var/www/html/wordpress/
 
 
 
# add READ permission to all directories and files under your DocumentRoot
sudo chmod +r /path/to/DocumentRoot/ -R

# add EXECUTE permission to all DIRECTORIES under your DocumentRoot
find /path/to/DocumentRoot/ -type d -exec chmod +x {} \;

23 สิงหาคม 2560

RHEL7: Firewalld

firewall-cmd --list-all-zones
firewall-cmd --get-active-zones
firewall-cmd --info-zone=public

firewall-cmd --permanent --new-zone testZ
firewall-cmd --permanent --zone=testZ --add-source=192.168.43.0/24
firewall-cmd --permanent --zone=testZ --add-source=192.168.31.0/24
firewall-cmd --permanent --zone=testZ --add-service={ssh,http,https}
firewall-cmd --reload
firewall-cmd --info-zone=testZ

firewall-cmd --permanent --zone=trusted --remove-source=192.168.31.0/24
firewall-cmd --permanent --zone=trusted --remove-service={smtp,dns}

firewall-cmd --zone=public --add-interface=ens160

firewall-cmd --get-services

17 สิงหาคม 2560

MySQL user with ip range

For a host value specified as an IPv4 address, a netmask can be given to indicate how many address bits to use for the network number. Netmask notation cannot be used for IPv6 addresses.
The syntax is host_ip/netmask. For example:

CREATE USER 'david'@'192.58.197.0/255.255.255.0';

https://dev.mysql.com/doc/refman/5.6/en/account-names.html

02 สิงหาคม 2560

config apaceh ssllabs A+


SSLEngine on
SSLProtocol TLSv1.2
SSLCipherSuite HIGH:!aNULL:!MD5:!EDH:!3DES:!CAMELLIA:!AES128
SSLHonorCipherOrder on
Header always set Strict-Transport-Security "max-age=31536000"





24 กรกฎาคม 2560

Setup DNSSEC on BIND DNS Server

Enable DNSSEC by adding the following configuration directives inside options{ }
# vi /etc/named.conf
dnssec-enable yes;
dnssec-validation yes;
dnssec-lookaside auto;

Create a Zone Signing Key(ZSK)
# dnssec-keygen -r /dev/urandom -a NSEC3RSASHA1 -b 2048 -n ZONE example.tld

Create a Key Signing Key(KSK)
# dnssec-keygen -r /dev/urandom -f KSK -a NSEC3RSASHA1 -b 4096 -n ZONE example.tld

Add the public keys which contain the DNSKEY record to the zone file.
# for key in `ls Kexample.tld*.key`; do echo "\$INCLUDE $key">> db.example.tld; done

Sign the zone with the dnssec-signzone command.
# dnssec-signzone -e +3024000 -N INCREMENT -o example.tld -t db.example.tld

Get DS record
# cat dsset-example.tld
or
# dig @ns.example.com example.tld dnskey | dnssec-dsfromkey -f /dev/stdin example.tld
# dig @ns.example.com example.tld dnskey | dnssec-dsfromkey -f - example.tld


http://dnsviz.net
https://dnssec-debugger.verisignlabs.com
http://viewdns.info/dnssec/