<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ihor</title>
    <description>The latest articles on DEV Community by Ihor (@garyker).</description>
    <link>https://dev.to/garyker</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F88256%2F77b78ee8-9834-4d3d-a788-5892e5dc6e29.jpeg</url>
      <title>DEV Community: Ihor</title>
      <link>https://dev.to/garyker</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/garyker"/>
    <language>en</language>
    <item>
      <title>OpenVPN Server and certificate management on MikroTik</title>
      <dc:creator>Ihor</dc:creator>
      <pubDate>Fri, 15 Mar 2019 08:17:13 +0000</pubDate>
      <link>https://dev.to/garyker/openvpn-server-and-certificate-management-on-mikrotik-54b3</link>
      <guid>https://dev.to/garyker/openvpn-server-and-certificate-management-on-mikrotik-54b3</guid>
      <description>&lt;h1&gt;
  
  
  Setup OpenVPN Server and generate certs
&lt;/h1&gt;

&lt;h1&gt;
  
  
  Change variables below and paste the script
&lt;/h1&gt;

&lt;h1&gt;
  
  
  into MikroTik terminal window.
&lt;/h1&gt;

&lt;p&gt;:global CN [/system identity get name]&lt;br&gt;
:global COUNTRY "UA"&lt;br&gt;
:global STATE "KV"&lt;br&gt;
:global LOC "Kyiv"&lt;br&gt;
:global ORG "My organization"&lt;br&gt;
:global OU ""&lt;br&gt;
:global KEYSIZE "2048"&lt;/p&gt;

&lt;h2&gt;
  
  
  functions
&lt;/h2&gt;

&lt;p&gt;:global waitSec do={:return ($KEYSIZE * 10 / 1024)}&lt;/p&gt;

&lt;h2&gt;
  
  
  generate a CA certificate
&lt;/h2&gt;

&lt;p&gt;/certificate&lt;br&gt;
add name=ca-template country="$COUNTRY" state="$STATE" locality="$LOC" \&lt;br&gt;
  organization="$ORG" unit="$OU" common-name="$CN" key-size="$KEYSIZE" \&lt;br&gt;
  days-valid=3650 key-usage=crl-sign,key-cert-sign&lt;br&gt;
sign ca-template ca-crl-host=127.0.0.1 name="$CN"&lt;br&gt;
:delay [$waitSec]&lt;/p&gt;

&lt;h2&gt;
  
  
  generate a server certificate
&lt;/h2&gt;

&lt;p&gt;/certificate&lt;br&gt;
add name=server-template country="$COUNTRY" state="$STATE" locality="$LOC" \&lt;br&gt;
  organization="$ORG" unit="$OU" common-name="server@$CN" key-size="$KEYSIZE" \&lt;br&gt;
  days-valid=3650 key-usage=digital-signature,key-encipherment,tls-server&lt;br&gt;
sign server-template ca="$CN" name="server@$CN"&lt;br&gt;
:delay [$waitSec]&lt;/p&gt;

&lt;h2&gt;
  
  
  create a client template
&lt;/h2&gt;

&lt;p&gt;/certificate&lt;br&gt;
add name=client-template country="$COUNTRY" state="$STATE" locality="$LOC" \&lt;br&gt;
  organization="$ORG" unit="$OU" common-name="client" \&lt;br&gt;
  key-size="$KEYSIZE" days-valid=3650 key-usage=tls-client&lt;/p&gt;

&lt;h2&gt;
  
  
  create IP pool
&lt;/h2&gt;

&lt;p&gt;/ip pool&lt;br&gt;
add name=VPN-POOL ranges=192.168.252.128-192.168.252.224&lt;/p&gt;

&lt;h2&gt;
  
  
  add VPN profile
&lt;/h2&gt;

&lt;p&gt;/ppp profile&lt;br&gt;
add dns-server=192.168.252.1 local-address=192.168.252.1 name=VPN-PROFILE \&lt;br&gt;
  remote-address=VPN-POOL use-encryption=yes&lt;/p&gt;

&lt;h2&gt;
  
  
  setup OpenVPN server
&lt;/h2&gt;

&lt;p&gt;/interface ovpn-server server&lt;br&gt;
set auth=sha1 certificate="server@$CN" cipher=aes128,aes192,aes256 \&lt;br&gt;
  default-profile=VPN-PROFILE enabled=yes require-client-certificate=yes&lt;/p&gt;

