Ubuntu Server: Configure the firewall with “ufw”

Ubuntu Server’s firewall is called ufw. If you are running an Ubuntu Server, you definitely want to enable some kind of firewall to keep intruders out of your ports. They likely will perform a port scan and try to find weaknesses. You can prevent this by enabling ufw and then configuring it to open ports that need access and close ones that don’t.

Enable ufw:

sudo ufw enable

Check ufw status:

sudo ufw status

Allow a service to run (example: ftp, telnet, ssh, http):

sudo ufw allow http

Open a port:

sudo ufw allow 22

Close a port:

sudo ufw deny 22

Open a range of ports and specify TCP or UDP:

sudo ufw allow 300:310/tcp

Close a range of ports and specify TCP or UDP:

sudo ufw deny 300:310/tcp

Delete a service:

sudo ufw status numbered
#creates a numbered list of services, example:

[ 1] 21/tcp                     ALLOW IN    Anywhere                  
[ 2] 22/tcp                     ALLOW IN    Anywhere                  
[ 3] 80/tcp                     ALLOW IN    Anywhere     

sudo ufw delete 3
#replace 3 with the service you want to delete

List applications that ufw can open service for:

sudo ufw app list
#will generate a list similar to this:
Available applications:
  Apache
  Apache Full
  Apache Secure
  CUPS
  OpenSSH
  plexmediaserver
  plexmediaserver-all
  plexmediaserver-dlna

Enable an application such as Apache. This is extremely important for a WordPress installation!

sudo ufw allow in "Apache Full"

Disable ufw:

sudo ufw disable

If you somehow screwed your ufw permissions up, you can reset them all. If you are configuring with SSH, make sure to enable your SSH service before re-enabling ufw!

sudo ufw reset

Hopefully, you have configured all of your services appropriately and have a good working firewall. If somehow this exercise is messing your server up, you can always disable it with “sudo ufw disable” until you can get more help or have more time to experiment. Happy and safe computing!

Advertisements

Static IP address for Ubuntu Server 18.04 “netplan”

If you are using Ubuntu Server version 18.04 LTS and want to configure a static IP address, the procedure has changed for network interface configuration.

We used to configure /etc/network/interfaces but now the system uses something called netplan. If you try to configure the old “interfaces” file, it will point you to this new netplan network configuration.

Here’s how we change the network interface to use a static IP address. Edit “50-cloud-init.yaml“, replacing the text with the text below. Replace the IP address with your own (192.168.1.100 used as an example) and then save:

sudo nano /etc/netplan/50-cloud-init.yaml
# This file is generated from information provided by
# the datasource.  Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
    ethernets:
        enp0s3:
            addresses: [192.168.1.100/24]
            gateway4: 192.168.1.1
            nameservers:
              addresses: [8.8.8.8,8.8.4.4]
            dhcp4: no
    version: 2

Apply the changes and then reboot.

sudo netplan apply
sudo reboot

Install Sony Playstation Now (PS Now) on Ubuntu

I’m always looking at ways to play video games on Ubuntu Linux. This one is a doozy. With Playstation Now, you can play over 700 real PS2, PS3 and PS4 games on your Ubuntu computer. The technology uses streaming from remote server where the gaming console exists. Sony typically will give you a couple weeks as a free trial though the deals vary. I was able to take advantage of a Black Friday sale with one full year of PS Now for only $70. Fantastic deal.

Here’s how to install PS Now on Ubuntu:

First install wine if it’s not already installed. Wine is a Linux program that helps us run Windows programs on the Linux platform.

sudo apt install wine-stable

Next, download winetricks into your downloads folder.

cd "${HOME}/Downloads"
wget  https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks
chmod +x winetricks

Now install some Windows apps with winetricks.

./winetricks corefonts
./winetricks vulkansdk
./winetricks dxvk
./winetricks vcrun2013

Now we are going to install Lutris, which is a program that helps you install games and other apps on your Wine Windows installation.

sudo apt-get install lutris

