<?xml-stylesheet href="/rss.xsl" type="text/xsl"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Eki&#39;s Home</title>
    <link>https://eki.moe/</link>
    <description>Recent content on Eki&#39;s Home</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <copyright>Eki</copyright>
    <lastBuildDate>Thu, 21 Sep 2023 19:33:53 +0900</lastBuildDate>
    
        <atom:link href="https://eki.moe/index.xml" rel="self" type="application/rss+xml" />
    
    
    
        <item>
        <title>Creating Debian Cloud-init Template for Proxmox VE</title>
        <link>https://eki.moe/posts/creating-debian-cloud-init-template-for-proxmox-ve/</link>
        <pubDate>Thu, 21 Sep 2023 19:33:53 +0900</pubDate>
        
        <guid>https://eki.moe/posts/creating-debian-cloud-init-template-for-proxmox-ve/</guid>
        <description>Eki&#39;s Home https://eki.moe/posts/creating-debian-cloud-init-template-for-proxmox-ve/ -&lt;p&gt;Cloud-init is a package that contains utilities for early initialization of cloud instances. (Source: &lt;a href=&#34;https://wiki.archlinux.org/title/Cloud-init&#34;&gt;ArchWiki&lt;/a&gt;). It allows headless and painless configuration for spinning up new cloud instances, so no more installing from scratch for every new instance. Check out &lt;a href=&#34;https://pve.proxmox.com/wiki/Cloud-Init_Support&#34;&gt;Proxmox&amp;rsquo;s documentation&lt;/a&gt; for more info on its support within Proxmox VE.&lt;/p&gt;
&lt;p&gt;Debian actually provides cloud-init ready images for deploying now, so it is even more convinient than before.&lt;/p&gt;
&lt;h1 id=&#34;creating-vm&#34;&gt;Creating VM&lt;/h1&gt;
&lt;p&gt;Firstly we will need to create a VM as the basis of operations. Click &lt;code&gt;Create VM&lt;/code&gt; on the top right corner. Then we just follow the interactive guide provided by the GUI.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;images/create_vm_general.webp&#34; alt=&#34;General tab&#34;&gt;&lt;/p&gt;
&lt;p&gt;Make sure to check the &lt;code&gt;Advanced&lt;/code&gt; box to have all options show up.&lt;/p&gt;
&lt;p&gt;Set your instance name and ID as you wish, and check &lt;code&gt;Start at boot&lt;/code&gt; if you want it to do so, which you probably do. This will not boot the template, but any VMs you have created from it.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;images/create_vm_os.webp&#34; alt=&#34;OS tab&#34;&gt;&lt;/p&gt;
&lt;p&gt;Select &lt;code&gt;Do not use any media&lt;/code&gt; for the OS image, as we will not be installing by hand, but rather by importing a ready-made image.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;images/create_vm_system.webp&#34; alt=&#34;System tab&#34;&gt;&lt;/p&gt;
&lt;p&gt;Check &lt;code&gt;Qemu Agent&lt;/code&gt;, and leave everything as is in the image. Qemu Agents will allow for extra operations from the host. &lt;code&gt;VirtIO SCSI single&lt;/code&gt; should be used, as it has the best performance, stated &lt;a href=&#34;https://pve.proxmox.com/wiki/Qemu/KVM_Virtual_Machines#qm_virtual_machines_settings&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;images/create_vm_disks.webp&#34; alt=&#34;Disks tab&#34;&gt;&lt;/p&gt;
&lt;p&gt;Delete the disk Proxmox VE has created for you by default, as we will not be needing it.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;images/create_vm_disks_deleted.webp&#34; alt=&#34;Disks tab&#34;&gt;&lt;/p&gt;
&lt;p&gt;This is how it should look like after you have deleted the disk.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;images/create_vm_cpu.webp&#34; alt=&#34;CPU tab&#34;&gt;&lt;/p&gt;
&lt;p&gt;Regarding the CPU type,&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;If you don’t care about live migration or have a homogeneous cluster where all nodes have the same CPU and same microcode version, set the CPU type to host, as in theory this will give your guests maximum performance.&lt;/li&gt;
&lt;li&gt;If you care about live migration and security, and you have only Intel CPUs or only AMD CPUs, choose the lowest generation CPU model of your cluster.&lt;/li&gt;
&lt;li&gt;If you care about live migration without security, or have mixed Intel/AMD cluster, choose the lowest compatible virtual QEMU CPU type.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For QEMU CPU type compatibiliy,&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;kvm64 (x86-64-v1): Compatible with Intel CPU &amp;gt;= Pentium 4, AMD CPU &amp;gt;= Phenom.&lt;/li&gt;
&lt;li&gt;x86-64-v2: Compatible with Intel CPU &amp;gt;= Nehalem, AMD CPU &amp;gt;= Opteron_G3. Added CPU flags compared to x86-64-v1: +cx16, +lahf-lm, +popcnt, +pni, +sse4.1, +sse4.2, +ssse3.&lt;/li&gt;
&lt;li&gt;x86-64-v2-AES: Compatible with Intel CPU &amp;gt;= Westmere, AMD CPU &amp;gt;= Opteron_G4. Added CPU flags compared to x86-64-v2: +aes.&lt;/li&gt;
&lt;li&gt;x86-64-v3: Compatible with Intel CPU &amp;gt;= Broadwell, AMD CPU &amp;gt;= EPYC. Added CPU flags compared to x86-64-v2-AES: +avx, +avx2, +bmi1, +bmi2, +f16c, +fma, +movbe, +xsave.&lt;/li&gt;
&lt;li&gt;x86-64-v4: Compatible with Intel CPU &amp;gt;= Skylake, AMD CPU &amp;gt;= EPYC v4 Genoa. Added CPU flags compared to x86-64-v3: +avx512f, +avx512bw, +avx512cd, +avx512dq, +avx512vl.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This choice is up to personal taste. You can customize this setting after you create the template, or even for each instance.&lt;/p&gt;
&lt;p&gt;For Memory and Network settings, set them to what you see fit.&lt;/p&gt;
&lt;p&gt;Next, some operations using ssh / console is needed, as Proxmox VE do not have them ready in the GUI.&lt;/p&gt;
&lt;h1 id=&#34;readying-vm&#34;&gt;Readying VM&lt;/h1&gt;
&lt;p&gt;We will need to manually add a serial console to the VM, otherwise the web console will not work.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;qm set &amp;lt;VM ID&amp;gt; --serial0 socket --vga serial0
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The Debian team has prepared a variety of cloud images available for download. Goto &lt;a href=&#34;https://cloud.debian.org/images/cloud/&#34;&gt;https://cloud.debian.org/images/cloud/&lt;/a&gt;, and scroll down to find the release of your choice. Personally I prefer the &amp;ldquo;latest&amp;rdquo; flavor.&lt;/p&gt;
&lt;p&gt;I will download the &amp;ldquo;genericcloud&amp;rdquo; &amp;ldquo;amd64&amp;rdquo; qcow2 image, as it fits me best.&lt;/p&gt;
&lt;p&gt;Then we will need to resize the image, otherwise the image will be considered &amp;ldquo;full&amp;rdquo;, unavailable for any operations.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;qemu-img resize &amp;lt;Image Filename&amp;gt; &amp;lt;Size, e.g. 5G&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Import the image file to our VM&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;qm importdisk &amp;lt;VM ID&amp;gt; &amp;lt;Image Filename&amp;gt; &amp;lt;Storage, be careful if you use LVM / ZFS&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Return to the web GUI. Go to Datacenter -&amp;gt; node -&amp;gt; VM -&amp;gt; Hardware. We will need to make 3 changes here.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Add -&amp;gt; CloudInit Drive -&amp;gt; Storage same as your VM disk storage -&amp;gt; Add&lt;/li&gt;
&lt;li&gt;Unused Disk 0 at the bottom. This is the disk image we have just imported. Click on it, then choose &amp;ldquo;edit&amp;rdquo;. As I&amp;rsquo;m using SSDs, I&amp;rsquo;m going to make two changes - check &amp;ldquo;Discard&amp;rdquo; and &amp;ldquo;SSD emulation&amp;rdquo;. Also check &amp;ldquo;IO thread&amp;rdquo; if it isn&amp;rsquo;t checked.&lt;/li&gt;
&lt;li&gt;Display -&amp;gt; edit -&amp;gt; Graphic card -&amp;gt; choose &amp;ldquo;default&amp;rdquo;. I prefer this over a serial console for it being graphics based.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Go to &amp;ldquo;Options&amp;rdquo; for this VM. Double-click &amp;ldquo;Boot Order&amp;rdquo;, enable &amp;ldquo;scsi0&amp;rdquo;, and move it to the second posision, as we might still want to boot from the virtual optical drive.&lt;/p&gt;
&lt;p&gt;You can read more about all the VM options at &lt;a href=&#34;https://pve.proxmox.com/wiki/Qemu/KVM_Virtual_Machines&#34;&gt;Proxmox VE Documentation&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Right-click the VM on the left side, and choose &amp;ldquo;convert to template&amp;rdquo;. Wait for it to finish, and now you have a template ready for use.&lt;/p&gt;
&lt;h1 id=&#34;using-the-template&#34;&gt;Using the template&lt;/h1&gt;
&lt;p&gt;To use the template, right-click again on the template, and choose &amp;ldquo;clone&amp;rdquo;. Name your VM, set a VM ID, and remember to set it to &amp;ldquo;Full Clone&amp;rdquo;, so the VM does not rely on the template.&lt;/p&gt;
&lt;p&gt;Now we can go to the new VM -&amp;gt; Cloud-Init, and set your user name to root, root password, ssh public keys, and networking. Remember to set them so you don&amp;rsquo;t get locked out like I did.&lt;/p&gt;
&lt;p&gt;Start the VM when you feel ready.&lt;/p&gt;
&lt;h1 id=&#34;final-touches&#34;&gt;Final touches&lt;/h1&gt;
&lt;p&gt;Go to Console. If you see &amp;ldquo;starting serial terminal on interface serial0&amp;rdquo;, just press enter and the console will load. Wait for cloud-init to finish loading, and then ssh into the VM with username &amp;ldquo;root&amp;rdquo; and the password / ssh key you chose. You did set it, right? Right?&lt;/p&gt;
&lt;p&gt;Install qemu-guest-agent and enable it.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;apt install qemu-guest-agent &amp;amp;&amp;amp; systemctl start qemu-guest-agent
&lt;/code&gt;&lt;/pre&gt;&lt;h1 id=&#34;references--sources&#34;&gt;References &amp;amp; Sources&lt;/h1&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://pve.proxmox.com/wiki/Qemu/KVM_Virtual_Machines&#34;&gt;Proxmox VE Documentation: Qemu/KVM Virtual Machines&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://pve.proxmox.com/wiki/Cloud-Init_Support&#34;&gt;Proxmox VE Documentation: Cloud-Init Support&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.youtube.com/watch?v=MJgIm03Jxdo&#34;&gt;Learn Linux TV@YouTube: Proxmox VE - How to build an Ubuntu 22.04 Template (Updated Method)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
- https://eki.moe/posts/creating-debian-cloud-init-template-for-proxmox-ve/ - Eki</description>
        </item>
    
    
    
        <item>
        <title>Fancontrol Script for Dell iDRAC</title>
        <link>https://eki.moe/posts/fancontrol-script-for-dell-idrac/</link>
        <pubDate>Wed, 20 Sep 2023 21:45:00 +0900</pubDate>
        
        <guid>https://eki.moe/posts/fancontrol-script-for-dell-idrac/</guid>
        <description>Eki&#39;s Home https://eki.moe/posts/fancontrol-script-for-dell-idrac/ -&lt;p&gt;I have looked into some solutions for my noisy Dell PowerEdge R730 in the post &lt;a href=&#34;https://eki.moe/posts/idrac-8-settings-and-tricks&#34;&gt;iDRAC 8 Settings and Tricks&lt;/a&gt;. This is the solution I have come up in the end.&lt;/p&gt;
&lt;h1 id=&#34;thought-process&#34;&gt;Thought process&lt;/h1&gt;
&lt;p&gt;Through experience and experiments I have found that under my loads, CPU temperatures will hardly go over 50 degress celcius even with a 5% fan speed. Thus my idea was to just keep it simple and set two thresholds for temperatures that I consider to be harmful and dangerous. They can be modified themselves.&lt;/p&gt;
&lt;p&gt;Also, the script is designed to run on the server itself, so IPMI usernames and passwords are not neccesary.&lt;/p&gt;
&lt;h1 id=&#34;usage&#34;&gt;Usage&lt;/h1&gt;
&lt;p&gt;All that is needed comes in this script. To run it, use this one-liner.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;wget https://github.com/nagaeki/dell-idrac-fancontrol/raw/main/setup.sh -O setup.sh &amp;amp;&amp;amp; chmod +x setup.sh &amp;amp;&amp;amp; bash setup.sh &amp;amp;&amp;amp; rm setup.sh
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Check out the &lt;a href=&#34;https://github.com/nagaeki/dell-idrac-fancontrol&#34;&gt;Github repository&lt;/a&gt; for more.&lt;/p&gt;
- https://eki.moe/posts/fancontrol-script-for-dell-idrac/ - Eki</description>
        </item>
    
    
    
        <item>
        <title>iDRAC 8 Settings and Tricks</title>
        <link>https://eki.moe/posts/idrac-8-settings-and-tricks/</link>
        <pubDate>Wed, 20 Sep 2023 18:27:00 +0900</pubDate>
        
        <guid>https://eki.moe/posts/idrac-8-settings-and-tricks/</guid>
        <description>Eki&#39;s Home https://eki.moe/posts/idrac-8-settings-and-tricks/ -&lt;p&gt;Information might change with time. Categories based on left column in iDRAC GUI.&lt;/p&gt;