&lt;h2&gt;
  
  
  add a firewall rule
&lt;/h2&gt;

&lt;p&gt;/ip firewall filter&lt;br&gt;
add chain=input dst-port=1194 protocol=tcp comment="Allow OpenVPN"&lt;/p&gt;

&lt;p&gt;Add a new user&lt;/p&gt;

&lt;h1&gt;
  
  
  Add a new user and generate/export certs
&lt;/h1&gt;

&lt;h1&gt;
  
  
  Change variables below and paste the script
&lt;/h1&gt;

&lt;h1&gt;
  
  
  into MikroTik terminal window.
&lt;/h1&gt;

&lt;p&gt;:global CN [/system identity get name]&lt;br&gt;
:global USERNAME "user"&lt;br&gt;
:global PASSWORD "password"&lt;/p&gt;

&lt;h2&gt;
  
  
  add a user
&lt;/h2&gt;

&lt;p&gt;/ppp secret&lt;br&gt;
add name=$USERNAME password=$PASSWORD profile=VPN-PROFILE service=ovpn&lt;/p&gt;

&lt;h2&gt;
  
  
  generate a client certificate
&lt;/h2&gt;

&lt;p&gt;/certificate&lt;br&gt;
add name=client-template-to-issue copy-from="client-template" \&lt;br&gt;
  common-name="$USERNAME@$CN"&lt;br&gt;
sign client-template-to-issue ca="$CN" name="$USERNAME@$CN"&lt;br&gt;
:delay 20&lt;/p&gt;

&lt;h2&gt;
  
  
  export the CA, client certificate, and private key
&lt;/h2&gt;

&lt;p&gt;/certificate&lt;br&gt;
export-certificate "$CN" export-passphrase=""&lt;br&gt;
export-certificate "$USERNAME@$CN" export-passphrase="$PASSWORD"&lt;/p&gt;

&lt;p&gt;Setup OpenVPN client&lt;/p&gt;

&lt;p&gt;Copy the exported certificates from the MikroTik&lt;/p&gt;

&lt;p&gt;sftp admin@MikroTik_IP:cert_export_*&lt;/p&gt;

&lt;p&gt;Also, you can download the certificates from the web interface. Go to WebFig → Files for this.&lt;/p&gt;

&lt;p&gt;Create user.auth file&lt;/p&gt;

&lt;p&gt;The file auth.cfg holds your username/password combination. On the first line must be the username and on the second line your password.&lt;br&gt;
user&lt;br&gt;
password&lt;/p&gt;

&lt;p&gt;Create OpenVPN config that named like USERNAME.ovpn:&lt;br&gt;
client&lt;br&gt;
dev tun&lt;br&gt;
proto tcp-client&lt;br&gt;
remote MikroTik_IP 1194&lt;br&gt;
nobind&lt;br&gt;
persist-key&lt;br&gt;
persist-tun&lt;br&gt;
cipher AES-256-CBC&lt;br&gt;
auth SHA1&lt;br&gt;
pull&lt;br&gt;
verb 2&lt;br&gt;
mute 3&lt;/p&gt;

&lt;h1&gt;
  
  
  Create a file 'user.auth' with a username and a password
&lt;/h1&gt;

&lt;h1&gt;
  
  
  cat &amp;lt;&amp;lt; EOF &amp;gt; user.auth
&lt;/h1&gt;

&lt;h1&gt;
  
  
  user
&lt;/h1&gt;

&lt;h1&gt;
  
  
  password
&lt;/h1&gt;

&lt;h1&gt;
  
  
  EOF
&lt;/h1&gt;

&lt;p&gt;auth-user-pass user.auth&lt;/p&gt;

&lt;h1&gt;
  
  
  Copy the certificates from MikroTik and change
&lt;/h1&gt;

&lt;h1&gt;
  
  
  the filenames below if needed
&lt;/h1&gt;

&lt;p&gt;ca cert_export_MikroTik.crt&lt;br&gt;
cert &lt;a href="mailto:cert_export_user@MikroTik.crt"&gt;cert_export_user@MikroTik.crt&lt;/a&gt;&lt;br&gt;
key &lt;a href="mailto:cert_export_user@MikroTik.key"&gt;cert_export_user@MikroTik.key&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Add routes to networks behind MikroTik
&lt;/h1&gt;

&lt;h1&gt;
  
  
  route 192.168.10.0 255.255.255.0
&lt;/h1&gt;

