Jump to content

brent

Administrators
  • Posts

    125
  • Joined

  • Last visited

  • Days Won

    1

brent last won the day on November 22 2019

brent had the most liked content!

brent's Achievements

Enthusiast

Enthusiast (6/14)

  • Dedicated
  • Week One Done
  • One Month Later
  • One Year In
  • Conversation Starter

Recent Badges

5

Reputation

  1. Are you hosting service on a dynamic IP and receiving a new IP when bouncing your router or firewall? prerequisites: Cloud Flare API token Portainer *Optional* Docker Compose from here. 1. In portainer go to stacks. and create a new stack. 2. Copy the below docker-compose into the editor adding your API key. version: '2' services: cloudflare-ddns: image: oznu/cloudflare-ddns:latest restart: always environment: - API_KEY=xxxxxxx - ZONE=example.com - SUBDOMAIN=subdomain #remove - PROXIED=yes 3. I remove the "SUBDOMAIN" environment as I use CNAME for all my subdomains. Meaning if I update the IP of my A record then my subdomains that use CNAME records are updated. 4. Before clicking on deployment let's set up a test scenario. Go to Cloud Flare and change the last octet of the IP. 5. Back in Portainer click deploy. 6. Go to container logs and verify the container is running. You should see the IP change. 7. In cloud flare verify the DNS has changed to reflect your current IP. 8. In the environment you will see a cron job to run every 5 minutes. This can be changed to your needs.
  2. Update your Instance It is critically important to keep your self-hosted Bitwarden instance up to date. Updates may include fixes that are important for the security of your Bitwarden instance, including patches to any vulnerabilities. Data stored in your Bitwarden vault, including passwords, should be considered critical data and therefore protected with up-to-date software. Additionally, newer versions of client applications may not support older versions of your self-hosted instance. If you're running a standard installation, update your Bitwarden instance using the same Bash (Linux or macOS) or Powershell (Windows) script (bitwarden.sh) used to install Bitwarden. Run the following sequence of commands: Bash ./bitwarden.sh updateself ./bitwarden.sh update
  3. brent

    adguard-sync

    From portainer open stacks and add the below. Modify IP's of adguard servers. If adguard won't spin up you need to disable the host systemd-resolved sudo systemctl disable systemd-resolved.service sudo systemctl stop systemd-resolved --- version: "2.1" services: adguardhome-sync: image: quay.io/bakito/adguardhome-sync container_name: adguardhome-sync command: run environment: - ORIGIN_URL=http://192.168.1.26:85 #change as necessary - ORIGIN_USERNAME=dbtech #change as necessary - ORIGIN_PASSWORD=password #change as necessary - REPLICA_URL=http://192.168.1.27 #change as necessary - REPLICA_USERNAME=dbtech #change as necessary - REPLICA_PASSWORD=password #change as necessary - REPLICA1_URL=http://192.168.1.4 #change as necessary - REPLICA1_USERNAME=username #change as necessary - REPLICA1_PASSWORD=password #change as necessary - CRON=*/1 * * * * # run every 1 minute - RUNONSTART=true ports: - 8080:8080 #change as necessary restart: unless-stopped ################ # # Original Source: # https://github.com/bakito/adguardhome-sync # ################
  4. Iptables is a firewall, installed by default on many Linux distributions. This walk through is simple for setting up the basic server. In this tutorial we will go over how to set up iptables for the first time. Note: When working with firewalls, do not block SSH communication; lock yourself out of your own server (port 22, by default). Prerequisites: Install iptables persistent to save iptables sudo apt install iptables-persistent make a directory /etc/iptables sudo mkdir /etc/iptables useful commands: sudo iptables -L sudo iptables -L -v sudo iptables -S Introducing new rules: To begin using iptables, add the rules for authorized inbound traffic for the services you need. Iptables can keep track of the connection’s state. Therefore, use the command below to enable established connections to continue. sudo iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT Allow traffic to a specific port to permit SSH connections by doing the following: sudo iptables -A INPUT -p tcp --dport ssh -j ACCEPT Change the input policy to drop once you’ve added all the required authorized rules. Note: Changing the default rule to drop will allow only specially allowed connections. Before modifying the default rule, ensure you’ve enabled at least SSH, as stated above. sudo iptables -P INPUT DROP Rules for saving and restoring If you restart your server, all these iptables configurations will be lost. Save the rules to a file to avoid this. sudo iptables-save > /etc/iptables/rules.v4 You may then just read the stored file to restore the saved rules. # Overwrite the existing rules sudo iptables-restore < /etc/iptables/rules.v4 # Append new rules while retaining the existing ones sudo iptables-restore -n < /etc/iptables/rules.v4 You may automate the restore procedure upon reboot by installing an extra iptables package that handles the loading of stored rules. Use the following command to do this. sudo apt-get install iptables-persistent After installation, the first setup will prompt you to preserve the current IPv4 and IPv6 rules; choose Yes, and press Enter for both. Saving Updates If you ever think of updating your firewall and want the changes to be durable, you must save your iptables rules. This command will help save your firewall rules: sudo netfilter-persistent save Example of IPTABLES: *filter :INPUT ACCEPT [63:3208] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [36:2160] -A INPUT -i lo -j ACCEPT -A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT (Accepting all established connections) -A INPUT -m conntrack --ctstate INVALID -j DROP (Drop statement if service or port doesn't match) -A INPUT -s 83.97.73.245/32 -j DROP (Example of blocking bad IP) -A INPUT -s 83.97.73.245/32 -j REJECT --reject-with icmp-port-unreachable (Rejecting a bad IP) -A INPUT -s 192.168.1.0/24 -p tcp -m tcp --dport 22 -m conntrack --ctstate NEW,> (Allow SSH from subnet) -A INPUT -p udp -m udp --dport 137 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT (Allow port) -A INPUT -p udp -m udp --dport 138 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT -A INPUT -p tcp -m tcp --dport 139 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT -A OUTPUT -o lo -j ACCEPT -A OUTPUT -m conntrack --ctstate ESTABLISHED -j ACCEPT COMMIT To accept all traffic on your loopback interface, run these commands: sudo iptables -A INPUT -i lo -j ACCEPT sudo iptables -A OUTPUT -o lo -j ACCEPT Allowing Established and Related Incoming Connections As network traffic generally needs to be two-way – incoming and outgoing – to work properly, it is typical to create a firewall rule that allows established and related incoming traffic, so that the server will allow return traffic for outgoing connections initiated by the server itself. This command will allow that: sudo iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT Allowing Established Outgoing Connections You may want to allow outgoing traffic of all established connections, which are typically the response to legitimate incoming connections. This command will allow that: sudo iptables -A OUTPUT -m conntrack --ctstate ESTABLISHED -j ACCEPT Allowing Internal Network to access External Assuming eth0 is your external network, and eth1 is your internal network, this will allow your internal to access the external: sudo iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT Dropping Invalid Packets Some network traffic packets get marked as invalid. Sometimes it can be useful to log this type of packet but often it is fine to drop them. Do so with this command: sudo iptables -A INPUT -m conntrack --ctstate INVALID -j DROP Blocking an IP Address To block network connections that originate from a specific IP address, 203.0.113.51 for example, run this command: sudo iptables -A INPUT -s 203.0.113.51 -j DROP In this example, -s 203.0.113.51 specifies a source IP address of “203.0.113.51”. The source IP address can be specified in any firewall rule, including an allow rule. If you want to reject the connection instead, which will respond to the connection request with a “connection refused” error, replace “DROP” with “REJECT” like this: sudo iptables -A INPUT -s 203.0.113.51 -j REJECT Blocking Connections to a Network Interface To block connections from a specific IP address, e.g. 203.0.113.51, to a specific network interface, e.g. eth0, use this command: iptables -A INPUT -i eth0 -s 203.0.113.51 -j DROP This is the same as the previous example, with the addition of -i eth0. The network interface can be specified in any firewall rule, and is a great way to limit the rule to a particular network. Service: SSH If you’re using a server without a local console, you will probably want to allow incoming SSH connections (port 22) so you can connect to and manage your server. This section covers how to configure your firewall with various SSH-related rules. Allowing All Incoming SSH To allow all incoming SSH connections run these commands: sudo iptables -A INPUT -p tcp --dport 22 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT sudo iptables -A OUTPUT -p tcp --sport 22 -m conntrack --ctstate ESTABLISHED -j ACCEPT The second command, which allows the outgoing traffic of established SSH connections, is only necessary if the OUTPUT policy is not set to ACCEPT. Allowing Incoming SSH from Specific IP address or subnet To allow incoming SSH connections from a specific IP address or subnet, specify the source. For example, if you want to allow the entire 203.0.113.0/24 subnet, run these commands: sudo iptables -A INPUT -p tcp -s 203.0.113.0/24 --dport 22 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT sudo iptables -A OUTPUT -p tcp --sport 22 -m conntrack --ctstate ESTABLISHED -j ACCEPT The second command, which allows the outgoing traffic of established SSH connections, is only necessary if the OUTPUT policy is not set to ACCEPT. Here's a sample of setting up a rule which only allows SSH from a single IP: Add a new "allow SSH from 1.2.3.4" rule: iptables -A INPUT -p tcp -s 1.2.3.4 --dport 22 -j ACCEPT Block SSH from all other IPs: iptables -A INPUT -p tcp -s 0.0.0.0/0 --dport 22 -j DROP Now your INPUT chain will look like: Chain INPUT (policy ACCEPT) target prot opt source destination ACCEPT tcp -- 1.2.3.4 0.0.0.0/0 tcp dpt:22 DROP tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:22 Later, if you need to whitelist a second IP you can use the -I parameter to place it before the blacklist rule. iptables -I INPUT 2 -p tcp -s 4.3.2.1 --dport 22 -j ACCEPT Chain INPUT (policy ACCEPT) target prot opt source destination ACCEPT tcp -- 1.2.3.4 0.0.0.0/0 tcp dpt:22 ACCEPT tcp -- 4.3.2.1 0.0.0.0/0 tcp dpt:22 DROP tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:22 Notice that using -I INPUT 2 added the new rule as rule number 2 and bumped the DROP rule to number 3. Allowing Outgoing SSH If your firewall OUTPUT policy is not set to ACCEPT, and you want to allow outgoing SSH connections—your server initiating an SSH connection to another server—you can run these commands: sudo iptables -A OUTPUT -p tcp --dport 22 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT sudo iptables -A INPUT -p tcp --sport 22 -m conntrack --ctstate ESTABLISHED -j ACCEPT Allowing Incoming Rsync from Specific IP Address or Subnet Rsync, which runs on port 873, can be used to transfer files from one computer to another. To allow incoming rsync connections from a specific IP address or subnet, specify the source IP address and the destination port. For example, if you want to allow the entire 203.0.113.0/24 subnet to be able to rsync to your server, run these commands: sudo iptables -A INPUT -p tcp -s 203.0.113.0/24 --dport 873 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT sudo iptables -A OUTPUT -p tcp --sport 873 -m conntrack --ctstate ESTABLISHED -j ACCEPT The second command, which allows the outgoing traffic of established rsync connections, is only necessary if the OUTPUT policy is not set to ACCEPT. Service: Web Server Web servers, such as Apache and Nginx, typically listen for requests on port 80 and 443 for HTTP and HTTPS connections, respectively. If your default policy for incoming traffic is set to drop or deny, you will want to create rules that will allow your server to respond to those requests. Allowing All Incoming HTTP To allow all incoming HTTP (port 80) connections run these commands: sudo iptables -A INPUT -p tcp --dport 80 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT sudo iptables -A OUTPUT -p tcp --sport 80 -m conntrack --ctstate ESTABLISHED -j ACCEPT The second command, which allows the outgoing traffic of established HTTP connections, is only necessary if the OUTPUT policy is not set to ACCEPT. Allowing All Incoming HTTPS To allow all incoming HTTPS (port 443) connections run these commands: sudo iptables -A INPUT -p tcp --dport 443 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT sudo iptables -A OUTPUT -p tcp --sport 443 -m conntrack --ctstate ESTABLISHED -j ACCEPT The second command, which allows the outgoing traffic of established HTTP connections, is only necessary if the OUTPUT policy is not set to ACCEPT. Allowing All Incoming HTTP and HTTPS If you want to allow both HTTP and HTTPS traffic, you can use the multiport module to create a rule that allows both ports. To allow all incoming HTTP and HTTPS (port 443) connections run these commands: sudo iptables -A INPUT -p tcp -m multiport --dports 80,443 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT sudo iptables -A OUTPUT -p tcp -m multiport --dports 80,443 -m conntrack --ctstate ESTABLISHED -j ACCEPT The second command, which allows the outgoing traffic of established HTTP and HTTPS connections, is only necessary if the OUTPUT policy is not set to ACCEPT. Service: MySQL MySQL listens for client connections on port 3306. If your MySQL database server is being used by a client on a remote server, you need to be sure to allow that traffic. Allowing MySQL from Specific IP Address or Subnet To allow incoming MySQL connections from a specific IP address or subnet, specify the source. For example, if you want to allow the entire 203.0.113.0/24 subnet, run these commands: sudo iptables -A INPUT -p tcp -s 203.0.113.0/24 --dport 3306 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT sudo iptables -A OUTPUT -p tcp --sport 3306 -m conntrack --ctstate ESTABLISHED -j ACCEPT The second command, which allows the outgoing traffic of established MySQL connections, is only necessary if the OUTPUT policy is not set to ACCEPT. Allowing MySQL to Specific Network Interface To allow MySQL connections to a specific network interface—say you have a private network interface eth1, for example—use these commands: sudo iptables -A INPUT -i eth1 -p tcp --dport 3306 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT sudo iptables -A OUTPUT -o eth1 -p tcp --sport 3306 -m conntrack --ctstate ESTABLISHED -j ACCEPT The second command, which allows the outgoing traffic of established MySQL connections, is only necessary if the OUTPUT policy is not set to ACCEPT. Service: PostgreSQL PostgreSQL listens for client connections on port 5432. If your PostgreSQL database server is being used by a client on a remote server, you need to be sure to allow that traffic. PostgreSQL from Specific IP Address or Subnet To allow incoming PostgreSQL connections from a specific IP address or subnet, specify the source. For example, if you want to allow the entire 203.0.113.0/24 subnet, run these commands: sudo iptables -A INPUT -p tcp -s 203.0.113.0/24 --dport 5432 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT sudo iptables -A OUTPUT -p tcp --sport 5432 -m conntrack --ctstate ESTABLISHED -j ACCEPT The second command, which allows the outgoing traffic of established PostgreSQL connections, is only necessary if the OUTPUT policy is not set to ACCEPT. Allowing PostgreSQL to Specific Network Interface To allow PostgreSQL connections to a specific network interface—say you have a private network interface eth1, for example—use these commands: sudo iptables -A INPUT -i eth1 -p tcp --dport 5432 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT sudo iptables -A OUTPUT -o eth1 -p tcp --sport 5432 -m conntrack --ctstate ESTABLISHED -j ACCEPT The second command, which allows the outgoing traffic of established PostgreSQL connections, is only necessary if the OUTPUT policy is not set to ACCEPT. Service: Mail Mail servers, such as Sendmail and Postfix, listen on a variety of ports depending on the protocols being used for mail delivery. If you are running a mail server, determine which protocols you are using and allow the appropriate types of traffic. We will also show you how to create a rule to block outgoing SMTP mail. Blocking Outgoing SMTP Mail If your server shouldn’t be sending outgoing mail, you may want to block that kind of traffic. To block outgoing SMTP mail, which uses port 25, run this command: sudo iptables -A OUTPUT -p tcp --dport 25 -j REJECT This configures iptables to reject all outgoing traffic on port 25. If you need to reject a different service by its port number, instead of port 25, substitute that port number for the 25 above. Allowing All Incoming SMTP To allow your server to respond to SMTP connections on port 25, run these commands: sudo iptables -A INPUT -p tcp --dport 25 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT sudo iptables -A OUTPUT -p tcp --sport 25 -m conntrack --ctstate ESTABLISHED -j ACCEPT The second command, which allows the outgoing traffic of established SMTP connections, is only necessary if the OUTPUT policy is not set to ACCEPT. Allowing All Incoming IMAP To allow your server to respond to IMAP connections, port 143, run these commands: sudo iptables -A INPUT -p tcp --dport 143 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT sudo iptables -A OUTPUT -p tcp --sport 143 -m conntrack --ctstate ESTABLISHED -j ACCEPT The second command, which allows the outgoing traffic of established IMAP connections, is only necessary if the OUTPUT policy is not set to ACCEPT. Allowing All Incoming IMAPS To allow your server to respond to IMAPS connections, port 993, run these commands: sudo iptables -A INPUT -p tcp --dport 993 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT sudo iptables -A OUTPUT -p tcp --sport 993 -m conntrack --ctstate ESTABLISHED -j ACCEPT The second command, which allows the outgoing traffic of established IMAPS connections, is only necessary if the OUTPUT policy is not set to ACCEPT. Allowing All Incoming POP3 To allow your server to respond to POP3 connections, port 110, run these commands: sudo iptables -A INPUT -p tcp --dport 110 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT sudo iptables -A OUTPUT -p tcp --sport 110 -m conntrack --ctstate ESTABLISHED -j ACCEPT The second command, which allows the outgoing traffic of established POP3 connections, is only necessary if the OUTPUT policy is not set to ACCEPT. Allowing All Incoming POP3S To allow your server to respond to POP3S connections, port 995, run these commands: sudo iptables -A INPUT -p tcp --dport 995 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT sudo iptables -A OUTPUT -p tcp --sport 995 -m conntrack --ctstate ESTABLISHED -j ACCEPT The second command, which allows the outgoing traffic of established POP3S connections, is only necessary if the OUTPUT policy is not set to ACCEPT.
  5. Install Qemu guest agent for Debian/Ubuntu In this article, we will help you to install the Qemu guest agent on your vm server. This agent is a helper daemon that exchanges information between the quest and the host and executes commands in the guest for snapshot or backup. The guest agent is used for mainly two things one for properly shut down the guest and the second is to freeze the guest file system when making a backup. Step 1: Log in using SSH You must be logged in via SSH with the root account or an account with sudo privileges. Step 2: Install qemu guest agent apt update && apt -y install qemu-guest-agent Step 3: Enable and Start Qemu Agent systemctl enable qemu-guest-agent systemctl start qemu-guest-agent Step 4: Verify Verify that the Qemu quest agent is running systemctl status qemu-guest-agent Conclusion If you are having a problem with the service starting power off the VM completely then start the VM. A restart of the VM won't work in some cases. Congratulations, you have installed the Qemu guest agent on your Debian/Ubuntu based system.
  6. Do you want to access your fleet of Linux servers without a password? First and foremost using password authentication via SSH is a bad practice even more so if your Linux server is internet-facing. Using a public key to access your Linux servers is best practice and prevents brute force attacks. Permissions: from your Linux workstation, if you are getting a permission error trying to ssh to a server check the following permissions. ~/.ssh needs to be owned by the user account. Make sure authorized_keys has the correct permissions. ls -l .ssh/authorized_keys make sure it has a permission of 600. sudo chmod 600 ~/.ssh/authorized_keys make sure the ~/.ssh directory is owned by the user. sudo chown brent:brent ~/.ssh ~/.ssh/id_rsa needs to have a permission of 600. sudo chmod 600 ~/.ssh/id_rsa The id_rsa.pub public key needs to have a permission of 644. sudo chmod 644 ~/.ssh/id_rsa.pub Prerequisites: Windows workstation putty for Windows (Download putty for Windows. You can find the latest Windows installer here. Linux workstation Linux server Generating SSH keys in Windows Create a folder on your local computer called SSH keys. This folder can be anywhere desktop, documents, etc.. Open PuTTygen from your start menu. Change the number of bits in the generated key to 4096 and click Generated. Move the mouse in the open area until complete. Copy the public key to Notepad and save it in the SSH keys folder. Now save the private key to the SSH key folder. You can close PuTTYgen once the files have been saved. Now you should have two files in the folder ssh keys. Copying the Public key to the Linux server. Open Putty and login to your Linux server. We need to check to see if a ssh folder already exists cd ~/.ssh if you don't have one sudo mkdir ~/.ssh Create a file called authorized_keys sudo mkdir ~/.ssh/authorized_keys Open your public key in Notepad and copy the key. Using your favorite text editor paste the key into the authorized_keys file and save. If you already have an authorized_keys file, add the key on another line. sudo nano ~/.ssh/authorized_keys Log out of your server. Open PuTTy up to make a couple of changes. make sure to add user@ in front of your hostname or IP. On the left side navigate to SSH > Auth > Credentials and click Browse to point to the Private key. Once the Key has been added Click on Session and save the session. You will need to repeat this for every server. Create SSH keys on a Linux workstation. Let's make sure we don't have an SSH key pair. ls -l ~/.ssh If the directory exists you may want to back it up as the following command will overwrite the folder. ssh-keygen -b 4096 Save the path in the default location. Enter Passphrase. This isn't required but is suggested as another layer of protection. If you choose to use a passphrase know that you will have to use the passphrase every time you log in. Let's verify that the keys have been created. ls -l ~/.ssh You should see two files id_rsa, the private key, and id_rsa.pub, the public key. Now let's copy the public key over to the server. ssh-copy-id [email protected] Type the server user password. Like below once you log in you should see the Number of key(s) added:1 Let's verify the public key is working. ssh [email protected] If the key is working you won't be prompted for a password.
  7. Install Qemu guest agent for Debian/Ubuntu In this article, we will help you to install the Qemu guest agent on your vm server. This agent is a helper daemon that exchanges information between the quest and the host and executes commands in the guest for snapshot or backup. The guest agent is used for mainly two things one for properly shut down the guest and the second is to freeze the guest file system when making a backup. Step 1: Log in using SSH You must be logged in via SSH with the root account or an account with sudo privileges. Step 2: Install qemu guest agent apt update && apt -y install qemu-guest-agent Step 3: Enable and Start Qemu Agent systemctl enable qemu-guest-agent systemctl start qemu-guest-agent Step 4: Verify Verify that the Qemu quest agent is running systemctl status qemu-guest-agent Conclusion If you are having a problem with the service starting power off the VM completely then start the VM. A restart of the VM won't work in some cases. Congratulations, you have installed the Qemu guest agent on your Debian/Ubuntu based system.
  8. DEB-based distros (Ubuntu, etc.) To enable the Plex Media Server repository on Ubuntu only a few terminal commands are required. From a terminal window run the following two commands: echo deb https://downloads.plex.tv/repo/deb public main | sudo tee /etc/apt/sources.list.d/plexmediaserver.list wget https://downloads.plex.tv/plex-keys/PlexSign.key cat PlexSign.key | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/PlexSigkey.gpg After that, it’s just a matter of running the normal sudo apt-get update and the Plex Media Server repo will be enabled on the OS.
  9. Tautulli will be installed to /opt/Tautulli. Open a terminal Install Git Ubuntu/Debian: sudo apt-get install git-core Fedora: sudo yum install git Install prerequisites: Ubuntu/Debian: sudo apt-get install python python-setuptools tzdata Fedora: sudo yum install python python2-setuptools Type: cd /opt Type: sudo git clone https://github.com/Tautulli/Tautulli.git Optional: Ubuntu/Debian: sudo addgroup tautulli && sudo adduser --system --no-create-home tautulli --ingroup tautulli CentOS/Fedora: sudo adduser --system --no-create-home tautulli sudo chown tautulli:tautulli -R /opt/Tautulli Type: cd Tautulli to start Tautulli Type: python Tautulli.py Tautulli will be loaded in your browser or listening on http://localhost:8181 To run Tautulli in the background on startup: # Tautulli - Stats for Plex Media Server usage # # Service Unit file for systemd system manager # # INSTALLATION NOTES # # 1. Copy this file into your systemd service unit directory (often '/lib/systemd/system') # and name it 'tautulli.service' with the following command: # sudo cp /opt/Tautulli/init-scripts/init.systemd /lib/systemd/system/tautulli.service # # 2. Edit the new tautulli.service file with configuration settings as required. # More details in the "CONFIGURATION NOTES" section shown below. # # 3. Enable boot-time autostart with the following commands: # sudo systemctl daemon-reload # sudo systemctl enable tautulli.service # # 4. Start now with the following command: # sudo systemctl start tautulli.service # # CONFIGURATION NOTES # # - The example settings in this file assume that you will run Tautulli as user: tautulli # - The example settings in this file assume that Tautulli is installed to: /opt/Tautulli # # - To create this user and give it ownership of the Tautulli directory: # Ubuntu/Debian: sudo addgroup tautulli && sudo adduser --system --no-create-home tautulli --ingroup tautulli # CentOS/Fedora: sudo adduser --system --no-create-home tautulli # sudo chown tautulli:tautulli -R /opt/Tautulli # # - Adjust ExecStart= to point to: # 1. Your Tautulli executable # - Default: /opt/Tautulli/Tautulli.py # 2. Your config file (recommended is to put it somewhere in /etc) # - Default: --config /opt/Tautulli/config.ini # 3. Your datadir (recommended is to NOT put it in your Tautulli exec dir) # - Default: --datadir /opt/Tautulli # # - Adjust User= and Group= to the user/group you want Tautulli to run as. # # - WantedBy= specifies which target (i.e. runlevel) to start Tautulli for. # multi-user.target equates to runlevel 3 (multi-user text mode) # graphical.target equates to runlevel 5 (multi-user X11 graphical mode) [Unit] Description=Tautulli - Stats for Plex Media Server usage Wants=network-online.target After=network-online.target [Service] ExecStart=/opt/Tautulli/Tautulli.py --config /opt/Tautulli/config.ini --datadir /opt/Tautulli --quiet --daemon --nolaunch GuessMainPID=no Type=forking User=tautulli Group=tautulli [Install] WantedBy=multi-user.target
  10. Step 1 - Add Plex Repository The first step we need to do for this guide is to add the Plex repository to our CentOS 7 system. Go to the 'yum.repos.d' directory and create new repo file 'plex.repo' using the vim editor. cd /etc/yum.repos.d/ vim plex.repo Paste the following Plex repository configuration there. # Plex.repo file will allow dynamic install/update of plexmediaserver. [PlexRepo] name=PlexRepo baseurl=https://downloads.plex.tv/repo/rpm/$basearch/ enabled=1 gpgkey=https://downloads.plex.tv/plex-keys/PlexSign.key gpgcheck=1 Save and exit. Plex repository has been added to the CentOS 7 system. Step 2 - Install Plex Media Server on CentOS 7\8 Now we will install Plex media server on our CentOS server. Run the yum command below. sudo yum -y install plexmediaserver After the installation is complete, start the plex service and enable it to launch everytime at system boot using the systemctl commands below. systemctl start plexmediaserver systemctl enable plexmediaserver Plex media server has been installed - check it using the following command. systemctl status plexmediaserver And you will get the result as shown below. The Plex Media Server is now running on the CentOS 7 server. Step 2 - remove Plex Media Server on CentOS 7\8 To completely remove the Plex Media Server from the computer, first make sure the Plex Media Server is not running. Then do the following: Run the command rpm -e plexmediaserver Remove the directory /var/lib/plexmediaserver/ Run the command userdel plex Step 3 - Configure Firewalld Rules for Plex Media Server In this tutorial, we will enable Firewalld services. Make sure firewalld packages are installed on the system. Or you can install them using the yum command below. sudo yum -y install firewalld Now start the firewalld service and enable it to launch every time at system boot. systemctl start firewalld systemctl enable firewalld Next, we need to add new firewalld configuration for our plex installation. Plex media server needs some port in the 'LISTEN' state, so we will create new firewalld XML configuration. Go to the '/etc/firewalld/service' directory and create a new service firewalld configuration 'plex.xml' using vim. cd /etc/firewalld/services/ vim plexmediaserver.xml There, paste the following configuration. <?xml version="1.0" encoding="utf-8"?> <service> <short>plexmediaserver</short> <description>Ports required by plexmediaserver.</description> <port protocol="tcp" port="32400"></port> <port protocol="udp" port="1900"></port> <port protocol="tcp" port="3005"></port> <port protocol="udp" port="5353"></port> <port protocol="tcp" port="8324"></port> <port protocol="udp" port="32410"></port> <port protocol="udp" port="32412"></port> <port protocol="udp" port="32413"></port> <port protocol="udp" port="32414"></port> <port protocol="tcp" port="32469"></port> </service> Save and exit. Now add the 'plexmediaserver' service to the firewalld services list, then reload the configuration. sudo firewall-cmd --add-service=plexmediaserver --permanent sudo firewall-cmd --reload And you will get the result as below. The plexmediaserver service has been added to firewalld - check it using the firewalld command below. firewall-cmd --list-all And you should get 'plexmediaserver' on service list. Step 4 - Configure Plex Media Server Before configuring the Plex media server, make sure you have an account for Plex. If not, you can register using the URL below. https://app.plex.tv/ And then login to your account. If you're a registered user and logged in with your browser, you can open your Plex media server installation url in the following way changing the IP to your server IP. http://192.168.33.10:32400/web/ And you will be redirected to the plex login as below. Click the 'SIGN IN' button.
  11. Plex is a free feature-rich media library platform that provides a way to store all your movies, shows, and other media in one place. You can access Plex from any device, whether you’re at home or on-the-go. There are many different media tools available in the world like, Kodi, Xmbc, OSMC and Mediatomb, but the Plex Media Server is perhaps one of the most popular solutions for managing media. Plex runs on Windows, macOS, Linux, FreeBSD and many more. Plex is a client-server media player system made up from two main components, 1) The Plex Media Server, which organizes music, photos and videos content from personal media libraries and streams it to their player, 2) The Players that can be the Plex web UI, Plex Apps or Plex home theater. Plex Media Server supports Chromecast, Amazon FireTV, Android, iOS, Xbox, PlayStation, Apple TV, Roku, Android TV and various types of smart TVs. If you are looking for a way to watch your movies from anywhere, then Plex is best choice for you. In this tutorial, we will learn how to install and configure Plex Media Server on Ubuntu 16.04. Requirements A server running Ubuntu 20.04 A not-root user with sudo privileges setup on your server. A static IP address 192.168.0.227 setup on your server. Getting Started Before starting, make sure your system is fully up to date by running the following command: sudo apt-get update -y sudo apt-get upgrade -y Once your system is updated, restart your system to apply all these changes with the following command: sudo reboot After restarting, log in with sudo user and proceed to the next step. 1. Install Plex Media Server First, you will need to download the latest version of the Plex from their official website. You can download it by running the following command: wget https://downloads.plex.tv/plex-media-server/1.7.5.4035-313f93718/plexmediaserver_1.7.5.4035-313f93718_amd64.deb Once Plex is downloaded, run the following command to install Plex: sudo dpkg -i plexmediaserver_1.7.5.4035-313f93718_amd64.deb Next, start Plex Media Server and enable it to start on boot time by running the following command: sudo systemctl start plexmediaserver sudo systemctl enable plexmediaserver You can check the status of Plex Media Server at any time by running the following command: sudo systemctl status plexmediaserver You should see the following output: ? plexmediaserver.service - Plex Media Server for Linux Loaded: loaded (/lib/systemd/system/plexmediaserver.service; enabled; vendor preset: enabled) Active: active (running) since Sat 2017-08-05 11:48:52 IST; 17s ago Main PID: 3243 (sh) CGroup: /system.slice/plexmediaserver.service ??3243 /bin/sh -c LD_LIBRARY_PATH=/usr/lib/plexmediaserver "/usr/lib/plexmediaserver/Plex Media Server" ??3244 /usr/lib/plexmediaserver/Plex Media Server ??3288 Plex Plug-in [com.plexapp.system] /usr/lib/plexmediaserver/Resources/Plug-ins-313f93718/Framework.bundle/Contents/Resources/Versions/ Aug 05 11:49:04 Node1 systemd[1]: Started Plex Media Server for Linux. Aug 05 11:49:04 Node1 sh[3243]: Error in command line:the argument for option '--serverUuid' should follow immediately after the equal sign Aug 05 11:49:04 Node1 sh[3243]: Crash Uploader options (all are required): Aug 05 11:49:04 Node1 sh[3243]: --directory arg Directory to scan for crash reports Aug 05 11:49:04 Node1 sh[3243]: --serverUuid arg UUID of the server that crashed Aug 05 11:49:04 Node1 sh[3243]: --userId arg User that owns this product Aug 05 11:49:04 Node1 sh[3243]: --platform arg Platform string Aug 05 11:49:04 Node1 sh[3243]: --url arg URL to upload to Aug 05 11:49:04 Node1 sh[3243]: --help show help message Aug 05 11:49:04 Node1 sh[3243]: --version arg Version of the product Next, you will need to create a directory to store your Plex media. You can create this by running the following command: sudo mkdir -p /root/plex/movie Or if you already have shares on your server, skip this step Once you are finished, you can proceed to the next step. 2. Configure Plex Now, all the components are installed on your system, it's time to configure and access Plex. Open your web browser and type the URL http://192.168.0.227:32400/web, login and follow the setup wizard. Congratulations! your Plex Media Server is ready, you are now ready to connect to it from your Plex client application or Web browser.
  12. Node exporter is the best way to collect all the Linux server related metrics and statistics for monitoring. Monitor Linux Servers Using Prometheus In this guide, you will learn how to setup Prometheus node exporter on a Linux server to export all node level metrics to the Prometheus server. Before You Begin Prometheus Node Exporter needs Prometheus server to be up and running. If you would like to setup Prometheus, please see the Port 9100 opened in server firewall as Prometheus reads metrics on this port. Setup Node Exporter Binary Step 1: Download the latest node exporter package. You should check the Prometheus downloads section for the latest version and update this command to get that package. wget https://github.com/prometheus/node_exporter/releases/download/v1.3.1/node_exporter-1.3.1.linux-amd64.tar.gz Step 2: Unpack the tarball tar -xvf node_exporter-0.18.1.linux-amd64.tar.gz Step 3: Move the node export binary to /usr/local/bin sudo mv node_exporter-0.18.1.linux-amd64/node_exporter /usr/local/bin/ Create a Custom Node Exporter Service Step 1: Create a node_exporter user to run the node exporter service. sudo useradd -rs /bin/false node_exporter Step 2: Create a node_exporter service file under systemd. sudo vi /etc/systemd/system/node_exporter.service Step 3: Add the following service file content to the service file and save it. [Unit] Description=Node Exporter After=network.target [Service] User=node_exporter Group=node_exporter Type=simple ExecStart=/usr/local/bin/node_exporter [Install] WantedBy=multi-user.target Step 4: Reload the system daemon and star the node exporter service. sudo systemctl daemon-reload sudo systemctl start node_exporter Step 5: check the node exporter status to make sure it is running in the active state. sudo systemctl status node_exporter Step 6: Enable the node exporter service to the system startup. sudo systemctl enable node_exporter Now, node exporter would be exporting metrics on port 9100. You can see all the server metrics by visiting your server URL on /metrics as shown below. http://<server-IP>:9100/metrics Configure the Server as Target on Prometheus Server Now that we have the node exporter up and running on the server, we have to add this server a target on the Prometheus server configuration. Note: This configuration should be done on the Prometheus server. Step 1: Login to the Prometheus server and open the prometheus.yml file. sudo vi /etc/prometheus/prometheus.yml Step 2: Under the scrape config section add the node exporter target as shown below. Change 10.142.0.3 with your server IP where you have setup node exporter. Job name can be your server hostname or IP for identification purposes. - job_name: 'node_exporter_metrics' scrape_interval: 5s static_configs: - targets: ['10.142.0.3:9100'] Step 3: Restart the prometheus service for the configuration changes to take place. sudo systemctl restart prometheus Now, if you check the target in prometheus web UI (http://<prometheus-IP>:9090/targets) , you will be able to see the status as shown below. Also, you can use the Prometheus expression browser to query for node related metrics. Following are the few key node metrics you can use to find its statistics. node_memory_MemFree_bytes node_cpu_seconds_total node_filesystem_avail_bytes rate(node_cpu_seconds_total{mode="system"}[1m]) rate(node_network_receive_bytes_total[1m])
  13. INSTALL PHP 7.4 1. Install epel repo and remi repo # dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm -y # dnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpm -y 2. Check php module list and Install PHP7.4 # dnf module list php # dnf module enable php:remi-7.4 -y 3. Install PHP and the Extensions # dnf install php php-cli php-common php-json php-xml php-mbstring php-mysqli php-zip php-intl Disable SElinux 1. in order to install PI-Hole you need to disable SElinux /etc/selinux/config 2. reboot the server. Disable Firewall (optional) 1. Disable the Firewall or configure firewall for Pi-hole. sudo systemctl stop firewalld sudo systemctl disable firewalld INSTALL PI-HOLE 1 . Download Install Pi-hole # git clone --depth 1 https://github.com/pi-hole/pi-hole.git Pi-hole # cd "Pi-hole/automated install/" # sed -i "s/lighttpd\slighttpd-fastcgi//" basic-install.sh # chmod +x basic-install.sh # ./basic-install.sh Setting up Pi-hole as a recursive DNS server solution sudo dnf install unbound 1. backup file /etc/unbound/unbound.conf mv /etc/unbound/unbound.conf /etc/unbound/unbound.conf.bak 3. Create a new unbound.conf file nano /etc/unbound/unbound.conf 4. Add the following line and save. include: "/etc/unbound/unbound.conf.d/*.conf" 5. Create /etc/unbound/unbound.conf.d/pi-hole.conf: server: # If no logfile is specified, syslog is used # logfile: "/var/log/unbound/unbound.log" verbosity: 0 interface: 127.0.0.1 port: 5335 do-ip4: yes do-udp: yes do-tcp: yes # May be set to yes if you have IPv6 connectivity do-ip6: no # You want to leave this to no unless you have *native* IPv6. With 6to4 and # Terredo tunnels your web browser should favor IPv4 for the same reasons prefer-ip6: no # Use this only when you downloaded the list of primary root servers! # If you use the default dns-root-data package, unbound will find it automatically #root-hints: "/var/lib/unbound/root.hints" # Trust glue only if it is within the server's authority harden-glue: yes # Require DNSSEC data for trust-anchored zones, if such data is absent, the zone becomes BOGUS harden-dnssec-stripped: yes # Don't use Capitalization randomization as it known to cause DNSSEC issues sometimes # see https://discourse.pi-hole.net/t/unbound-stubby-or-dnscrypt-proxy/9378 for further details use-caps-for-id: no # Reduce EDNS reassembly buffer size. # IP fragmentation is unreliable on the Internet today, and can cause # transmission failures when large DNS messages are sent via UDP. Even # when fragmentation does work, it may not be secure; it is theoretically # possible to spoof parts of a fragmented DNS message, without easy # detection at the receiving end. Recently, there was an excellent study # >>> Defragmenting DNS - Determining the optimal maximum UDP response size for DNS <<< # by Axel Koolhaas, and Tjeerd Slokker (https://indico.dns-oarc.net/event/36/contributions/776/) # in collaboration with NLnet Labs explored DNS using real world data from the # the RIPE Atlas probes and the researchers suggested different values for # IPv4 and IPv6 and in different scenarios. They advise that servers should # be configured to limit DNS messages sent over UDP to a size that will not # trigger fragmentation on typical network links. DNS servers can switch # from UDP to TCP when a DNS response is too big to fit in this limited # buffer size. This value has also been suggested in DNS Flag Day 2020. edns-buffer-size: 1232 # Perform prefetching of close to expired message cache entries # This only applies to domains that have been frequently queried prefetch: yes # One thread should be sufficient, can be increased on beefy machines. In reality for most users running on small networks or on a single machine, it should be unnecessary to seek performance enhancement by increasing num-threads above 1. num-threads: 1 # Ensure kernel buffer is large enough to not lose messages in traffic spikes so-rcvbuf: 1m # Ensure privacy of local IP ranges private-address: 192.168.0.0/16 private-address: 169.254.0.0/16 private-address: 172.16.0.0/12 private-address: 10.0.0.0/8 private-address: fd00::/8 private-address: fe80::/10 Start your local recursive server and test that it's operational: sudo service unbound restart dig pi-hole.net @127.0.0.1 -p 5335 The first query may be quite slow, but subsequent queries, also to other domains under the same TLD, should be fairly quick. You should also consider adding edns-packet-max=1232 to a config file like /etc/dnsmasq.d/99-edns.conf to signal FTL to adhere to this limit. Test validation¶ You can test DNSSEC validation using dig sigfail.verteiltesysteme.net @127.0.0.1 -p 5335 dig sigok.verteiltesysteme.net @127.0.0.1 -p 5335 The first command should give a status report of SERVFAIL and no IP address. The second should give NOERROR plus an IP address. Configure Pi-hole¶ Finally, configure Pi-hole to use your recursive DNS server by specifying 127.0.0.1#5335 as the Custom DNS (IPv4): (don't forget to hit Return or click on Save) Disable resolvconf for unbound (optional) The unbound package can come with a systemd service called unbound-resolvconf.service and default enabled. It instructs resolvconf to write unbound's own DNS service at nameserver 127.0.0.1 , but without the 5335 port, into the file /etc/resolv.conf. That /etc/resolv.conf file is used by local services/processes to determine DNS servers configured. If you configured /etc/dhcpcd.conf with a static domain_name_servers= line, these DNS server(s) will be ignored/overruled by this service. To check if this service is enabled for your distribution, run below one and take note of the Active line. It will show either active or inactive or it might not even be installed resulting in a could not be found message: sudo systemctl status unbound-resolvconf.service To disable the service if so desire, run below two: sudo systemctl disable unbound-resolvconf.service sudo systemctl stop unbound-resolvconf.service To have the domain_name_servers= in the file /etc/dhcpcd.conf activated/propagate, run below one: sudo systemctl restart dhcpcd And check with below one if IP(s) on the nameserver line(s) reflects the ones in the /etc/dhcpcd.conf file: cat /etc/resolv.conf Add logging to unbound Warning It's not recommended to increase verbosity for daily use, as unbound logs a lot. But it might be helpful for debugging purposes. There are five levels of verbosity Level 0 means no verbosity, only errors Level 1 gives operational information Level 2 gives detailed operational information Level 3 gives query level information Level 4 gives algorithm level information Level 5 logs client identification for cache misses First, specify the log file and the verbosity level in the server part of /etc/unbound/unbound.conf.d/pi-hole.conf: server: # If no logfile is specified, syslog is used logfile: "/var/log/unbound/unbound.log" verbosity: 1 Second, create log dir and file, set permissions: sudo mkdir -p /var/log/unbound sudo touch /var/log/unbound/unbound.log sudo chown unbound /var/log/unbound/unbound.log Third, restart unbound: sudo service unbound restart
  14. If the Red Hat Insights site is reflecting a different hostname simply run the following to make the insights-client check back in # insights-client --version
  15. Installing CIFS Utilities Packages To mount a Windows share on a Linux system, first you need to install the CIFS utilities package. Installing CIFS utilities on CentOS and Fedora: sudo dnf install cifs-utils Auto Mounting sudo nano /etc/fstab Add the following line to the file: # <file system> <dir> <type> <options> <dump> <pass> //WIN_SHARE_IP/share_name /mnt/win_share cifs credentials=/etc/win-credentials,file_mode=0755,dir_mode=0755 0 0 Run the following command to mount the share: mount -a Creating Credential File For better security it is recommended to use a credentials file, which contains the share username, password and domain. /etc/win-credentials The credentials file has the following format: username = user password = password domain = domain The file must not be readable by users. To set the correct permissions and ownership run: sudo chown root: /etc/win-credentials sudo chmod 600 /etc/win-credentials Create Symlink in Linux 8. Create a shortcut to your new mounted file share: Terminal way (the link will appear in the folder the terminal points to): ln -s /folderorfile/link/will/point/to /name/of/the/link
×
×
  • Create New...