&lt;h1 id=&#34;server&#34;&gt;Server&lt;/h1&gt;
&lt;h2 id=&#34;system-hostname--operating-system&#34;&gt;System Hostname &amp;amp; Operating System&lt;/h2&gt;
&lt;p&gt;Normally these two values are provided by the &lt;a href=&#34;https://www.dell.com/support/kbdoc/en-us/000178050/support-for-dell-emc-idrac-service-module&#34;&gt;Dell EMC iSM (iDRAC Service Module)&lt;/a&gt;. Check to see if you can install iSM to update these values in realtime.&lt;/p&gt;
&lt;p&gt;However iSM might not support the system you&amp;rsquo;re using. Those times it is helpful to manually set them. You can either use &lt;code&gt;racadm&lt;/code&gt; or &lt;code&gt;ipmitool&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&#34;racadm&#34;&gt;racadm&lt;/h3&gt;
&lt;p&gt;To use racadm, either ssh into iDRAC, or use the mobile app &lt;code&gt;Dell OpenManage&lt;/code&gt;,or use the &lt;code&gt;racadm&lt;/code&gt; utility on your device. The &lt;code&gt;racadm&lt;/code&gt; utility does not support any of my current operating systems in use, so I will use the first two methods.&lt;/p&gt;
&lt;p&gt;Use the following commands -&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;racadm set System.ServerOS.HostName hostname.example.com
racadm set System.ServerOS.OSName &amp;#34;OSName&amp;#34;
&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&#34;ipmitool&#34;&gt;ipmitool&lt;/h3&gt;
&lt;p&gt;Install &lt;code&gt;ipmitool&lt;/code&gt; on your system. Most Linux repositories have this utility ready.&lt;/p&gt;
&lt;p&gt;To use this, you first need to ensure that IPMI over lan is enabled. Go to iDRAC Settings -&amp;gt; Network -&amp;gt; scroll down to IPMI settings and check &lt;code&gt;Enable IPMI Over LAN&lt;/code&gt;. Click &lt;code&gt;apply&lt;/code&gt; in the bottom right corner.&lt;/p&gt;
&lt;p&gt;Usage -&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;ipmitool -I lanplus -H $IP -U $USER -P $PASS raw $COMMANDS
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Note that &lt;code&gt;lanplus&lt;/code&gt; is constant. To set hostname, the following IPMI raw command can be used.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;raw 0x06 0x58 0x02 0x00 0x05 0x04 0x4c 0x4d 0x4e 0x4f

Byte 0 : 0x06 Network Function
Byte 1 : 0x58 Command
Byte 2 : 0x02 Parameter Selector (distinguish between set Firmware Version, OS Name, System Name etc.)
Byte 3 : 0x00 Set Selector (this equals 0 implies that the user is setting the parameter)
Byte 4 : 0x05 Check String data
Byte 5 : 0x04  --&amp;gt; data length
Byte 6…n : data bytes

Usage:
For example, to set the hostname to &amp;#34;DELL&amp;#34;:

raw 0x06 0x58 0x02 0x00 0x05 --This part is common
0x04 -- hostname string length- four characters(DELL) in our example
0x44 0x45 0x4c 0x4c -- ASCII equivalent for DELL

It is advised to use a ASCII to Hex convertor with the prefix 0x to easily translate the characters.
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;virtual-console&#34;&gt;Virtual Console&lt;/h2&gt;
&lt;p&gt;Though HTML5 is the shiny new thing, I actually prefer to use Java here because of poor HTML5 performance on iDRAC8 and because how it always gets blocked for unsafe certificates.&lt;/p&gt;
&lt;h2 id=&#34;alerts&#34;&gt;Alerts&lt;/h2&gt;
&lt;p&gt;This is important!&lt;/p&gt;
&lt;h3 id=&#34;alerts-1&#34;&gt;Alerts&lt;/h3&gt;
&lt;p&gt;Firstly enable &lt;code&gt;Alerts&lt;/code&gt; in the top.&lt;/p&gt;
&lt;p&gt;For &lt;code&gt;Alert Filters&lt;/code&gt;, I would uncheck &lt;code&gt;Info&lt;/code&gt; because it&amp;rsquo;s often not that important. Then check what alerts you wish in the table down below. Note that you need to do this for every page. With &lt;code&gt;Info&lt;/code&gt; unchecked, that will be 13 pages.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;images/idrac_alerts_page.webp&#34; alt=&#34;Alerts Page Example&#34;&gt;&lt;/p&gt;
&lt;h3 id=&#34;snmp-and-email-settings&#34;&gt;SNMP and Email Settings&lt;/h3&gt;
&lt;p&gt;Here you will need to set destination addresses for SNMP and email alerts. Down below you will find SMTP server settings. There are two things to take note here -&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Regarding authentication, because of how old iDRAC8 is, it does not support newer versions of TLS and newer cipher suites, so you will need to change your mail server settings accordingly.&lt;/li&gt;
&lt;li&gt;Regarding the username, this is only the username for &lt;strong&gt;authentication&lt;/strong&gt;, not the mail &lt;strong&gt;envelope-from address&lt;/strong&gt;. This might trigger safeguard mechanisms within your mail server, as this could be used for forging from addresses. You will need to allow this &lt;strong&gt;authentication address&lt;/strong&gt; to send mail as the &lt;strong&gt;envelope-from address&lt;/strong&gt;. I will mention this again &lt;a href=&#34;#dns-idrac-name-and-static-dns-domain-name&#34;&gt;down below&lt;/a&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;What&amp;rsquo;s a &lt;code&gt;envelope-from address&lt;/code&gt;? Just like real-life mail, there is a envelope and the letter itself. The envelope is used by mail servers (post offices) to send the mail to the recipient, however the recipient will most likely get who the mail is from and for using information from the headers (the actual letter inside the envelope). In fact, a lot of email clients does not bother to show the envelope-from and envelope-to address, leading to higher risks. Thus it is normally not allowed to authenticate with one address and use another address for envelope-from, however a whitelist function is also normally in place. Consolidate documentations for this setting.&lt;/p&gt;
&lt;p&gt;Read more &lt;a href=&#34;https://www.mailgun.com/resources/learn/glossary/email-envelope/&#34;&gt;here&lt;/a&gt; and &lt;a href=&#34;https://www.spamhero.com/support/120008/Envelope_Sender_Vs_Email_Header_To&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;setup&#34;&gt;Setup&lt;/h2&gt;
&lt;p&gt;Here you can choose where the server boots to, as well as does this setting persist or not. This could be useful if you&amp;rsquo;re trying to boot into BIOS but wants to go to the loo real bad.&lt;/p&gt;
&lt;h1 id=&#34;idrac-settings&#34;&gt;iDRAC Settings&lt;/h1&gt;
&lt;h2 id=&#34;network-settings&#34;&gt;Network Settings&lt;/h2&gt;
&lt;h3 id=&#34;network&#34;&gt;Network&lt;/h3&gt;
&lt;h4 id=&#34;dns-idrac-name-and-static-dns-domain-name&#34;&gt;DNS iDRAC name and static DNS domain name&lt;/h4&gt;
&lt;p&gt;This are the two components that actually make up the envelope-from address, as mentioned &lt;a href=&#34;#snmp-and-email-settings&#34;&gt;here&lt;/a&gt;. The address will be DNS-iDRAC-Name@Static-DNS-Domain-Name. For example,&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;If
DNS iDRAC name = iDRAC-1234
and
Static DNS domain name = example.com

Then the envelope-from address will be
idrac-1234@example.com
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;By default the DNS iDRAC Name value will be IDRAC-&amp;lt;Dell Service Tag #&amp;gt;. Source: &lt;a href=&#34;https://www.dell.com/support/kbdoc/en-us/000176998/configuring-initial-idrac7-network-settings&#34;&gt;Dell&lt;/a&gt;&lt;/p&gt;
&lt;h4 id=&#34;ipmi-settings&#34;&gt;IPMI Settings&lt;/h4&gt;
&lt;p&gt;Enable IPMI Over LAN - mentioned previously &lt;a href=&#34;#ipmitool&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;user-authentication&#34;&gt;User Authentication&lt;/h2&gt;
&lt;p&gt;Here you can change user passwords as well as upload ssh key files.&lt;/p&gt;
&lt;h2 id=&#34;update-and-rollback&#34;&gt;Update and Rollback&lt;/h2&gt;
&lt;p&gt;This is not apparent, but the function to automatically search for firmware updates for your currently installed hardware does exist. For file location choose &lt;code&gt;HTTPS&lt;/code&gt;, and for HTTPS address use &lt;code&gt;downloads.dell.com&lt;/code&gt;. Wait for it to load, and then you can forget about finding all the update files one by one.&lt;/p&gt;
&lt;h1 id=&#34;hardware&#34;&gt;Hardware&lt;/h1&gt;
&lt;h2 id=&#34;fan&#34;&gt;Fan&lt;/h2&gt;
&lt;p&gt;The default fan profile is definitely quieter than older models, such that I can actually sleep with it. However, it can be even quieter.&lt;/p&gt;
&lt;p&gt;Context: Testing is done with 2 * E5-2680 V4 CPUs at around 25 degrees celsius ambient.&lt;/p&gt;
&lt;h3 id=&#34;basic-static-fan-speeds&#34;&gt;Basic static fan speeds&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;ipmitool&lt;/code&gt; is used here. How to use? Check &lt;a href=&#34;#ipmitool&#34;&gt;here&lt;/a&gt;&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;# print temps and fans rpms
ipmitool -I lanplus -H &amp;lt;iDRAC-IP&amp;gt; -U &amp;lt;iDRAC-USER&amp;gt; -P &amp;lt;iDRAC-PASSWORD&amp;gt; sensor reading &amp;#34;Temp&amp;#34; 

# print fan info
ipmitool -I lanplus -H &amp;lt;iDRAC-IP&amp;gt; -U &amp;lt;iDRAC-USER&amp;gt; -P &amp;lt;iDRAC-PASSWORD&amp;gt; sdr get &amp;#34;FAN1&amp;#34;

# enable manual/static fan control
ipmitool -I lanplus -H &amp;lt;iDRAC-IP&amp;gt; -U &amp;lt;iDRAC-USER&amp;gt; -P &amp;lt;iDRAC-PASSWORD&amp;gt; raw 0x30 0x30 0x01 0x00

# disable manual/static fan control
ipmitool -I lanplus -H &amp;lt;iDRAC-IP&amp;gt; -U &amp;lt;iDRAC-USER&amp;gt; -P &amp;lt;iDRAC-PASSWORD&amp;gt; raw 0x30 0x30 0x01 0x01