&lt;p&gt;Try to connect&lt;br&gt;
sudo openvpn USERNAME.ovpn&lt;/p&gt;

&lt;p&gt;Decrypt private key to avoid password asking&lt;br&gt;
openssl rsa -passin pass:password -in &lt;a href="mailto:cert_export_user@MikroTik.key"&gt;cert_export_user@MikroTik.key&lt;/a&gt; -out &lt;a href="mailto:cert_export_user@MikroTik.key"&gt;cert_export_user@MikroTik.key&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Delete a user and revoke his certificate&lt;/p&gt;

&lt;h1&gt;
  
  
  Delete a user and revoke his certificate
&lt;/h1&gt;

&lt;h1&gt;
  
  
  Change variables below and paste the script
&lt;/h1&gt;

&lt;h1&gt;
  
  
  into MikroTik terminal window.
&lt;/h1&gt;

&lt;p&gt;:global CN [/system identity get name]&lt;br&gt;
:global USERNAME "user"&lt;/p&gt;

&lt;h2&gt;
  
  
  delete a user
&lt;/h2&gt;

&lt;p&gt;/ppp secret&lt;br&gt;
remove [find name=$USERNAME profile=VPN-PROFILE]&lt;/p&gt;

&lt;h2&gt;
  
  
  revoke a client certificate
&lt;/h2&gt;

&lt;p&gt;/certificate&lt;br&gt;
issued-revoke [find name="$USERNAME@$CN"]&lt;/p&gt;

&lt;p&gt;Revert OpenVPN server configuration on MikroTik&lt;/p&gt;

&lt;h1&gt;
  
  
  Revert OpenVPN configuration
&lt;/h1&gt;

&lt;p&gt;/ip pool&lt;br&gt;
remove [find name=VPN-POOL]&lt;/p&gt;

&lt;p&gt;/ppp profile&lt;br&gt;
remove [find name=VPN-PROFILE]&lt;/p&gt;

&lt;p&gt;/ip firewall filter&lt;br&gt;
remove [find comment="Allow OpenVPN"]&lt;/p&gt;

&lt;p&gt;/ppp secret&lt;br&gt;
remove [find profile=VPN-PROFILE]&lt;/p&gt;

&lt;p&gt;/certificate&lt;/p&gt;

&lt;h2&gt;
  
  
  delete the certificates manually
&lt;/h2&gt;

</description>
    </item>
    <item>
      <title>AWS Classic Load Balancer vs Application Load Balancer</title>
      <dc:creator>Ihor</dc:creator>
      <pubDate>Mon, 11 Feb 2019 13:41:12 +0000</pubDate>
      <link>https://dev.to/garyker/aws-classic-load-balancer-vs-application-load-balancer-12m0</link>
      <guid>https://dev.to/garyker/aws-classic-load-balancer-vs-application-load-balancer-12m0</guid>
      <description>&lt;p&gt;Elastic Load Balancing supports two types of load balancers: Application Load Balancers and Classic Load Balancers. While there is some overlap in the features, AWS does not maintain feature parity between the two types of load balancers. Content below lists down the feature comparison for both.&lt;/p&gt;

&lt;p&gt;Usage Pattern&lt;/p&gt;

&lt;p&gt;A Classic Load Balancer is ideal for simple load balancing of traffic across multiple EC2 instances,&lt;br&gt;
Application Load Balancer is ideal for microservices or container-based architectures where there is a need to route traffic to multiple services or load balance across multiple ports on the same EC2 instance.&lt;br&gt;
AWS ELB Classic Load Balancer vs Application Load Balancer&lt;br&gt;
Supported Protocols&lt;/p&gt;

&lt;p&gt;Classic Load Balancer operates at layer 4 and supports HTTP, HTTPS, TCP, SSL while Application Load Balancer operates at layer 7 and supports HTTP, HTTPS, HTTP/2, WebSockets&lt;br&gt;
If Layer-4 features are needed, Classic Load Balancers should be used&lt;br&gt;
Supported Platforms&lt;/p&gt;

&lt;p&gt;Classic Load Balancer supports both EC2-Classic and EC2-VPC while Application Load Balancer supports only EC2-VPC&lt;br&gt;
Stick Sessions (Cookies)&lt;/p&gt;

&lt;p&gt;Stick Sessions (Session Affinity) enables the load balancer to bind a user’s session to a specific instance, which ensures that all requests from the user during the session are sent to the same instance&lt;br&gt;
Both Classic &amp;amp; Application Load Balancer supports sticky sessions to maintain session affinity&lt;br&gt;
Idle Connection Timeout&lt;/p&gt;

