Wednesday, December 2, 2020

Free SSL Certificate Authorities (CAs)

There are a few public key CAs that issue free SSL certificates via the Automated Certificate Management Environment protocol (ACME). So, this serves as a bookmark for these CAs.

More detailed discussion about these three are in this blog post. This post and the discussion of the post have some useful information about these three, such as, support of wildcard certificates and ECC certifications.

Friday, November 20, 2020

Where are my Python packages?

Sometimes when I use a Python package, I run into some problems. I want to take a look at the source code of the package. But where are the packages?

There are a couple of methods. First, we can view where Python is looking for packages. For globally installed packages, we can locate the paths as follows,


$ python
Python 3.7.4 (default, Aug  9 2019, 18:34:13) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> for p in sys.path:
...   print(p)
...

The global site packages are at,


python
Python 3.7.4 (default, Aug  9 2019, 18:34:13) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import site
>>> for p in site.getsitepackages():
...   print(p)
...

If we have pip installed and know the package name, we can use a command like


$ pip show numpy

What if we want to know the path to the locally installed pacakges (user-installed packages)?


$ python
Python 3.7.4 (default, Aug  9 2019, 18:34:13) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import site
>>> site.getusersitepackages()
...

Monday, October 26, 2020

Updating Plex Media Server Plugin from FreeNAS 11.2-RELEASE to 11.3-RELEASE

 Plex failed to update when I upgrade FreeNAS from 11.2-RELEASE to 11.3-RELEASE. After some Web searches, I found the solution given in this post worked. For convenience, I copied the solution to this post in the following,

  1. Stop the plex jail
  2. Log on to a FreeNAS shell, and renamed the jail
    
        iocage rename plex plexmediaserver
        
  3. From the FreeNAS shell, go into /mnt/__YOUR_STORAGE__/iocage/jails/plexmediaserver/ and renam plex.json to plexmediaserver.json,
    
        mv plex.json plexmediaserver.json
        
  4. Open config.json in the same directory and change the plugin name from plex to plexmediaserver
  5. Start the jail again. Everything still worked and both jail and plugin now displayed as plexmediaserver
  6. Run the following command to upgrade the jail and the plex plugin
    
        iocage upgrade plexmediaserver -r 11.3-RELEASE
        

Monday, October 5, 2020

Which ISP's routers support hairpinning (NAT loopback)?

NAT loopback, also known as hairpinning is that two hosts on the LAN behind the NAT gateway can communicate with each other via the NAT gateway's external address. Which ISP's router out of the box supports NAT loopback? Based on experience thus far in October, 2020, my experience is as follows,

  • Optimum. Yes
  • Verizon Fios. Yes
  • Spectrum. No

Sunday, October 4, 2020

Configuring Windows Dynamic Port Allocation?

Some Windows applications can reserve TCP or UDP ports which may cause some other applications fail to run. These threads provide solutions to this problem,

The solution are generally three.

  1. Removing/disabling the offending application or Windows feature. For instance, the threads point out Hyper-V is often the culprit because it reserves ports dynamically and unpredictably. We can disable it if we aren't using it,
    
    REM disable Hyper-V
    dism.exe /Online /Disable-Feature:Microsoft-Hyper-V
      
    In PowerShell, do this to remove all Hyper-V adapters,
    
    Get-HNSNetwork | Remove-HNSNetwork
      
  2. Reset dynamic port range from which the offending application reserves ports. For instance, for Hyper-V, for instance, we can do this,
    
    dism.exe /Online /Disable-Feature:Microsoft-Hyper-V
    
    netsh int ipv4 add excludedportrange protocol=tcp startport=50051 numberofports=1
    
    dism.exe /Online /Enable-Feature:Microsoft-Hyper-V /All
        
  3. Disable dynamic port allocation, i.e.,
    
    reg add HKLM\SYSTEM\CurrentControlSet\Services\hns\State /v EnableExcludedPortRange /d 0 /f
        

Monday, September 28, 2020

Verizon Fios G3100 Router Fort Forwarding

Verizon Fios G3100 Router's manual doesn't explain clearly how to set up port forwarding. This is just a note to clarify a few concepts related to it, in particular, I saw there were a few discussions about port forwarding. 

To set up port forwarding, we go to https://192.168.1.1/. Note that the certificate is self-signed, and we have to accept it when the browser complains about it. 

Port Forwarding Rules

From the UI, follow the navigation path of "Network | Advanced | Network Settings | Port Forwarding Rules", we arrive at the UI to set up "Port Forwarding Rules". This is actually for you to define a network service you may wish to expose from you home network, i.e., to define an incoming port to the router from the outside the home network. 

With this in mind, the following example is to most is a mistake because we specify the source port as 80.

 

The source port is actually the port of the application that attempts to connect to port 80 at your home web server. It is very unlikely a web client is connecting from port 80. So the correct setup is likely to be the following for the Web service.

 

What is the service used for? This service is used to create port forwarding firewall rules. To set up port forwarding for a network service hosted at your home, you can select one of these rules to populate some fields for setting up port forwarding for a network service, so these rules only provide some convenience, but isn't necessary. I would say, forget about these.

Setting up Port Forwarding

To set up port forwarding, from the UI, follow the navigation path of "Network | Firewall  | Port Forwarding". The router's manual does not say much, in particular, advanced port forwarding. So, I believe that there is a confusion among users. 

The UI looks like this,

I marked "Add" and "Advanced". These are actually "buttons" you can click. To create advanced port forwarding rules, i.e., forwarding the traffic coming in to one port on the router to a different port on a host at your home, click "Advanced. Once, you are done, don't forget to click "Add".

The actually confusion comes from the UI of the "Advanced Port Forwarding Setup" interface, which is different from many other routers where you only specify two ports, like "external" and "incoming". Here you are given 3 fields to fill up 3 ports as shown below,

 

Source Ports

These aren't the ports open on your router. These are the ports belong to the network application running on a host outside of your home in the world. Let's say, you want to connect to the Plex server at your home from your office, these are the ports of your web browser on your office computer. For most applications, we don't know these ports since they are assigned by the operating systems dynamically. In generally, they should be "Any"

Destination Ports

These are the ports on the Fios router. We often call them the "service" ports. At your office, you open your home plex server at URL like http://your_home.example.com:51400/web/index.html, then you fill it up with 51400. Don't confuse this with the port open on a home server behind the Fios router. 

Forward to Port

This is actually a port open at your home server, in this figure, at 192.168.1.55. Using the example in the above, at your office, if you open your home plex server at URL like http://your_home.example.com:51400/web/index.html, the browser at your office computer connects to port 51400 at the Fios router at your home. The router then forwards the incoming network traffic to the home server at the "Forward to Port" you specify.

Testing Your Ports

You should test your ports. But you are at home. So we have to rely on some services. I saw a few recommended services like https://www.yougetsignal.com/tools/open-ports/. Be ware that lots of these tools only check TCP ports, e.g., if your game runs on UDP ports, find a better tool to test your ports.