# set fan speed to percentage
ipmitool -I lanplus -H &amp;lt;iDRAC-IP&amp;gt; -U &amp;lt;iDRAC-USER&amp;gt; -P &amp;lt;iDRAC-PASSWORD&amp;gt; raw 0x30 0x30 0x02 0xff 0xXX
# 0xXX as speed percentage in hexdecimal. 0% would be 0x00, 100% would be 0x64, and so on.
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Read more detailed usages &lt;a href=&#34;https://www.spxlabs.com/blog/2019/3/16/silence-your-dell-poweredge-server&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&#34;fan-speed-curve&#34;&gt;Fan speed curve&lt;/h3&gt;
&lt;p&gt;The idea is to check CPU temps every other few minutes using cron, and set fan speeds according the CPU temperature at the time. For example, there is one solution here on &lt;a href=&#34;https://www.reddit.com/r/homelab/comments/x5y63n/fan_curve_for_dell_r730r730xd/&#34;&gt;reddit&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;However there is one problem with this approach as that in extreme circumstances CPU temperatures may rise too fast for cron to respond. Thus a response time of a few seconds is much more resonable.&lt;/p&gt;
&lt;h3 id=&#34;static-speed--automatic-curve&#34;&gt;Static speed + automatic curve&lt;/h3&gt;
&lt;p&gt;There is this wonderful docker image on Github &lt;a href=&#34;https://github.com/tigerblue77/Dell_iDRAC_fan_controller_Docker&#34;&gt;tigerblue77/Dell_iDRAC_fan_controller_Docker&lt;/a&gt; that not only has a second-level response time, but also allows the bios curve to kick in if things get out of hand for the quiet low speed settings.&lt;/p&gt;
&lt;p&gt;&lt;del&gt;However, in my own testing, even with a fan speed of just 5%, my two E5-2680 V4s never exceeded 70 degress with max load.&lt;/del&gt; &lt;strong&gt;But do not take my word for it. Do your own testing for your hardware&amp;rsquo;s safety.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Turns out I have made a mistake, and the previous test method did not put enough stress on the CPUs.&lt;/p&gt;
&lt;h3 id=&#34;faster-responses&#34;&gt;Faster responses&lt;/h3&gt;
&lt;p&gt;In the end I have decided to write a little script myself to regulate the fan speeds based on temperature thresholds. Find more about it in the post &lt;a href=&#34;https://eki.moe/posts/fancontrol-script-for-dell-idrac&#34;&gt;Fancontrol Script for Dell iDRAC&lt;/a&gt;.&lt;/p&gt;
&lt;h1 id=&#34;storage&#34;&gt;Storage&lt;/h1&gt;
&lt;p&gt;The only thing that needs to be mentioned here is the integrated RAID controller. More can be read in &lt;a href=&#34;https://eki.moe/posts/using-520-byte-sector-disks/&#34;&gt;this post&lt;/a&gt;.&lt;/p&gt;
&lt;h1 id=&#34;references--sources&#34;&gt;References &amp;amp; Sources&lt;/h1&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://www.dell.com/support/kbdoc/en-us/000141693/dell-poweredge-how-do-i-change-the-system-host-name-on-the-idrac&#34;&gt;Dell: Dell PowerEdge: How Do I Change the System Host Name on the iDRAC?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.dell.com/support/kbdoc/en-us/000178050/support-for-dell-emc-idrac-service-module&#34;&gt;Dell: Support for Dell iDRAC Service Module&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.dell.com/support/kbdoc/en-us/000176998/configuring-initial-idrac7-network-settings&#34;&gt;Dell: Configuring Initial iDRAC7 Network Settings&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.dell.com/support/kbdoc/en-us/000062035/psqn-idrac7-idrac8-smtp-email-tls-encryption-settings&#34;&gt;Dell: iDRAC7 and iDRAC8 SMTP email TLS Encryption settings&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.dell.com/support/kbdoc/ja-jp/000131098/dell-idrac-configuring-email-notifications-for-system-alerts-on-idrac7-8-and-idrac9&#34;&gt;Dell: How to Configure Integrated Dell Remote Access Controller (iDRAC) Email Alerts&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/ipmitool/ipmitool&#34;&gt;ipmitool@Github&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.reddit.com/r/homelab/comments/x5y63n/fan_curve_for_dell_r730r730xd/&#34;&gt;Reddit: Fan curve for Dell R730/R730xd&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.reddit.com/r/homelab/comments/t9pa13/dell_poweredge_fan_control_with_ipmitool/&#34;&gt;Reddit: Dell PowerEdge fan control with ipmitool - individual fan speeds&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.reddit.com/r/homelab/comments/7xqb11/dell_fan_noise_control_silence_your_poweredge/&#34;&gt;Reddit: Dell Fan Noise Control - Silence Your Poweredge&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.reddit.com/r/homelab/comments/779cha/manual_fan_control_on_r610r710_including_script/&#34;&gt;Reddit: Manual fan control on R610/R710, including script to revert to automatic if temp gets to high.&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.spxlabs.com/blog/2019/3/16/silence-your-dell-poweredge-server&#34;&gt;SPXLABS: Silence Your Dell PowerEdge Server&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.mybluelinux.com/what-is-email-envelope-and-email-header/&#34;&gt;MYBLUELINUX.COM: What is email envelope and email header&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.spamhero.com/support/120008/Envelope_Sender_Vs_Email_Header_To&#34;&gt;Spamhero: Envelope sender/recipient vs. email header From/To&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.mailgun.com/resources/learn/glossary/email-envelope/&#34;&gt;Mailgun: Email envelope&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
- https://eki.moe/posts/idrac-8-settings-and-tricks/ - Eki</description>
        </item>
    
    
    
        <item>
        <title>Proxmox VE Install Routine and Setup Email Notification</title>
        <link>https://eki.moe/posts/proxmox-ve-install-routine-and-setup-email-notification/</link>
        <pubDate>Mon, 18 Sep 2023 21:40:00 +0900</pubDate>
        
        <guid>https://eki.moe/posts/proxmox-ve-install-routine-and-setup-email-notification/</guid>
        <description>Eki&#39;s Home https://eki.moe/posts/proxmox-ve-install-routine-and-setup-email-notification/ -&lt;p&gt;These are some basic routines I go over during a Proxmox VE install. Putting them down here so I won&amp;rsquo;t forget about them. Information might change with time.&lt;/p&gt;