&lt;p&gt;Idle Connection Timeout helps specify a time period, which ELB uses to close the connection if no data has been sent or received by the time that the idle timeout period elapses&lt;br&gt;
Both Classic &amp;amp; Application Load Balancer supports idle connection timeout&lt;br&gt;
Connection Draining&lt;/p&gt;

&lt;p&gt;Connection draining enables the load balancer to complete in-flight requests made to instances that are de-registering or unhealthy&lt;br&gt;
Both Classic &amp;amp; Application Load Balancer supports connection draining&lt;br&gt;
SSL Termination&lt;/p&gt;

&lt;p&gt;Both Classic Load Balancer and ALB support SSL Termination to decrypt requests from clients before sending them to targets and hence reducing the load. SSL certificate must be installed on the load balancer.&lt;br&gt;
Back-end Server Authentication&lt;/p&gt;

&lt;p&gt;Back-end Server Authentication enables authentication of the instances. Load balancer communicates with an instance only if the public key that the instance presents to the load balancer matches a public key in the authentication policy for the load balancer.&lt;br&gt;
Classic Load Balancer supports while Application Load Balancer does notsupport Back-end Server Authentication&lt;br&gt;
Cross-zone Load Balancing&lt;/p&gt;

&lt;p&gt;Cross-zone Load Balancing help distribute incoming requests evenly across all instances in its enabled AZs. By default, Load Balancer will evenly distribute requests evenly across its enabled AZs, irrespective of the instances it hosts.&lt;br&gt;
Both Classic &amp;amp; Application Load Balancer both support Cross-zone load balancing, however for Classic it needs to be enabled while for ALB it is always enabled&lt;br&gt;
Health Checks&lt;/p&gt;

&lt;p&gt;Both Classic &amp;amp; Application Load Balancer both support Health checks to determine if the instance is healthy or unhealthy&lt;br&gt;
ALB provides health check improvements that allow detailed error codes from 200-399 to be configured&lt;br&gt;
CloudWatch Metrics&lt;/p&gt;

&lt;p&gt;Both Classic &amp;amp; Application Load Balancer integrate with CloudWatch to provide metrics, with ALB providing additional metrics&lt;br&gt;
Access Logs&lt;/p&gt;

&lt;p&gt;Access logs capture detailed information about requests sent to the load balancer. Each log contains information such as the time the request was received, the client’s IP address, latencies, request paths, and server responses&lt;br&gt;
Both Classic &amp;amp; Application Load Balancer provide access logs, with ALB providing additional attributes&lt;br&gt;
Host-based Routing &amp;amp; Path-based Routing&lt;/p&gt;

&lt;p&gt;Host-based routing use host conditions to define rules that forward requests to different target groups based on the host name in the host header. This enables ALB to support multiple domains using a single load balancer.&lt;br&gt;
Path-based routing use path conditions to define rules that forward requests to different target groups based on the URL in the request. Each path condition has one path pattern. If the URL in a request matches the path pattern in a listener rule exactly, the request is routed using that rule.&lt;br&gt;
Only ALB supports Host-based &amp;amp; Path-based routing.&lt;br&gt;
Dynamic Ports&lt;/p&gt;

&lt;p&gt;Only ALB supports Dynamic Port Mapping with ECS, which allows two containers of a service to run on a single server on dynamic ports that ALB automatically detects and reconfigures itself.&lt;br&gt;
Deletion Protection&lt;/p&gt;

&lt;p&gt;Only ALB supports Deletion Protection, wherein a load balancer can’t be deleted if deletion protection is enabled&lt;br&gt;
Request Tracing&lt;/p&gt;

&lt;p&gt;Only ALB supports Request Tracing to track HTTP requests from clients to targets or other services.&lt;br&gt;
IPv6 in VPC&lt;/p&gt;

&lt;p&gt;Only ALB supports IPv6 in VPC&lt;br&gt;
AWS WAF&lt;/p&gt;

&lt;p&gt;Only ALB supports AWS WAF, which can be directly used on ALBs (both internal and external) in a VPC, to protect websites and web services&lt;/p&gt;

</description>
      <category>devops</category>
      <category>aws</category>
      <category>elb</category>
      <category>alb</category>
    </item>
  </channel>
</rss>