Once you find Lutris in your application menu and launch it.
Now visit the Lutris website and launch the PS Now installer.
https://lutris.net/games/playstation-now/
After you select ‘install’ you will see a Playstation Now icon in the Lutris application.

Here’s where I ran into trouble with this installation Mind you, I figured all this out by using directions cobbled together from many broken install methods I found on the web! When I tried to launch PS Now from Lutris, I was met with a message that said, “Vulkan is not installed” even though I installed it with winetricks (above).

Here’s the fix:

Right-click on the Playstation Now icon in Lutris.
Select “configure”.
Select the “runner options” tab.
Turn “Enable DXVK” off.
Save and relaunch. After poking on a couple dialog boxes, you should be good to go!

Ubuntu: Mounting a USB hard drive at reboot

First, if you have an exFat drive, you will need to install the Ubuntu exFat utility or you will get a “unknown filesystem type ‘exfat’” mount error.
To avoid that, in a console type:
sudo apt-get install exfat-fuse exfat-utils

Before we update anything, we will need to find out what your hard drive is called in the system before we mount it.
Any of these commands will tell you the drive name.
lsblk
sudo blkid
sudo fdisk -l

Look for something like this: /dev/sdb

You will need to create a mount point for the system.
>sudo mkdir /media/usb
You can replace “usb” with any name you like.

Now you will need to update your “fstab” file so Ubuntu can mount the drive at startup.

Important: find the Device and Filesystem with this command:
>df -T
Look for “Filesystem” and “Type”.
Example:
Filesystem Type 1K-blocks Used Available Use% Mounted on
/dev/sda2 ext4 959862832 368219792 542814880 41% /
The “Filesystem” is /dev/sda2 and the “Type” is “ext4”.

Edit fstab:
sudo nano /etc/fstab

Copy this statement into the file, replacing the #Device (example: /dev/sdb1) and #fs-type (example: exfat or ext4)

#Device #Mountpoint #fs-type #options #dump #fsck
/dev/sdb1 /media/usb exfat defaults 0 0

^O to write out, ^X to exit.
Reboot your machine:
sudo reboot

Your computer should mount your USB hard drive to /media/usb

Update Subsonic on Ubuntu

To update Subsonic from the Ubuntu console, it’s best to log into a terminal window from Windows or Mac using Putty (or the Mac terminal).
Using your web browser from Windows/Mac, visit the download page.
Find the Ubuntu download link and copy the link location.
Example: http://www.subsonic.org/pages/download2.jsp?target=subsonic-6.1.5.deb

Log into your server using Putty/terminal. Download the new file.
wget http://www.subsonic.org/pages/download2.jsp?target=subsonic-6.1.5.deb

Now execute the update command:
>sudo dpkg -i subsonic-6.1.5.deb

Updated and back in business!

Update Subsonic on Ubuntu; Mount USB drive at boot

Update Subsonic:

Download the subsonic package and execute this command:
sudo dpkg -i subsonic-6.1.5.deb
||||||||||||||||||||||||||||||||||||||
Mount a USB drive in Ubuntu Console:
Find the drive (three commands that will do it):
lsblk
sudo blkid
sudo fdisk -l

(example: /dev/sdb)

Create a mount point:
sudo mkdir /media/usb

Mount the drive:
sudo mount /dev/sdb1 /media/usb
||||||||||||||||||||||||||||||||||||||
Mount error: “unknown filesystem type ‘exfat’”

Install exfat filesystem utility for Ubuntu:
sudo apt-get install exfat-fuse exfat-utils
||||||||||||||||||||||||||||||||||||||
How to automatically mount usb flash drive at startup

List your drives:
sudo fdisk -l
(example: /dev/sdb1)

Edit /etc/fstab and place this info in the file, replacing the #Device and #fs-type with your own:

sudo nano /etc/fstab
add:
#Device #Mountpoint #fs-type #options #dump #fsck
/dev/sdb1 /media/usb exfat defaults 0 0
||||||||||||||||||||||||||||||||||||||