&lt;h1 id=&#34;install&#34;&gt;Install&lt;/h1&gt;
&lt;h2 id=&#34;file-system&#34;&gt;File System&lt;/h2&gt;
&lt;p&gt;During install you get to choose which file system you want to use. I&amp;rsquo;m going with a ZFS mirrored (RAID1) setup for Proxmox VE itself. Note that by saying Proxmox VE itself, I mean that VMs / Containers will run on other disks. Will touch on this later.&lt;/p&gt;
&lt;p&gt;Why ZFS? Basically, it&amp;rsquo;s great. If you want to know more about it, check out -&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://itsfoss.com/what-is-zfs/&#34;&gt;It&amp;rsquo;s Foss: What is ZFS? Why are People Crazy About it?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://youtu.be/lsFDp-W1Ks0&#34;&gt;Level1Linux@YouTube: What Is ZFS?: A Brief Primer&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;why-mirrored&#34;&gt;Why mirrored&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Losing one ssd on Proxmox is acceptable. I do not expect to lose both SSDs at the same time.&lt;/li&gt;
&lt;li&gt;RAIDZ needs at least 3 drives, while mirroring only needs 2.&lt;/li&gt;
&lt;li&gt;For workloads prioritizing IOPs, more VDEVs are preferred. Though this might not matter for Proxmox VE itself, it does matter for VMs and their pool, as will be discussed later.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;zfs-settings-during-install&#34;&gt;ZFS settings during install&lt;/h3&gt;
&lt;p&gt;Read more &lt;a href=&#34;https://pve.proxmox.com/pve-docs/chapter-pve-installation.html#advanced_zfs_options&#34;&gt;here&lt;/a&gt; as well as references below.&lt;/p&gt;
&lt;h4 id=&#34;ashift--12&#34;&gt;ashift = 12&lt;/h4&gt;
&lt;p&gt;The ashift value of the pool defines the minimum block size of the pool. As I have drives with 4K physical sectors (see &lt;a href=&#34;https://eki.moe/posts/using-520-byte-sector-disks/&#34;&gt;here&lt;/a&gt;), ashift = 12 corresponds to 4K sectors (2^12 = 4096). Even if you have a drive that uses 512 byte physical sectors, which is rare, using ashift = 12 is still fine. Note that once the ashift value is set for a pool, there is no going back unless you destroy the pool, which would mean reinstalling Proxmox VE. This is also why using ashift = 12 is recommended even for physical 512 byte sector drives, as if you add a 4K sector drive you will encounter performance issues.&lt;/p&gt;
&lt;p&gt;However, if you have those rare 8K sector SSDs - set ashift = 13. See also on this topic: &lt;a href=&#34;https://wiki.archlinux.org/title/ZFS#Advanced_Format_disks&#34;&gt;ArchWiki&lt;/a&gt;&lt;/p&gt;
&lt;h4 id=&#34;compress--lz4&#34;&gt;compress = lz4&lt;/h4&gt;
&lt;p&gt;LZ4 does not tax on IO performance but still compresses. Simple as that.&lt;/p&gt;
&lt;h4 id=&#34;checksum--copies&#34;&gt;checksum &amp;amp; copies&lt;/h4&gt;
&lt;p&gt;Leave as-is.&lt;/p&gt;
&lt;h4 id=&#34;hdsize&#34;&gt;hdsize&lt;/h4&gt;
&lt;p&gt;Normally it should be left at default, as this will let ZFS use all the free space it can use. However, if you want to leave some space for partitioning later, you can set it here. For example, because of complications regarding swap on ZFS (you shouldn&amp;rsquo;t), leave some space to add a swap partition later.&lt;/p&gt;
&lt;h2 id=&#34;email&#34;&gt;Email&lt;/h2&gt;
&lt;p&gt;Set it to a email address you own, as alerts will be sent here. This can be modified later.&lt;/p&gt;
&lt;h2 id=&#34;hostname&#34;&gt;Hostname&lt;/h2&gt;
&lt;p&gt;This can &lt;strong&gt;not&lt;/strong&gt; be modified later.&lt;/p&gt;
&lt;h1 id=&#34;after-install&#34;&gt;After Install&lt;/h1&gt;
&lt;h2 id=&#34;creating-another-zpool-for-vms-and-containers&#34;&gt;Creating another zpool for VMs and Containers&lt;/h2&gt;
&lt;p&gt;Check if your pool is using entire disks - run &lt;code&gt;zdb&lt;/code&gt; and find &lt;code&gt;whole_disk&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;It is recommended to point ZFS at an entire disk (ie. /dev/sdx rather than /dev/sdx1), which will automatically create a GPT (GUID Partition Table) and add an 8 MB reserved partition at the end of the disk for legacy bootloaders. &lt;a href=&#34;https://wiki.archlinux.org/title/ZFS#Storage_pools&#34;&gt;Source: ArchWiki&lt;/a&gt; There is also a reason regarding IO, however I was unable to find documentation sources for this. &lt;a href=&#34;https://www.reddit.com/r/zfs/comments/enxxyx/formatting_zfs_to_use_whole_disk_vs_partition/&#34;&gt;Source: Reddit&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;images/zfs_whole_disk_reason_reddit.webp&#34; alt=&#34;Reason to use whole disk - Reddit&#34;&gt;&lt;/p&gt;
&lt;p&gt;Also, I don&amp;rsquo;t like the look of having boot &amp;amp; EFI &amp;amp; ZFS partitions on a single disk, so I would rather have dedicated disks for storage.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;images/zfs_partition_vs_whole_disk.webp&#34; alt=&#34;Partition vs Whole Disk&#34;&gt;&lt;/p&gt;
&lt;p&gt;I use mirrored setups for this - not RAIDZ. Reasons have been listed above.&lt;/p&gt;
&lt;h2 id=&#34;zfs-trim-and-scrub&#34;&gt;ZFS trim and scrub&lt;/h2&gt;
&lt;p&gt;This is actually already enabled by default.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;root@ayanami:~# cat /etc/cron.d/zfsutils-linux 
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# TRIM the first Sunday of every month.
24 0 1-7 * * root if [ $(date +\%w) -eq 0 ] &amp;amp;&amp;amp; [ -x /usr/lib/zfs-linux/trim ]; then /usr/lib/zfs-linux/trim; fi

# Scrub the second Sunday of every month.
24 0 8-14 * * root if [ $(date +\%w) -eq 0 ] &amp;amp;&amp;amp; [ -x /usr/lib/zfs-linux/scrub ]; then /usr/lib/zfs-linux/scrub; fi
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;postfix-settings-so-alert-emails-wont-go-to-spam&#34;&gt;Postfix settings so alert emails won&amp;rsquo;t go to spam&lt;/h2&gt;
&lt;p&gt;I have my own email server with &lt;a href=&#34;https://mailcow.email/&#34;&gt;mailcow&lt;/a&gt;. If you use a different server / provider, your settings may vary.&lt;/p&gt;
&lt;h3 id=&#34;set-email-from-address&#34;&gt;Set email from address&lt;/h3&gt;
&lt;p&gt;Go to Datacenter -&amp;gt; Options -&amp;gt; &amp;ldquo;Email from address&amp;rdquo;. Enter your email from address here.&lt;/p&gt;
&lt;h3 id=&#34;get-prerequisites&#34;&gt;Get prerequisites&lt;/h3&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;apt-get install libsasl2-modules
&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&#34;maincf&#34;&gt;main.cf&lt;/h3&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;nano /etc/postfix/main.cf
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Comment out the &lt;code&gt;relayhost = &lt;/code&gt; line.&lt;/p&gt;
&lt;p&gt;Add the following at the end.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;relayhost = mail.relay.host:587
smtp_use_tls = yes
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_sasl_tls_security_options = noanonymous
smtp_tls_security_level = encrypt
&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&#34;sasl_passwd&#34;&gt;sasl_passwd&lt;/h3&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;echo &amp;#34;mail.relay.host your-email@gmail.com:YourAppPassword&amp;#34; &amp;gt; /etc/postfix/sasl_passwd
chmod 600 /etc/postfix/sasl_passwd
postmap /etc/postfix/sasl_passwd
postfix reload
&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&#34;send-testmail&#34;&gt;Send testmail&lt;/h3&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;mail -s Testmail youremail@domain.com
Testmail
.
&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&#34;check-mail-queue&#34;&gt;Check mail queue&lt;/h3&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;root@ayanami:~# mailq
Mail queue is empty
&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&#34;troubleshooting&#34;&gt;Troubleshooting&lt;/h3&gt;
&lt;p&gt;If you have errors like -&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;root@proxmox:~# mailq
-Queue ID-  --Size-- ----Arrival Time---- -Sender/Recipient-------
43B2E100F17    1399 Mon Nov  1 18:36:56  root@proxmox.local
(SASL authentication failed; cannot authenticate to server smtp.sendgrid.net[13.114.210.107]: no mechanism available)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Then you might have messed up the following -&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;apt-get install libsasl2-modules&lt;/li&gt;
&lt;li&gt;postmap /etc/postfix/sasl_passwd&lt;/li&gt;
&lt;li&gt;Wrong account / password&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Use &lt;code&gt;postqueue -f&lt;/code&gt; to retry the queue.&lt;/p&gt;
&lt;h2 id=&#34;system-and-zfs-alerts&#34;&gt;System and ZFS alerts&lt;/h2&gt;
&lt;p&gt;If you have your correct email set at installation, you have nothing else to worry about. All alerts will be sent to root@proxmox, and then forwarded to the set email address.&lt;/p&gt;
&lt;p&gt;If you need to fix it, you can find it at Datacenter -&amp;gt; Permissions -&amp;gt; Users -&amp;gt; root -&amp;gt; E-Mail.&lt;/p&gt;
&lt;p&gt;To test them out, just pull your drives out and wait for a email alert to arrive.&lt;/p&gt;
&lt;h2 id=&#34;enable-pci-e-passthrough&#34;&gt;Enable PCI-E passthrough&lt;/h2&gt;
&lt;p&gt;Make your modifications using the commmand line.&lt;/p&gt;
&lt;p&gt;Follow these guides:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://www.servethehome.com/how-to-pass-through-pcie-nics-with-proxmox-ve-on-intel-and-amd/&#34;&gt;ServeTheHome: How to Pass-through PCIe NICs with Proxmox VE on Intel and AMD&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://pve.proxmox.com/wiki/PCI(e)_Passthrough&#34;&gt;Proxmox Documentation: PCI(e) Passthrough&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://pve.proxmox.com/wiki/PCI_Passthrough&#34;&gt;Proxmox Documentation: PCI Passthrough&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;disable-conntrack-for-asymmetrical-routes&#34;&gt;Disable Conntrack for asymmetrical routes&lt;/h2&gt;
&lt;p&gt;Create / modify &lt;code&gt;/etc/pve/nodes/&amp;lt;nodename&amp;gt;/host.fw&lt;/code&gt; and add the following:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;[OPTIONS]
nf_conntrack_allow_invalid: 1
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Then restart the Proxmox VE firewall.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;pve-firewall stop &amp;amp;&amp;amp; pve-firewall start
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Source: &lt;a href=&#34;https://blog.swineson.me/zh/an-analysis-of-proxmox-ve-vm-outbound-packets-dropped-under-asymmetric-routing/&#34;&gt;blog.swineson.me&lt;/a&gt;&lt;/p&gt;
&lt;h1 id=&#34;references--sources&#34;&gt;References &amp;amp; Sources&lt;/h1&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://zenn.dev/yakumo/articles/2919b755c6ce7a&#34;&gt;Proxmoxのpostfixを設定する&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://technotim.live/posts/proxmox-alerts/&#34;&gt;Techno Tim: Set up alerts in Proxmox before it&amp;rsquo;s too late!&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.servethehome.com/proxmox-ve-e-mail-notifications-are-important/&#34;&gt;ServeTheHome: Proxmox VE E-mail Notifications are Important&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.reddit.com/r/Proxmox/comments/wuhvfx/proxmox_with_zfs_ssds_builtin_trim_cron_job_vs/&#34;&gt;Reddit: Proxmox with ZFS + SSDs: Built-in TRIM cron job vs zfs autotrim?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://forum.proxmox.com/threads/zfs-trim-on-proxmox.87962/&#34;&gt;Proxmox Forum: ZFS TRIM on Proxmox&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.reddit.com/r/zfs/comments/enxxyx/formatting_zfs_to_use_whole_disk_vs_partition/&#34;&gt;Reddit: Formatting ZFS to use whole disk vs. partition?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://blog.zanshindojo.org/proxmox-zfs-performance/amp/&#34;&gt;ZANSHIN DOJO: Proxmox ZFS Performance Tuning&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://pve.proxmox.com/wiki/ZFS_on_Linux&#34;&gt;Proxmox Documentation: ZFS on Linux&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://pve.proxmox.com/wiki/ZFS:_Tips_and_Tricks&#34;&gt;Proxmox Documentation: ZFS: Tips and Tricks&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://pve.proxmox.com/pve-docs/chapter-pve-installation.html#advanced_zfs_options&#34;&gt;Proxmox Documentation: Advanced ZFS Configuration Options&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://itsfoss.com/what-is-zfs/&#34;&gt;It&amp;rsquo;s Foss: What is ZFS? Why are People Crazy About it?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.high-availability.com/docs/ZFS-Tuning-Guide/&#34;&gt;high-availability.com: ZFS Tuning and Optimisation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://wiki.archlinux.org/title/ZFS&#34;&gt;ArchWiki: ZFS&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://youtu.be/lsFDp-W1Ks0&#34;&gt;Level1Linux@YouTube: What Is ZFS?: A Brief Primer&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://youtu.be/85ME8i4Ry6A&#34;&gt;Techno Tim@YouTube: Set up alerts in Proxmox before it&amp;rsquo;s too late!&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.servethehome.com/how-to-pass-through-pcie-nics-with-proxmox-ve-on-intel-and-amd/&#34;&gt;ServeTheHome: How to Pass-through PCIe NICs with Proxmox VE on Intel and AMD&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://pve.proxmox.com/wiki/PCI(e)_Passthrough&#34;&gt;Proxmox Documentation: PCI(e) Passthrough&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://pve.proxmox.com/wiki/PCI_Passthrough&#34;&gt;Proxmox Documentation: PCI Passthrough&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://blog.swineson.me/zh/an-analysis-of-proxmox-ve-vm-outbound-packets-dropped-under-asymmetric-routing/&#34;&gt;blog.swineson.me: Proxmox VE中虚拟机非对等路由出站数据包被丢的情况分析&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
- https://eki.moe/posts/proxmox-ve-install-routine-and-setup-email-notification/ - Eki</description>
        </item>
    
    
    
        <item>
        <title>Using 520 Byte Sector Disks</title>
        <link>https://eki.moe/posts/using-520-byte-sector-disks/</link>
        <pubDate>Mon, 18 Sep 2023 17:07:00 +0900</pubDate>
        
        <guid>https://eki.moe/posts/using-520-byte-sector-disks/</guid>
        <description>Eki&#39;s Home https://eki.moe/posts/using-520-byte-sector-disks/ -&lt;p&gt;Bought some dirt cheap used enterprise SSDs on Yahoo Auction, only to be not able to do anything with them. The 520 byte sector problem.&lt;/p&gt;
&lt;h1 id=&#34;the-problem&#34;&gt;The problem&lt;/h1&gt;
&lt;h2 id=&#34;whats-a-sector&#34;&gt;What&amp;rsquo;s a sector&lt;/h2&gt;
&lt;p&gt;In computer disk storage, a sector is a subdivision of a track on a magnetic disk or optical disc. In simpler terms, it is the smallest unit of allocation or operation of a disk, to some extend kind like a atom during chemimal reactions. In practice, operations often span across multiple sectors, and data not filling entire sectors will have the remainder of the sector filled with zeros. [Source: &lt;a href=&#34;https://en.wikipedia.org/wiki/Disk_sector&#34;&gt;Wikipedia&lt;/a&gt;]&lt;/p&gt;
&lt;p&gt;Traditionally HDDs have been using 512 byte sectors for a long time, however some modern storage devices has turned to 4KiB sectors for its ability to integrate stronger error correction algorithms to maintain data integrity at higher storage densities.&lt;/p&gt;
&lt;h2 id=&#34;why-do-some-disks-use-520-byte-sectors&#34;&gt;Why do some disks use 520 byte sectors?&lt;/h2&gt;
&lt;p&gt;The main motive here is that the extra bytes could be used for something else. For example, hardware RAID may use it for parity calculations, or special file systems may use it for other purposes.&lt;/p&gt;
&lt;p&gt;Sometimes 528 byte sectors are also used though less common in my experience. For the time being the focus will be put on 520 byte sectors.&lt;/p&gt;
&lt;h2 id=&#34;the-problem-with-520-byte-sectors&#34;&gt;The problem with 520 byte sectors&lt;/h2&gt;
&lt;p&gt;The problem is simple - it&amp;rsquo;s not normal. Linux cannot read disks formatted with 520-byte sectors. (Nor does Windows.) If you try to use linux with 520 byte sector drive, run dmesg and you might see the following error:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;images/linux_dmesg_unsupported_sector_size_520.webp&#34; alt=&#34;dmesg error observed on linux&#34;&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://youtu.be/DAaTfv96V9w?t=183&#34;&gt;Source: youtube.com/@ArtofServer&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;However, this will only show up if the operating system has access to the drives. In my case, connecting 520 byte sector drives to a Dell R730 with a H730p controller, the drives do show up on the controller management page as 520 byte sectors and &amp;ldquo;RAID ready&amp;rdquo;, however I was unable to do anything with them, nor did the controller pass the drives to the operating system, despite setting the controller in &amp;ldquo;HBA Mode&amp;rdquo;. Although some info online suggested that flashing a H710 into &amp;ldquo;IT mode&amp;rdquo; was able to fix the problem, no workaround for H730/H730p or anything that generation has come up. Thus I was unable to do anything with the drives unless I purchase another HBA card.&lt;/p&gt;
&lt;p&gt;In the end I purchased 2 &lt;a href=&#34;https://docs.broadcom.com/doc/12352067&#34;&gt;LSI 9217-8i 2308 HBAs&lt;/a&gt; for 160 CNY (around 20 USD at the time) on Taobao. As a bonus the cards were already flashed into IT mode, reducing my pain. IT mode basically means that instead of functioning as a RAID controller, the card will passthrough the disks without any modification. Though the HBA mode on my H730p should have functioned the same, for some hiccup or another the H730p did not pass it through. I ended up using the cards on another machine that did not have a build-in SAS controller but only a SATA one, so I guess nothing is wasted afterall.&lt;/p&gt;
&lt;h2 id=&#34;why-did-you-buy-those-disks-then-should-i-buy-them&#34;&gt;Why did you buy those disks then? Should I buy them?&lt;/h2&gt;
&lt;p&gt;The main selling point of these drives are that they are just cheap. Why are they cheap then? Well -&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The 520 byte sector problem.&lt;/li&gt;
&lt;li&gt;They&amp;rsquo;re old. In fact the drives I picked up were more than a decade old as of time writing. (Manufactured in week 52 of year 2012 - Data from S.M.A.R.T.)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;But they also have pros -&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;They are enterprise grade drives, so you enjoy all the enterprise-level stuff, like SAS, power-loss protection, and a very high level of endurance. Some drives I picked up only had a few terabytes written, while two drives which had 800+TBs written only used ~4% endurance.&lt;/li&gt;
&lt;li&gt;They are also pure MLC, so no slowdowns with TLC and QLC.&lt;/li&gt;
&lt;li&gt;Same or better performance than buying brand new, but sometimes with 1/4-1/3 of the cost.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Should you buy them? Well if you&amp;rsquo;re just a &amp;ldquo;normal&amp;rdquo; person planning your next PC build, I would probably say, no. It&amp;rsquo;s still a lot of effort to get something like this working, let alone the specific parts and hardware. I still just use consumer NVMe SSDs in my personal PC. But if you&amp;rsquo;re building your &amp;ldquo;homelab&amp;rdquo; with already enterprise grade servers, then why not. Still, the choice is up to you.&lt;/p&gt;
&lt;p&gt;But then again, come to think of it, no &amp;ldquo;normal&amp;rdquo; person should probably be reading this.&lt;/p&gt;
&lt;h1 id=&#34;the-fix&#34;&gt;The fix&lt;/h1&gt;
&lt;p&gt;Basically the fix will just be to reformat the drives into 512 byte sectors.&lt;/p&gt;
&lt;h2 id=&#34;prerequisites&#34;&gt;Prerequisites&lt;/h2&gt;
&lt;p&gt;I would recommend using Linux for the operation. In my opinion booting a live Ubuntu USB and using it is much simpler than Windows. However, Windows will still work for this.&lt;/p&gt;
&lt;p&gt;Fire up the terminal with root privileges. We will be using &lt;code&gt;sg3-utils&lt;/code&gt; and &lt;code&gt;smartmontools&lt;/code&gt;.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;apt update &amp;amp;&amp;amp; apt install sg3-utils smartmontools
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Run &lt;code&gt;sg_scan -i&lt;/code&gt; to see if your drives show up. If they don&amp;rsquo;t, then you have other problems to fix.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;root@ubuntu:~# sg_scan -i
/dev/sg0: scsi0 channel=0 id=0 lun=0
    NETAPP    X446_RALS200MCHT  NA02 [rmb=0 cmdq=1 pqual=0 pdev=0x0] 
/dev/sg1: scsi0 channel=0 id=1 lun=0
    NETAPP    X446_RALS200MCHT  NA02 [rmb=0 cmdq=1 pqual=0 pdev=0x0] 
/dev/sg2: scsi0 channel=0 id=2 lun=0
    HITACHI   HUSMM118 CLAR800  C250 [rmb=0 cmdq=1 pqual=0 pdev=0x0] 
/dev/sg3: scsi0 channel=0 id=3 lun=0
    HITACHI   HUSMM118 CLAR800  C250 [rmb=0 cmdq=1 pqual=0 pdev=0x0] 
/dev/sg4: scsi0 channel=0 id=32 lun=0
    DP        BP13G+EXP         3.35 [rmb=0 cmdq=1 pqual=0 pdev=0xd] 
/dev/sg5: scsi10 channel=0 id=0 lun=0 [em]
    HL-DT-ST  DVD-ROM DTA0N     D3C0 [rmb=1 cmdq=0 pqual=0 pdev=0x5]
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Identify your drives. Use &lt;code&gt;lsblk&lt;/code&gt; and &lt;code&gt;smartctl --all /dev/sgX&lt;/code&gt; to find the right drive. &lt;strong&gt;Like any other formatting operation, you will lose all the data on the drive you&amp;rsquo;re formatting. Precede with your own caution.&lt;/strong&gt;&lt;/p&gt;
&lt;h2 id=&#34;formatting&#34;&gt;Formatting&lt;/h2&gt;
&lt;p&gt;Just like any other thing, using 512 byte sectors with a disk will require the disk&amp;rsquo;s firmware to support it. Older drives might require a firmware re-flash. If you need to do this, consolidate the web. However, most modern drives since 2012 (&lt;a href=&#34;https://forum.level1techs.com/t/how-to-reformat-520-byte-drives-to-512-bytes-usually/133021&#34;&gt;source&lt;/a&gt;) will support 512, 520 and other sector sizes with the same firmware. For example, the HITACHI Ultrastar SSD1600MMs clearly states that it does support 512, 520, 528, and 4K sector sizes in its &lt;a href=&#34;https://documents.westerndigital.com/content/dam/doc-library/en_us/assets/public/western-digital/product/data-center-drives/ultrastar-sas-series/data-sheet-ultrastar-ssd1600mm.pdf&#34;&gt;datasheet&lt;/a&gt;, with the Ultrastar SSD400Ms supporting both 512 and 520 sector sizes, though not listed in its &lt;a href=&#34;https://documents.westerndigital.com/content/dam/doc-library/en_us/assets/public/western-digital/product/data-center-drives/ultrastar-sas-series/data-sheet-ultrastar-ssd400m.pdf&#34;&gt;datasheet&lt;/a&gt;. This will come bite me back later. Anyhow, getting something old enough to not support 512 byte sectors out of the box is probably not worth the effort.&lt;/p&gt;
&lt;p&gt;We will use the &lt;code&gt;sg_format&lt;/code&gt; utility for formatting. The command goes&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;sg_format /dev/sgX
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This will give information regarding the disk, such as&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;root@ubuntu:~# sg_format /dev/sg1
    NETAPP    X446_RALS200MCHT  NA02   peripheral_type: disk [0x0]
      &amp;lt;&amp;lt; supports protection information&amp;gt;&amp;gt;
      Unit serial number: XXVAV10A        
      LU name: 5000cca01313b5bc
Mode Sense (block descriptor) data, prior to changes:
  Number of blocks=390721968 [0x1749f1b0]
  Block size=520 [0x208]
Read Capacity (10) results:
   Number of logical blocks=390721968
   Logical block size=520 bytes
No changes made. To format use &amp;#39;--format&amp;#39;. To resize use &amp;#39;--resize&amp;#39;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;To actually format it, you will need to use the &lt;code&gt;--format&lt;/code&gt; option. &lt;strong&gt;There is no going back if the operation has started. You will have 15 seconds to cancel after you press enter. Precede at your own risk.&lt;/strong&gt; The follwing code only serves as an example.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;root@ubuntu:~# sg_format -v --format --size=512 /dev/sgX
    SanDisk   DOPE1920S5xnNMRI  3P01   peripheral_type: disk [0x0]
      PROTECT=1
      &amp;lt;&amp;lt; supports protection information&amp;gt;&amp;gt;
      Unit serial number: 00028FA6
      LU name: 50011731004624c0
    mode sense (10) cdb: 5a 00 01 00 00 00 00 00 fc 00 
Mode Sense (block descriptor) data, prior to changes:
  Number of blocks=3750748848 [0xdf8fe2b0]
  Block size=512 [0x200]

A FORMAT UNIT will commence in 15 seconds
    ALL data on /dev/sg2 will be DESTROYED
        Press control-C to abort
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;what-if-it-doesnt-want-to-format&#34;&gt;What if it doesn&amp;rsquo;t want to format?&lt;/h2&gt;
&lt;p&gt;For example, something like this will come up&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;root@ubuntu:~# sg_format -v --format --size=512 /dev/sgX
    SanDisk   DOPE1920S5xnNMRI  3P01   peripheral_type: disk [0x0]
      PROTECT=1
      &amp;lt;&amp;lt; supports protection information&amp;gt;&amp;gt;
      Unit serial number: 00028FA6
      LU name: 50011731004624c0
    mode sense (10) cdb: 5a 00 01 00 00 00 00 00 fc 00 
Mode Sense (block descriptor) data, prior to changes:
  Number of blocks=3750748848 [0xdf8fe2b0]
  Block size=520 [0x208]
    mode select (10) cdb: 55 11 00 00 00 00 00 00 1a 00 
mode select (10):
Fixed format, current; Sense key: Illegal Request
Additional sense: Parameter list length error
  Sense Key Specific: Error in Data parameters: byte 0
MODE SELECT command: Illegal request sense key, apart from Invalid opcode
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This is just the drive&amp;rsquo;s smart way of telling you that this is destructive. You can use &lt;code&gt;dd&lt;/code&gt; to zero the device out first, or you can just &lt;code&gt;sg_format&lt;/code&gt; them to 520 byte sectors first.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;sg_format -v --format --size=520 /dev/sgX
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;After that, you can &lt;code&gt;sg_format&lt;/code&gt; then to 512 byte sectors.&lt;/p&gt;
&lt;h2 id=&#34;confirming-the-results&#34;&gt;Confirming the results&lt;/h2&gt;
&lt;p&gt;Using &lt;code&gt;smartctl --all /dev/sgX&lt;/code&gt; we can check the sector sizes after the format. For example&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;root@ubuntu:~# smartctl --all /dev/sg2
smartctl 7.3 2022-02-28 r5338 [x86_64-linux-6.2.16-3-pve] (local build)
Copyright (C) 2002-22, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Vendor:               HITACHI
Product:              HUSMM118 CLAR800
Revision:             C250
Compliance:           SPC-4
User Capacity:        800,176,914,432 bytes [800 GB]
Logical block size:   512 bytes
Physical block size:  4096 bytes
LU is resource provisioned, LBPRZ=1
Rotation Rate:        Solid State Device
Form Factor:          2.5 inches
Logical Unit id:      0x5000cca04fb58110
Serial number:        0RY6UEWA
Device type:          disk
Transport protocol:   SAS (SPL-4)
Local Time is:        Mon Sep 18 19:01:10 2023 JST
SMART support is:     Available - device has SMART capability.
SMART support is:     Enabled
Temperature Warning:  Enabled

=== START OF READ SMART DATA SECTION ===
SMART Health Status: OK

Percentage used endurance indicator: 4%
Current Drive Temperature:     28 C
Drive Trip Temperature:        70 C

Accumulated power on time, hours:minutes 45063:15
Manufactured in week 42 of year 2016
Specified cycle count over device lifetime:  0
Accumulated start-stop cycles:  0
Specified load-unload count over device lifetime:  0
Accumulated load-unload cycles:  0
Elements in grown defect list: 0

Vendor (Seagate Cache) information
  Blocks sent to initiator = 50707552

Error counter log:
           Errors Corrected by           Total   Correction     Gigabytes    Total
               ECC          rereads/    errors   algorithm      processed    uncorrected
           fast | delayed   rewrites  corrected  invocations   [10^9 bytes]  errors
read:          0        0         0         0          0     723754.391           0
write:         0        0         0         0          0     818404.477           0

Non-medium error count:        0

No Self-tests have been logged
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;but-what-about-4k-sectors&#34;&gt;But what about 4K sectors?&lt;/h2&gt;
&lt;p&gt;Advanced Format (AF) is any disk sector format used to store data on magnetic disks in hard disk drives (HDDs) that exceeds 528 bytes per sector, frequently 4096, 4112, 4160, or 4224-byte (4 KB) sectors. &lt;a href=&#34;https://en.wikipedia.org/wiki/Advanced_Format&#34;&gt;Source: Wikipedia&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;If it&amp;rsquo;s the new modern thing, than it must be better, right? Well, not always.&lt;/p&gt;
&lt;p&gt;Remember how I said that the Ultrastar SSD400Ms not clearly labeling supported sector sizes will come back to bite me? Well, after trying to reformat them to 4096, aka 4K sectors, the formating succeeded without problem. However, I was unable to do anything to the disks. The disks still showed up in system, but anything as small as partitioning failed. After reverting them back to 512 byte sectors, everything worked fine, though S.M.A.R.T reports as &lt;code&gt;Logical block size:   512 bytes Physical block size:  4096 bytes&lt;/code&gt;. But on the newer Ultrastar SSD1600MMs, they still worked fine with 4K sectors.&lt;/p&gt;
&lt;p&gt;But what about performance? I expected performance to increase with 4K sectors, but it seemed to have actually decreased. Online sources divide on this topic, with some saying a increase while some say no noticeable differences. Considering that the older Ultrastar SSD400Ms are in 512 byte sectors, how the Ultrastar SSD1600MMs came in 512 byte sectors, as well as how my comsumer Kioxia NVMe SSDs worked fine in 512 byte sectors, I have decided to keep them in 512 byte mode. I guess it&amp;rsquo;s just not worth the hassle.&lt;/p&gt;
&lt;p&gt;I do believe that the operation in not destructive toward the firmware, so you can try it out yourself. &lt;strong&gt;Still, your mileage may very. Precede at your own risk.&lt;/strong&gt;&lt;/p&gt;
&lt;h1 id=&#34;references--sources&#34;&gt;References &amp;amp; Sources&lt;/h1&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://forum.level1techs.com/t/how-to-reformat-520-byte-drives-to-512-bytes-usually/133021&#34;&gt;Level1Techs: How to reformat 520 byte drives to 512 bytes (usually)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://en.wikipedia.org/wiki/Disk_sector&#34;&gt;Wikipedia: Disk Sector&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://en.wikipedia.org/wiki/Advanced_Format&#34;&gt;Wikipedia: Advanced Format&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://youtu.be/DAaTfv96V9w&#34;&gt;YouTube: Art of Server&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://nakoruru.jp/format_netapp_hdd_sas_520byte_sector_so_that_it_can_be_used/&#34;&gt;NetApp の HDD(SAS/520byteセクタ) をフォーマットして使えるようにしたい!&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://serverfault.com/questions/1025239/how-does-os-read-disks-that-were-formatted-as-520&#34;&gt;ServerFault: How does OS read disks that were formatted as 520?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://dannyda.com/2021/09/22/what-are-it-mode-hba-mode-raid-mode-in-sas-controllers/&#34;&gt;dannyda.com: What are IT mode, HBA mode, RAID mode in (SAS) Controllers?&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
- https://eki.moe/posts/using-520-byte-sector-disks/ - Eki</description>
        </item>
    
    
    
        <item>
        <title>在 internet.nl 上拿到满分</title>
        <link>https://eki.moe/posts/full-score-on-internet-nl/</link>
        <pubDate>Mon, 13 Feb 2023 17:05:14 +0800</pubDate>
        
        <guid>https://eki.moe/posts/full-score-on-internet-nl/</guid>
        <description>Eki&#39;s Home https://eki.moe/posts/full-score-on-internet-nl/ -&lt;p&gt;&lt;a href=&#34;https://internet.nl&#34;&gt;Internet.nl&lt;/a&gt; 是一个由网络社区和荷兰政府共同创立的项目。这个项目提供对网站，电子邮件和网络连接的测试，以便查看他们是否遵循了现代而可靠的技术/协议。 &lt;a href=&#34;https://internet.nl/about/&#34;&gt;Source&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;测试分为三个部分：网站，邮件和网络连接。网站，邮局测试中达到满分的域名会被加入他们的“名人堂”列表，双满分则更为稀少。网络连接测试不会进行研究，原因会在后文解释。&lt;/p&gt;
&lt;h1 id=&#34;网站测试&#34;&gt;网站测试&lt;/h1&gt;
&lt;p&gt;此部分使用 nginx 为例，版本号 1.22.1。&lt;/p&gt;
&lt;p&gt;对于一些项目，可能需要更改的配置文件有&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;/etc/nginx/nginx.conf&lt;/li&gt;
&lt;li&gt;/etc/nginx/sites-available/example.com (or /default)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;如果你在使用 Certbot，则还可能需要更改&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;/etc/letsencrypt/options-ssl-nginx.conf&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;modern-address-ipv6&#34;&gt;Modern address (IPv6)&lt;/h2&gt;
&lt;p&gt;分为三部分：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Nameserver 是否有 IPv6 地址，且是否可达（正确）。&lt;/li&gt;
&lt;li&gt;网站是否有 IPv6 地址，且是否可达（正确）。&lt;/li&gt;
&lt;li&gt;IPv6 连接下的网站是否和 IPv4 连接下的网站相同。&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;一般来说是能很容易满足的条件。&lt;/p&gt;
&lt;h2 id=&#34;signed-domain-name-dnssec&#34;&gt;Signed domain name (DNSSEC)&lt;/h2&gt;
&lt;p&gt;&lt;a href=&#34;https://zh.wikipedia.org/zh-cn/%E5%9F%9F%E5%90%8D%E7%B3%BB%E7%BB%9F%E5%AE%89%E5%85%A8%E6%89%A9%E5%B1%95&#34;&gt;DNSSEC&lt;/a&gt; 提供了对 DNS 数据来源的验证，在自己的域名注册商处设置即可。&lt;/p&gt;
&lt;h2 id=&#34;secure-connection-https&#34;&gt;Secure connection (HTTPS)&lt;/h2&gt;
&lt;p&gt;简单设置了 HTTPS 并不能在这里得到满分。&lt;/p&gt;
&lt;p&gt;一个很有用的网站，由 mozilla 提供，可生成众多配置文件：&lt;a href=&#34;https://ssl-config.mozilla.org&#34;&gt;ssl-config.mozilla.org&lt;/a&gt;&lt;/p&gt;
&lt;h3 id=&#34;https-available--https-redirect&#34;&gt;HTTPS available &amp;amp; HTTPS redirect&lt;/h3&gt;
&lt;p&gt;网站启用 HTTPS 连接与 HTTP 重定向即可。Nginx 模板如下&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;server {
    listen 80;
    listen [::]:80;
    server_name example.com www.example.com;
    return 301 https://$server_name$request_uri;
}

server {
    listen 443 ssl http2; 
    listen [::]:443 ssl http2;
    server_name example.com www.example.com

    ssl_certificate /etc/ssl/certs/example.com/fullchain.pem;
    ssl_certificate_key /etc/ssl/certs/example.com/privkey.pem;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&#34;http-compression&#34;&gt;HTTP compression&lt;/h3&gt;
&lt;p&gt;HTTP 压缩可能使服务器遭受 BREACH 攻击，启用与否是对流量/带宽和安全性的取舍。&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;gzip off;
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&#34;hsts&#34;&gt;HSTS&lt;/h3&gt;
&lt;p&gt;HSTS 将在浏览器再次访问网站时强制使用 HTTPS 连接，这有助于预防中间人攻击。Internel.nl 认为 HSTS 策略缓存时间为&lt;em&gt;&lt;strong&gt;至少&lt;/strong&gt;&lt;/em&gt;一年时，策略足够安全。&lt;/p&gt;
&lt;p&gt;在 nginx 配置中添加以下语句&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;add_header Strict-Transport-Security &amp;quot;max-age=31536000&amp;quot; always;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;参照 internet.nl 的提示，只有当确认&lt;strong&gt;全部&lt;/strong&gt;子域名都被 HTTPS 覆盖到时，才应该添加 &lt;code&gt;includeSubDomains&lt;/code&gt; 语句，即&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;add_header Strict-Transport-Security &amp;quot;max-age=31536000; includeSubDomains&amp;quot; always;
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&#34;tls-version&#34;&gt;TLS version&lt;/h3&gt;
&lt;p&gt;TLS 版本安全性表格：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;优秀：TLS 1.3&lt;/li&gt;
&lt;li&gt;足够：TLS 1.2&lt;/li&gt;
&lt;li&gt;换代：TLS 1.1,1.0&lt;/li&gt;
&lt;li&gt;不足：SSL 3.0,2.0,1.0&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;在 server 块中加入以下内容：&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;ssl_protocols TLSv1.2 TLSv1.3;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;同时，如果使用了 Cloudflare CDN，我还需要在 Cloudflare 的面板中调整以下设置&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;images/cloudflare_tls_version.webp&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;h3 id=&#34;ciphers-algorithm-selections&#34;&gt;Ciphers (Algorithm selections)&lt;/h3&gt;
&lt;p&gt;很多算法已经到了 phase-out 阶段，可以在 nginx 配置文件中禁用。&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305;
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&#34;cipher-order&#34;&gt;Cipher order&lt;/h3&gt;
&lt;p&gt;在 internet.nl 的列表中列出了 good, sufficient 和 phase out 列表。服务器应该：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;若只支持 good 列表中的内容，则不参加此测试&lt;/li&gt;
&lt;li&gt;若同时支持 good 列表外的内容，应优先使用 good cipher&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&#34;ssl_prefer_server_ciphers&#34;&gt;ssl_prefer_server_ciphers&lt;/h4&gt;
&lt;p&gt;Nginx 推荐此项设置为 on，而 mozilla 推荐设置为 off。&lt;/p&gt;
&lt;p&gt;相关讨论可参考此处：&lt;a href=&#34;https://serverfault.com/questions/997614/setting-ssl-prefer-server-ciphers-directive-in-nginx-config&#34;&gt;https://serverfault.com/questions/997614/setting-ssl-prefer-server-ciphers-directive-in-nginx-config&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;我将其设置为了 off。&lt;/p&gt;
&lt;h3 id=&#34;key-exchange-parameters&#34;&gt;Key exchange parameters&lt;/h3&gt;
&lt;p&gt;&lt;a href=&#34;https://en.wikipedia.org/wiki/Diffie%E2%80%93Hellman_key_exchange&#34;&gt;Diffie-Hellman key exchange&lt;/a&gt; 是一种安全协议。服务端应支持足够安全的交换参数。&lt;/p&gt;
&lt;p&gt;Github 上的 &lt;a href=&#34;https://github.com/internetstandards/dhe_groups&#34;&gt;internetstandards/dhe_roups&lt;/a&gt; 仓库给出了足够安全的 ffdhe4096 参数。下载后在 nginx 中指定：
ssl_dhparam /etc/nginx/ffdhe4096.pem;&lt;/p&gt;
&lt;h3 id=&#34;ocsp-stapling&#34;&gt;OCSP stapling&lt;/h3&gt;
&lt;p&gt;OCSP stapling 将本应客户端发起的 OCSP 请求交给服务端发起，服务端将 OCSP 结果随证书一同发送给客户端，跳过了客户自己请求 OCSP 的过程，提高了效率。&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;ssl_stapling on;
ssl_stapling_verify on;
ssl_trusted_certificate /path/to/fullchain;
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&#34;certificate-相关&#34;&gt;Certificate 相关&lt;/h3&gt;
&lt;p&gt;证书相关，请求了证书并启用即可。&lt;/p&gt;
&lt;h3 id=&#34;dane&#34;&gt;DANE&lt;/h3&gt;
&lt;p&gt;此处不强求，故不启用。若有兴趣，方法于邮件处的 DANE 设置相同。&lt;/p&gt;
&lt;h2 id=&#34;security-options&#34;&gt;Security options&lt;/h2&gt;
&lt;h3 id=&#34;x-frame-options&#34;&gt;X-Frame-Options&lt;/h3&gt;
&lt;p&gt;X-Frame-Options 用于避免 &lt;a href=&#34;https://owasp.org/www-community/attacks/Clickjacking&#34;&gt;clickjacking 攻击&lt;/a&gt;。&lt;/p&gt;
&lt;p&gt;相关选项语法为：&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;add_header X-Frame-Options &amp;quot;OPTION&amp;quot;;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;其中 OPTION 可选择 SAMEORIGIN, DENY 和 ALLOW-FROM URI。前两项被认为足够安全。&lt;br&gt;
此处设置为&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;add_header X-Frame-Options &amp;quot;SAMEORIGIN&amp;quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&#34;x-content-type-options&#34;&gt;X-Content-Type-Options&lt;/h3&gt;
&lt;p&gt;X-Content-Type-Options 用于指明 MIME 类型，同时避免 &lt;a href=&#34;https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types#mime_sniffing&#34;&gt;MIME 类型嗅探&lt;/a&gt;。&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;add_header X-Content-Type-Options nosniff;
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&#34;content-security-policy&#34;&gt;Content-Security-Policy&lt;/h3&gt;
&lt;p&gt;按照 internet.nl 推荐，应至少有以下内容：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;default-src: none/self/https:(不推荐)&lt;/li&gt;
&lt;li&gt;frame-src: none/self/url&lt;/li&gt;
&lt;li&gt;frame-ancestors: hone/self/url&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;其他项目可在 internet.nl 的测试项中查看细节，或在 &lt;a href=&#34;https://content-security-policy.com&#34;&gt;content-security-policy.com&lt;/a&gt; 查看规范。&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;add_header Content-Security-Policy &amp;quot;default-src &#39;self&#39;;frame-src &#39;self&#39;;frame-ancestors &#39;self&#39;;&amp;quot; always;
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&#34;referrer-policy-existence&#34;&gt;Referrer-Policy existence&lt;/h3&gt;
&lt;pre&gt;&lt;code&gt;add_header Referrer-Policy &#39;strict-origin-when-cross-origin&#39;;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;推荐值：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;no-referrer/same-origin 如果不发送敏感信息到第三方。&lt;/li&gt;
&lt;li&gt;strict-origin/strict-origin-when-cross-origin 如果只通过 HTTPS 发送敏感信息到第三方。&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;securitytxt&#34;&gt;Security.txt&lt;/h3&gt;
&lt;p&gt;可以通过 &lt;a href=&#34;https://securitytxt.org/&#34;&gt;securitytxt.org&lt;/a&gt; 生成 security.txt，并放置在 domain.com/security.txt 和/或 domain.com/.well-known/security.txt&lt;/p&gt;
&lt;h2 id=&#34;route-authorisation-rpki&#34;&gt;Route authorisation (RPKI)&lt;/h2&gt;
&lt;p&gt;BGP 相关。&lt;/p&gt;
&lt;h2 id=&#34;nginx配置总和&#34;&gt;Nginx配置总和&lt;/h2&gt;
&lt;p&gt;不推荐直接抄，放这里只是为了方便我自己看。&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;server {
    listen 80;
    listen [::]:80;
    server_name example.com;
    return 301 https://$server_name$request_uri;
}

server {
    listen 443 ssl http2; 
    listen [::]:443 ssl http2;
    server_name example.com;
    root /var/www/example.com;

    ssl_certificate /etc/ssl/certs/example.com/fullchain.pem;
    ssl_certificate_key /etc/ssl/certs/example.com/privkey.pem;
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305;
    ssl_prefer_server_ciphers off;
    ssl_stapling on;
    ssl_stapling_verify on;
    ssl_trusted_certificate /etc/ssl/certs/example.com/fullchain.pem;
    ssl_dhparam /etc/nginx/ffdhe4096.pem;
    add_header Strict-Transport-Security &amp;quot;max-age=31536000&amp;quot; always;
    add_header X-Frame-Options &amp;quot;SAMEORIGIN&amp;quot;;
    add_header X-Content-Type-Options nosniff;
    add_header Referrer-Policy &#39;strict-origin-when-cross-origin&#39;;

    index index.html index.xml;

    location / {
            index index.html;
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h1 id=&#34;邮局测试&#34;&gt;邮局测试&lt;/h1&gt;
&lt;p&gt;此处使用 &lt;a href=&#34;https://mailcow.email&#34;&gt;mailcow&lt;/a&gt; 为基础进行设置。&lt;/p&gt;
&lt;h2 id=&#34;modern-address-ipv6--signed-domain-names-dnssec&#34;&gt;Modern address (IPv6) &amp;amp; Signed domain names (DNSSEC)&lt;/h2&gt;
&lt;p&gt;与上文相同。&lt;/p&gt;
&lt;h2 id=&#34;authenticity-marks-against-phishing-dmarc-dkim-and-spf&#34;&gt;Authenticity marks against phishing (DMARC, DKIM and SPF)&lt;/h2&gt;
&lt;h3 id=&#34;dmarc&#34;&gt;DMARC&lt;/h3&gt;
&lt;p&gt;DMARC 策略用于指明当一封邮件不能被 DKIM 和 SPF 认证时的处理方式。&lt;/p&gt;
&lt;p&gt;参考： &lt;a href=&#34;https://dmarc.org/&#34;&gt;dmarc.org&lt;/a&gt;。&lt;/p&gt;
&lt;h3 id=&#34;dkim&#34;&gt;DKIM&lt;/h3&gt;
&lt;p&gt;不同平台配置方法不同，得到数据后添加至 DNS 记录即可。&lt;/p&gt;
&lt;h3 id=&#34;spf&#34;&gt;SPF&lt;/h3&gt;
&lt;p&gt;SPF 用于验证邮件发送人的真实性。参考 Cloudflare 就此的文章：&lt;a href=&#34;https://www.cloudflare.com/zh-cn/learning/dns/dns-records/dns-spf-record/&#34;&gt;什么是 DNS SPF 记录？&lt;/a&gt;。&lt;/p&gt;
&lt;h2 id=&#34;secure-mail-server-connection-starttls-and-dane&#34;&gt;Secure mail server connection (STARTTLS and DANE)&lt;/h2&gt;
&lt;h3 id=&#34;tls&#34;&gt;TLS&lt;/h3&gt;
&lt;p&gt;简而言之就是对 postfix 进行的设置。&lt;code&gt;/opt/mailcow-dockerized/data/conf/postfix/extra.cf&lt;/code&gt; 内容如下&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;tls_ssl_options = NO_COMPRESSION, 0x40000000
tls_preempt_cipherlist = yes
smtpd_tls_protocols = !SSLv2, !SSLv3, !TLSv1, !TLSv1.1
smtpd_tls_mandatory_protocols = !SSLv2, !SSLv3, !TLSv1, !TLSv1.1
smtpd_tls_ciphers = high
smtpd_tls_mandatory_ciphers = high
smtpd_tls_exclude_ciphers = EXP, LOW, MEDIUM, aNULL, eNULL, SRP, PSK, kDH, DH, kRSA, DHE, DSS, RC4, DES, IDEA, SEED, ARIA, CAMELLIA, AESCCM8, 3DES, ECDHE-ECDSA-AES256-SHA&amp;gt;
smtpd_tls_eecdh_grade = ultra
smtpd_tls_dh1024_param_file = /opt/mailcow-dockerized/data/assets/ssl/ffdhe4096.pem
smtp_host_lookup = dns
smtp_tls_note_starttls_offer = yes
smtp_tls_protocols = !SSLv2, !SSLv3, !TLSv1, !TLSv1.1
smtp_tls_mandatory_protocols = !SSLv2, !SSLv3, !TLSv1, !TLSv1.1
smtp_tls_ciphers = high
smtp_tls_mandatory_ciphers = high
smtp_tls_exclude_ciphers = EXP, LOW, MEDIUM, aNULL, eNULL, SRP, PSK, kDH, DH, kRSA, DHE, DSS, RC4, DES, IDEA, SEED, ARIA, CAMELLIA, AESCCM8, 3DES, ECDHE-ECDSA-AES256-SHA3&amp;gt;
lmtp_tls_note_starttls_offer = yes
lmtp_tls_protocols = !SSLv2, !SSLv3, !TLSv1, !TLSv1.1
lmtp_tls_mandatory_protocols = !SSLv2, !SSLv3, !TLSv1, !TLSv1.1
lmtp_tls_ciphers = high
lmtp_tls_mandatory_ciphers = high
lmtp_tls_exclude_ciphers = EXP, LOW, MEDIUM, aNULL, eNULL, SRP, PSK, kDH, DH, kRSA, DHE, DSS, RC4, DES, IDEA, SEED, ARIA, CAMELLIA, AESCCM8, 3DES, ECDHE-ECDSA-AES256-SHA3&amp;gt;
lmtp_tls_loglevel = 1
lmtp_tls_session_cache_database = btree:/var/lib/postfix/lmtp_tls_session_cache
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;对每一项具体内容感兴趣可自行研究。&lt;/p&gt;
&lt;h3 id=&#34;certificate&#34;&gt;Certificate&lt;/h3&gt;
&lt;p&gt;证书相关，mailcow 帮我生成了自签名证书，此处自动解决。&lt;/p&gt;
&lt;h3 id=&#34;dane-1&#34;&gt;DANE&lt;/h3&gt;
&lt;p&gt;提示：DNSSEC 为 DANE 设置的前提。&lt;/p&gt;
&lt;p&gt;DANE 用于尽可能减少邮件传输时可能的内容窥探。可参考 &lt;a href=&#34;https://www.sidn.nl/en/news-and-blogs/hands-on-implementing-dane-in-postfix&#34;&gt;Hands-on: implementing DANE in Postfix&lt;/a&gt;。&lt;/p&gt;
&lt;p&gt;启用过程请参考 &lt;a href=&#34;https://github.com/internetstandards/toolbox-wiki/blob/main/DANE-for-SMTP-how-to.md&#34;&gt;DANE for SMTP how-to&lt;/a&gt;。&lt;/p&gt;
&lt;p&gt;懒人版：&lt;/p&gt;
&lt;p&gt;需两个数值，自签证书的 DANE SHA-256 hash，和 root certificate 的 DANE SHA-256 hash。&lt;/p&gt;
&lt;p&gt;对于 mailcow，自签证书位于 &lt;code&gt;/mailcow-folder/data/assets/ssl/cert.pem&lt;/code&gt;；&lt;br&gt;
根因使用 Let&amp;rsquo;s Encrypt，根证书为 ISRG Root X1，位于 &lt;code&gt;/etc/ssl/certs/ISRG_Root_X1.pem&lt;/code&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# openssl x509 -in /opt/mailcow-dockerized/data/assets/ssl/cert.pem -noout -pubkey | openssl pkey -pubin -outform DER | openssl sha256
(stdin)= example_output_1
# openssl x509 -in /etc/ssl/certs/ISRG_Root_X1.pem -noout -pubkey | openssl pkey -pubin -outform DER | openssl sha256
(stdin)= example_output_2
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;随后需要在 DNS 中声明这两项结果&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;_25._tcp.mail.example.com. IN TLSA 3 1 1 example_output_1
_25._tcp.mail.example.com. IN TLSA 2 1 1 example_output_2
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;数值的具体意义可查看上述参考内容。&lt;/p&gt;
&lt;h2 id=&#34;route-authorisation-rpki-1&#34;&gt;Route authorisation (RPKI)&lt;/h2&gt;
&lt;p&gt;同上，BGP 大佬受我一拜。&lt;/p&gt;
&lt;h1 id=&#34;网络连接测试&#34;&gt;网络连接测试&lt;/h1&gt;
&lt;p&gt;基本就是测试本地是否能连接 IPv6 网络。但从国内连接的效果基本没有意义，如果真的在意不如使用 &lt;a href=&#34;https://testipv6.cn/&#34;&gt;testipv6.cn&lt;/a&gt;。&lt;/p&gt;
&lt;p&gt;这么多内容调整完了。问题是：有多少会产生实际影响？&lt;/p&gt;
&lt;p&gt;&lt;del&gt;当然在于玩的开心&lt;/del&gt;&lt;/p&gt;
- https://eki.moe/posts/full-score-on-internet-nl/ - Eki</description>
        </item>
    
    
    
        <item>
        <title>Why I&#39;m Transitioning to Static Websites</title>
        <link>https://eki.moe/posts/why-im-transitioning-to-static-websites/</link>
        <pubDate>Sun, 12 Feb 2023 22:24:17 +0800</pubDate>
        
        <guid>https://eki.moe/posts/why-im-transitioning-to-static-websites/</guid>
        <description>Eki&#39;s Home https://eki.moe/posts/why-im-transitioning-to-static-websites/ -&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;Note: This does not serve as a guide. It is only a reminder in case I forget this again.
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;What&amp;rsquo;s a static website? What are advantages of static websites? Please check &lt;a href=&#34;https://www.cloudflare.com/learning/performance/static-site-generator/&#34;&gt;this blog from Cloudflare&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;m not in a position to say how one option is correct and the other option is not. This is only a log for myself.&lt;/p&gt;
&lt;h1 id=&#34;initial-choice-wordpress&#34;&gt;Initial choice: WordPress&lt;/h1&gt;
&lt;p&gt;The reasons for which I chose to use WordPress in the beginning is simple:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Easy to follow tutorials&lt;/li&gt;
&lt;li&gt;Beginner-friendly editor&lt;/li&gt;
&lt;li&gt;Not too bad-looking pages&lt;/li&gt;
&lt;li&gt;Abundant choice of themes/plugins&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;But after using WordPress for a while, I also realized some of its weaknesses:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Performance is much worse than static pages&lt;/li&gt;
&lt;li&gt;CVEs appear often&lt;/li&gt;
&lt;li&gt;I don&amp;rsquo;t need most of the functions a dynamic site provides&lt;/li&gt;
&lt;li&gt;The editor can be hard to use sometimes&lt;/li&gt;
&lt;/ul&gt;
&lt;h1 id=&#34;turning-to-hugo&#34;&gt;Turning to Hugo&lt;/h1&gt;
&lt;p&gt;There are a lot of choices for static site generators. I chose Hugo for the following options:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Good performance&lt;/li&gt;
&lt;li&gt;Great plugins/themes/documentation&lt;/li&gt;
&lt;li&gt;The fact that it uses Markdown for editing&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;At the same time, I use VSCode and Git for writing and source management, and overall have a wonderful experience.&lt;/p&gt;
&lt;p&gt;Although initially I did not have much interest for solutions that require me to use the command line and external editors, after about half an hour of reading the documentation, it turned out to be not too difficult.&lt;/p&gt;
&lt;p&gt;I also plan to remake the DN42 pages and other websites to be static where possible, to have a better editing experience.&lt;/p&gt;
&lt;h1 id=&#34;common-knowledge-and-commands-for-hugo&#34;&gt;Common knowledge and commands for Hugo&lt;/h1&gt;
&lt;p&gt;Source of truth for this part comes from the &lt;a href=&#34;https://gohugo.io/getting-started/quick-start/&#34;&gt;Hugo Docs&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;quickstart&#34;&gt;Quickstart&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;hugo new project quickstart
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This command asks hugo to create a folder called quickstart, and generates a project skeleton within that folder. The project skeleton looks like this.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;my-project/
├── archetypes/
│   └── default.md
├── assets/
├── content/
├── data/
├── i18n/
├── layouts/
├── static/
├── themes/
└── hugo.toml         &amp;lt;-- project configuration
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Depending on your site&amp;rsquo;s requirements, you might not need some of those folders. After the site is built, the folders &lt;code&gt;public/&lt;/code&gt; and &lt;code&gt;resources/&lt;/code&gt; are also creates as the built files.&lt;/p&gt;
&lt;p&gt;Each of the folders contribute to the website&amp;rsquo;s content or behaviour. For what each folder is used, refer to this &lt;a href=&#34;https://gohugo.io/getting-started/directory-structure/&#34;&gt;docs&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;page-bundles&#34;&gt;Page bundles&lt;/h2&gt;
&lt;p&gt;Hugo uses a folder structure that bundles images and other resources into &lt;a href=&#34;https://gohugo.io/content-management/organization/&#34;&gt;&lt;strong&gt;Page bundles&lt;/strong&gt;&lt;/a&gt;. Page bundles are content folders that holds &lt;code&gt;index.md&lt;/code&gt; or &lt;code&gt;_index.md&lt;/code&gt; at their foot. The resources within page bundles are called page resources, and they are only available to the page with which they are bundled.&lt;/p&gt;
&lt;p&gt;Content should be organized in a manner that reflects the rendered website. For example, the following structure should work without additional configuration.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;.
└── content
    └── about
    |   └── index.md  // &amp;lt;- https://example.org/about/
    ├── posts
    |   ├── firstpost.md   // &amp;lt;- https://example.org/posts/firstpost/
    |   ├── happy
    |   |   └── ness.md  // &amp;lt;- https://example.org/posts/happy/ness/
    |   └── secondpost.md  // &amp;lt;- https://example.org/posts/secondpost/
    └── quote
        ├── first.md       // &amp;lt;- https://example.org/quote/first/
        └── second.md      // &amp;lt;- https://example.org/quote/second/
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;A more detailed example with page resources could look like this.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;content
└── post
    ├── first-post
    │   ├── images
    │   │   ├── a.jpg
    │   │   ├── b.jpg
    │   │   └── c.jpg
    │   ├── index.md (root of page bundle)
    │   ├── latest.html
    │   ├── manual.json
    │   ├── notice.md
    │   ├── office.mp3
    │   ├── pocket.mp4
    │   ├── rating.pdf
    │   └── safety.txt
    └── second-post
        └── index.md (root of page bundle)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Note that the page resources of page &lt;code&gt;first-post&lt;/code&gt; are not visible to page &lt;code&gt;second-post&lt;/code&gt;.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;content/
├── blog/
│   ├── hugo-is-cool/
│   │   ├── images/
│   │   │   ├── funnier-cat.jpg
│   │   │   └── funny-cat.jpg
│   │   ├── cats-info.md
│   │   └── index.md
│   ├── posts/
│   │   ├── post1.md
│   │   └── post2.md
│   ├── 1-landscape.jpg
│   ├── 2-sunset.jpg
│   ├── _index.md
│   ├── content-1.md
│   └── content-2.md
├── 1-logo.png
└── _index.md
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This example shows nested page bundles, namely &lt;code&gt;content/_index.md&lt;/code&gt;, &lt;code&gt;content/blog/_index.md&lt;/code&gt;, and &lt;code&gt;content/blog/hugo-is-cool/index.md&lt;/code&gt;. Note that the home page cannot contain other content pages, although other files such as images are allowed.&lt;/p&gt;
&lt;p&gt;Hugo only makes sure each content is rendered to the target paths, however the navigation to the contents at each path are up to the website&amp;rsquo;s author to implement, as well as the theme to decide on its apperance. For example, a blog based theme could list all of its posts at the home page, while a company facing theme probably won&amp;rsquo;t make each product page visible directly on the root page. Therefore it is important to refer to the theme&amp;rsquo;s manual and make changes accordingly.&lt;/p&gt;
&lt;h2 id=&#34;initializing-git&#34;&gt;Initializing Git&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;cd quickstart
git init
git submodule add https://github.com/gohugo-ananke/ananke themes/ananke
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Of course, you would use git for source control on your content. Here we can add a theme as a Git submodule, to the path &lt;code&gt;themes/ananke&lt;/code&gt;. More about this will be featured on the part, &amp;ldquo;How to use Git submodules&amp;rdquo;.&lt;/p&gt;
&lt;h2 id=&#34;editing-and-viewing-content&#34;&gt;Editing and viewing content&lt;/h2&gt;
&lt;p&gt;To add a new page to the project&amp;rsquo;s content, you would use the following command.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;hugo new content content/posts/my-first-post.md
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Hugo will create the file to the path do designated, from the &lt;a href=&#34;https://gohugo.io/content-management/archetypes/&#34;&gt;archetype&lt;/a&gt; you chose, which is in this instance &lt;code&gt;posts&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;By default the page&amp;rsquo;s front matter will set the value of &lt;code&gt;draft&lt;/code&gt; to &lt;code&gt;true&lt;/code&gt;, which will not be published by default.&lt;/p&gt;
&lt;p&gt;To start Hugo&amp;rsquo;s development server, you would run the following command.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;hugo server
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;However, to include draft content, you would run the following command.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;hugo server --buildDrafts
hugo server -D
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;publishing-the-project&#34;&gt;Publishing the project&lt;/h2&gt;
&lt;p&gt;When you choose to publish your project, Hugo renders all build artifacts to the &lt;code&gt;public&lt;/code&gt; directory in the root of your project. This includes the HTML files for every site, along with assets such as images, CSS, and JavaScript. The command to do so is very simple.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;hugo
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;It might be important to remember that Hugo does not clear the public directory before building your project. Existing files are overwritten, but not deleted. This behavior is intentional to prevent the inadvertent removal of files that you may have added to the public directory after the build. Depending on your needs, you may wish to manually clear the contents of the public directory before every build.&lt;/p&gt;
&lt;p&gt;Same goes with the resources folder, which is said to &lt;code&gt;By default this cache directory includes CSS and images. Hugo recreates this directory and its content as needed&lt;/code&gt;. Therefore in some cases it might be benefitial to remove that folder by hand.&lt;/p&gt;
&lt;h1 id=&#34;how-to-use-git-submodules&#34;&gt;How to use Git submodules&lt;/h1&gt;
&lt;p&gt;Source of truth to this section should be on the &lt;a href=&#34;https://git-scm.com/book/en/v2/Git-Tools-Submodules&#34;&gt;Git handbook&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;what-are-submodules&#34;&gt;What are submodules?&lt;/h2&gt;
&lt;p&gt;Sometimes you need to refer to another repository from your own. However, if you simple refer to it by code by pointing to another directory outside of the current repository, you lose the advantages of using Git for version control on that, making updating it when newer upstream sources are available extremely difficult. Therefore, normally it is preferable to hold the code of that repository, within the same Git version controlled environment.&lt;/p&gt;
&lt;p&gt;There are a few ways to do that. For example, some programming languages might have builtin package managers that allow importing packages. However, as is the case with Hugo themes, sometimes we do need the raw code at our hands. There is also the problem with simply including the library, which is that it is difficult to customize the library in anyway, or to make sure each time that the library is installed on a target machine.&lt;/p&gt;
&lt;p&gt;Git addresses this problem with submodules, which allows the user to keep another Git repository as a subdirectory of a Git repository, while also keeping the commits separate.&lt;/p&gt;
&lt;p&gt;Other advantages of using Git submodules also include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Code safety when an external component is changing too fast, or when upcoming changes will break your project.&lt;/li&gt;
&lt;li&gt;When an external component doesn&amp;rsquo;t change too often, and you want to track it as a dependency.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;hugo-modules&#34;&gt;Hugo modules&lt;/h2&gt;
&lt;p&gt;Hugo allows the use of external resources as modules through its builtin management feature.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;A module is a packaged combination of components which may contain archetypes, assets, content, data, templates, translation tables, and static files. A module may be a theme, a complete project, or a smaller collection of one or more components.
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Source: &lt;a href=&#34;https://gohugo.io/hugo-modules/use-modules/&#34;&gt;Hugo docs&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;To put it simply, Hugo provides a way to manage external resources used by Hugo through the &lt;code&gt;hugo mod&lt;/code&gt; command, which allows inclusion of external files through a subdirectory in the project folder, a external path on the system&amp;rsquo;s mountpoint, or even just a link to a Git repository. Importing, updating, caching, removing and other actions are all controlled by Hugo.&lt;/p&gt;
&lt;p&gt;I do believe that this is a great tool to get started when other resources are necessary. However, since that this is a function confined to Hugo, the option to use the submodule function of Git, which could also be used in other projects unrelated to Hugo, could be a better option.&lt;/p&gt;
&lt;h2 id=&#34;quirks-of-git-submodules&#34;&gt;Quirks of Git submodules&lt;/h2&gt;
&lt;p&gt;Although submodules are represented by just another directory on your filesystem, Git sees it as a submodule and doesn&amp;rsquo;t track its contents when you&amp;rsquo;re not in that directory. Instead, it sees the directory as a whole, as a certain commit.&lt;/p&gt;
&lt;p&gt;Therefore, when you wish to update contents of the submodule, it might not be as straightforward as editing a simple file, as there is a flow that needs to be followed.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Go to the submodule&amp;rsquo;s directory&lt;/li&gt;
&lt;li&gt;Edit the submodule&lt;/li&gt;
&lt;li&gt;Commit changes to the submodule&lt;/li&gt;
&lt;li&gt;Push the submodule&amp;rsquo;s changes to remote&lt;/li&gt;
&lt;li&gt;Now the parent repository sees a new version to the submodule&lt;/li&gt;
&lt;li&gt;Commit changes to the parent repository, and pushto remote&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It is important that the editor does not forget to push changes to the submodule to remote, before the parent repository is pushed. This is because Git only tracks the submodule to a commit, and when the parent repository is pushed without the new version of the submodule being available, other users trying to use the repository will fail to do so.&lt;/p&gt;
&lt;h2 id=&#34;common-commands-to-use-git-submodules&#34;&gt;Common commands to use Git submodules&lt;/h2&gt;
&lt;p&gt;Again, the source of truth is the Git handbook, linked above. This part will only cover some common commands that I will probably use often.&lt;/p&gt;
&lt;h3 id=&#34;adding-a-submodule&#34;&gt;Adding a submodule&lt;/h3&gt;
&lt;p&gt;To start to use a submodule, you would use the following command.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;git submodule add https://link-to-repo
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This will result in the repository being cloned, and the &lt;code&gt;.gitmodules&lt;/code&gt; file created.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;[submodule &amp;#34;submodule-a&amp;#34;]
    path = submodule-a
    url = https://link-to-repo
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Note that if you&amp;rsquo;re using code from another developer, it might be a good idea to fork that repository first. This is because while using submodules, you probably with to edit the files to a certain point, however using the original developer&amp;rsquo;s repository directly does not allow your changes to be pushed to remote, at least the changes that only apply to yourself.&lt;/p&gt;
&lt;h3 id=&#34;cloning-a-repository-with-submodules&#34;&gt;Cloning a repository with submodules&lt;/h3&gt;
&lt;p&gt;When cloning a project with a submodule in it, by default the directories that contain the submodules will be created, but not the contents inside those directories. To also clones the submodules, you need to run these commands.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;git submodule init # inits local configuration
git submodule update # fetches data from remote
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Another way to do this is to pass &lt;code&gt;--recursive-submodules&lt;/code&gt; to the &lt;code&gt;git clone&lt;/code&gt; command. This has the advantage of being able to recursively fetch data if any of the submodules in your repository has submodules of themselves.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;git clone --recursive-submodules https://link-to-repo
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Finally, if you have already cloned the repository but forgot to use &lt;code&gt;--recursive-submodules&lt;/code&gt;, you can combine &lt;code&gt;git submodule init&lt;/code&gt; and &lt;code&gt;git submodule update&lt;/code&gt; with the following one liner.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;git submodule update --init
git submodule update --init --recursive # if submodules are recursive
&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&#34;updating-upstream-changes-from-submodule-remote&#34;&gt;Updating upstream changes from submodule remote&lt;/h3&gt;
&lt;p&gt;One common way to use submodules is to consume its content, but not make any modifications on your own. Thus, it might be necessary to update the submodule from its upstream from time to time.&lt;/p&gt;
&lt;p&gt;To check for new work in a submodule, go into its directory and run these commands.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;git fetch
git merge origin/master
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;If you commit at this point then you will lock the submodule into having the new code when other people update.&lt;/p&gt;
&lt;p&gt;An easier way to do this exists, if you do not wish to fetch and merge in the subdirectory by hand.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;git submodule update --remote
git submodule update --remote submodule_name # when only updating one submodule
&lt;/code&gt;&lt;/pre&gt;- https://eki.moe/posts/why-im-transitioning-to-static-websites/ - Eki</description>
        </item>
    
    
    
        <item>
        <title>Nginx 禁用源站 IP 对网站的访问</title>
        <link>https://eki.moe/posts/block-direct-ip-access-nginx/</link>
        <pubDate>Tue, 27 Dec 2022 23:26:06 +0800</pubDate>
        
        <guid>https://eki.moe/posts/block-direct-ip-access-nginx/</guid>
        <description>Eki&#39;s Home https://eki.moe/posts/block-direct-ip-access-nginx/ -&lt;p&gt;对于这个问题有三种解决方法：&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;对于Nginx 1.19.4与更新，使用ssl_reject_handshake；&lt;/li&gt;
&lt;li&gt;对于较老版本，使用自签SSL证书；&lt;/li&gt;
&lt;li&gt;在server块中用if语句判断。&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;三种方法对 HTTP, HTTPS 都适用（为什么不呢）。&lt;/p&gt;
&lt;h1 id=&#34;update-20230919&#34;&gt;Update 2023/09/19&lt;/h1&gt;
&lt;p&gt;Configuration snippets as well as automatic installer script available on &lt;a href=&#34;https://github.com/nagaeki/nginx-config&#34;&gt;my Github&lt;/a&gt;&lt;/p&gt;
&lt;h1 id=&#34;ssl_reject_handshake-方法&#34;&gt;ssl_reject_handshake 方法&lt;/h1&gt;
&lt;h2 id=&#34;安装可用的nginx版本&#34;&gt;安装可用的Nginx版本&lt;/h2&gt;
&lt;p&gt;首先需要确定安装的是Nginx 1.19.4及以上版本，可使用 `nginx -v 命令查看。&lt;/p&gt;
&lt;p&gt;处理此问题时Debian Stable仍在发行1.18.0版本，因此使用Nginx官网源安装新版。参考 &lt;a href=&#34;https://www.nginx.com/resources/wiki/start/topics/tutorials/install/&#34;&gt;Nginx官网安装步骤&lt;/a&gt;。&lt;/p&gt;
&lt;p&gt;获得 nginx 签名密钥并添加信任&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;wget https://nginx.org/keys/nginx_signing.key 
apt-key add nginx_signing.key
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;添加 nginx 源&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;gt;/etc/apt/sources.list.d/nginx.conf
deb https://nginx.org/packages/mainline/debian/ bullseye nginx
deb-src https://nginx.org/packages/mainline/debian bullseye nginx
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;如果需要卸载原有的 nginx 安装&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;apt purge nginx nginx-common
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;随后安装并重启 nginx 服务即可。&lt;/p&gt;
&lt;h2 id=&#34;启用default配置&#34;&gt;启用default配置&lt;/h2&gt;
&lt;p&gt;在 nginx 的配置文件夹中写一个default文件，我选择位于 &lt;code&gt;/etc/nginx/conf.d/default.conf&lt;/code&gt; ，根据习惯即可。&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;server {
    listen 80 default_server;
    listen [::]:80 default_server;

    server_name _;
    return 444;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;解释：server_name _ 针对一切没有在本机匹配的域名，444响应让Nginx直接不响应内容。&lt;/p&gt;
&lt;p&gt;记得启用此配置并刷新Nginx。&lt;/p&gt;
&lt;h2 id=&#34;针对https&#34;&gt;针对HTTPS&lt;/h2&gt;
&lt;p&gt;以上内容只针对HTTP请求有效（也只监听了80端口）。为了对HTTPS请求也生效，增加文件至以下内容：&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;server {
    listen 80 default_server;
    listen [::]:80 default_server;

    listen 443 default_server;
    listen [::]:443 default_server;
    ssl_reject_handshake on;

    server_name _;
    return 444;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;这样处理后，HTTPS请求到源站后不会露出证书。 &lt;strong&gt;这是我选择的方法。&lt;/strong&gt; 效果如图，不同浏览器报错不同。&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;images/ssl_error.webp&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;h1 id=&#34;自签ssl证书方法&#34;&gt;自签SSL证书方法&lt;/h1&gt;
&lt;p&gt;如果你在较老版本的Nginx上使用了上面的方法，你很有可能会遇到以下报错：&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; nginx: [emerg] no &amp;quot;ssl_certificate&amp;quot; is defined for the &amp;quot;listen ... ssl&amp;quot; directive
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;如果你又不想更新Nginx，则可以使用自签SSL证书方法。&lt;/p&gt;
&lt;h2 id=&#34;获得空白ssl证书&#34;&gt;获得空白SSL证书&lt;/h2&gt;
&lt;p&gt;可以使用以下命令获得 &lt;code&gt;ssl_certificate&lt;/code&gt; 和 &lt;code&gt;ssl_certificate_key&lt;/code&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout default.key -out default.crt -subj &#39;/CN=&#39;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;这样会直接把 default.key 和 default.crt 输出在当前目录下。&lt;/p&gt;
&lt;h2 id=&#34;更新nginx配置&#34;&gt;更新Nginx配置&lt;/h2&gt;
&lt;p&gt;随后可以把 Nginx 的 default 配置改为如下：&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;server {
    listen 80 default_server;
    listen [::]:80 default_server;
    
    listen 443 default_server;
    listen [::]:443 default_server;

    ssl_certificate /etc/nginx/ssl/default.crt;
    ssl_certificate_key /etc/nginx/ssl/default.key;

    server_name _;
    return 444;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;重载配置后再次通过IP访问应该不会得到结果。&lt;/p&gt;
&lt;h1 id=&#34;if语句判断方法&#34;&gt;IF语句判断方法&lt;/h1&gt;
&lt;p&gt;对于某个域名的配置，写入以下内容：&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;server {
    listen 443 default_server;
    listen [::]:443 default_server;

    if ($host != eki.moe) {
            return 444;
    }

    server_name eki.moe;

...剩余内容
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;判断语句可以搭配正则表达式。但这种方法缺点太多了：&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;工作量大；&lt;/li&gt;
&lt;li&gt;容易出错；&lt;/li&gt;
&lt;li&gt;难以扩展；&lt;/li&gt;
&lt;li&gt;上面两种方法好太多了。&lt;/li&gt;
&lt;/ol&gt;
&lt;h1 id=&#34;本文参考&#34;&gt;本文参考&lt;/h1&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&#34;https://stackoverflow.com/questions/29104943/how-to-disable-direct-access-to-a-web-site-by-ip-address&#34;&gt;https://stackoverflow.com/questions/29104943/how-to-disable-direct-access-to-a-web-site-by-ip-address&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://erikpoehler.com/2022/08/02/how-to-block-direct-ip-access-to-your-nginx-web-server/&#34;&gt;https://erikpoehler.com/2022/08/02/how-to-block-direct-ip-access-to-your-nginx-web-server/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.codedodle.com/disable-direct-ip-access-nginx.html&#34;&gt;https://www.codedodle.com/disable-direct-ip-access-nginx.html&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.nginx.com/resources/wiki/start/topics/tutorials/install/&#34;&gt;https://www.nginx.com/resources/wiki/start/topics/tutorials/install/&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
- https://eki.moe/posts/block-direct-ip-access-nginx/ - Eki</description>
        </item>
    
    
    
    
    
    
  </channel>
</rss> 