PackeTsar / radiuid

An application to extract User-to-IP mappings from RADIUS accounting data and send them to Palo Alto firewalls for use by the User-ID function.
http://packetpushers.net/radiuid/
GNU General Public License v3.0
34 stars 10 forks source link

RadiUID RadiUID

An application to extract User-to-IP mappings from RADIUS accounting data and send them to Palo Alto firewalls for use by the User-ID function.


VERSION

The version of RadiUID documented here is: v2.5.0


TABLE OF CONTENTS

  1. What is RadiUID?
  2. How it Works
  3. Screenshots
  4. Requirements
  5. Tested Environments
  6. Docker Install Instructions
  7. OS Install Instructions
  8. Command Interface
  9. Timeout Tuning
  10. The Munge Engine
  11. 1.1.0 TO 2.0.0 Updates
  12. 2.0.0 TO 2.0.1 Updates
  13. 2.0.1 TO 2.1.0 Updates
  14. 2.1.0 TO 2.2.0 Updates
  15. 2.2.0 TO 2.2.1 Updates
  16. 2.2.1 TO 2.3.0 Updates
  17. 2.3.0 TO 2.3.1 Updates
  18. 2.3.1 TO 2.3.2 Updates
  19. 2.3.2 TO 2.4.0 Updates
  20. 2.4.0 TO 2.4.1 Updates
  21. 2.4.1 TO 2.4.2 Updates
  22. 2.4.2 TO 2.4.3 Updates
  23. 2.4.3 TO 2.5.0 Updates
  24. Upgrade Processes
  25. Docker Files
  26. Contributing

WHAT IS RADIUID

User-based firewall filtering is a novel and attractive concept which can often be difficult to implement due to the requirement by firewalls to map IP addresses to users. One common method of getting user-to-IP mapping information for your firewall is to install a log-reading agent onto an Active Directory domain controller which can look over transaction logs and send the proper information to the firewall, but this assumes user endpoints interact and authenticate directly with the domain controllers, or that you have Active Directory at all!

RadiUID is a Linux-based application built to take everyday RADIUS accounting information generated by RADIUS authenticators like wireless systems, firewalls, etc (which contains username and IP info) and send that ephemeral IP and username mapping info to a Palo Alto firewall to be used by the User-ID system for user or group-based access-list filtering, or intelligent reporting.


HOW IT WORKS

RadiUID uses FreeRADIUS as a backend service to listen on RADIUS accounting ports (typically TCP\UDP 1813) and write recieved accounting information to accounting logs.

RadiUID then parses these logs, pulls down the User and IP mapping information and pushes those mappings to the Palo Alto firewall using the published RESTful XML API.

RadiUID runs as a system service on Linux and is very easy to configure and use. All configuration and interaction with RadiUID is via command line on the Linux BASH shell. Once the installer completes, RadiUID can be invoked from the command shell by typing radiuid followed by the desired command. Hit the [TAB] key for command options or hit [ENTER] for the list of options!


SCREENSHOTS

The main list of CLI command options RadiUID

Output from the show log command RadiUID

Output from the show config command RadiUID

Output from the show config set command RadiUID

Pushing a mapping using the push command and checking the current mappings using the show mappings command RadiUID

Test your munge rule-set using the request munge-test command RadiUID


REQUIREMENTS

OS: Any modern Debian, RHEL distro (CentOS 6 or 7, Ubuntu 14 or 16...), or Docker container host

Interpreter: Python 2.7.X (Also works on Python 2.6.6 and up)

PAN-OS Version: 6.X, 7.X, and 8.X have been tested


TESTED ENVIRONMENTS

RadiUID has been written and tested in a few environments to date as it was purpose-built for a specific environment, but it should be very adaptable as it uses standardized RADIUS accounting to source user information and the published API to push that info to Palo Alto firewalls.

RadiUID has currently been tested with the following Operating Systems, RADIUS servers, and authenticators

Operating Systems: CentOS 7, CentOS 6, Ubuntu 16 Server, Ubuntu 14 Server, Docker 1.10.3

Identity Systems: JumpCloud RADIUS service, Windows 2012 NPS Server (with Active Directory)

Authenticators: Meraki Wireless Access Points, Cisco Wireless (Controller-based), Ruckus Zonedirector


DOCKER INSTALL INSTRUCTIONS

Downloading and running RadiUID on a Docker host is the fastest and easiest way to get it up and running. There are two versions of the RadiUID image maintained on Docker Hub: an image with SSH, and an image without SSH. The image with SSH has the SSH server installed and pre-configured with a login username and password. All you have to do is change the password. The Dockerfile build scripts which were used to build the images are available in the Docker Files section in case you want to perform the build yourself.

  1. From the Docker host, download and run the image in interactive mode
    1. To run the image with SSH: docker run -it -p 1813:1813/udp -p 1813:1813/tcp -p 222:22/tcp --name radiuid -t packetsar/radiuid-ssh:latest
    2. To run the image without SSH: docker run -it -p 1813:1813/udp -p 1813:1813/tcp --name RADIUID -t packetsar/radiuid:latest
  2. If you ran the image with SSH: The default SSH username and password is root\radiuid. Run the command passwd root to change the SSH password.
    1. NOTE: The command above to run the container with SSH publishes the SSH service on TCP port 222. You will need to connect to that port with your SSH client to get access to the container.
  3. Run the command radiuid show config set to see the default configuration.
  4. Run the radiuid clear target all command to delete the firewall target configurations, then use the radiuid set target [parameters] command to configure the application with your Palo Alto target firewall paramaters.
  5. Run the radiuid set client [parameters] command to configure FreeRADIUS to accept RADIUS accounting data from your RADIUS authenticators.
  6. Once configuration is complete, run the radiuid service all restart to restart the services so the new configuration takes effect.
  7. Take a look at your logs using the radiuid show log command to see what the application is doing.
  8. To exit your interactive session with the Docker container, hold down CTRL and hit P then Q.

OS INSTALL INSTRUCTIONS

The install of RadiUID is very quick and straightforward using the built-in installer. NOTE: You need to be logged in as root or have sudo privileges on the system to install RadiUID

  1. Install OS with appropriate IP and OS settings and update to latest patches (recommended)
  2. Install the Git client (unless you already have the RadiUID files): sudo yum install git -y or sudo apt install git -y
  3. Clone the RadiUID repo to any location on the box: git clone https://github.com/PackeTsar/radiuid.git
  4. Change to the directory where the RadiUID main code file (radiuid.py) and config file (radiuid.conf) are stored: cd radiuid
    • (OPTIONAL) Change to the development branch (perform this step only if you are prepared for a version which is under active development and may have broken features): git checkout devX.X.X
  5. Run the RadiUID program in install mode to perform the installation: sudo python radiuid.py install
    • NOTE: Make sure that you have the .conf file in the same directory as the .py directory for the initial install
  6. Follow the on-screen prompts to install FreeRADIUS and the RadiUID application
    • The installer should let you know if everything installed correctly and services are running, but in the next section are the CLI commands you can run to check up on it.

COMMAND INTERFACE

The RadiUID system is meant to run in the background as a system service: constantly checking for new RADIUS accounting data and pushing User-ID mapping information to the firewall, but it also has an easy to use command interface. This command interface is meant to be used for regular maintenance, troubleshooting, and operation of the system.

Below is the CLI guide for the RadiUID service.

You can see this guide by typing 'python radiuid.py' (before installation) or 'radiuid' (after installation) and hitting ENTER.

-------------------------------------------------------------------------------------------------------------------------------
                     ARGUMENTS                    |                                  DESCRIPTIONS
-------------------------------------------------------------------------------------------------------------------------------

 - run                                            |  Run the RadiUID main program in shell mode begin pushing User-ID information
-------------------------------------------------------------------------------------------------------------------------------

 - install                                        |  Run RadiUID Install/Maintenance Utility
-------------------------------------------------------------------------------------------------------------------------------

 - show log                                       |  Show the RadiUID log file
 - show acct-logs                                 |  Show the log files currently in the FreeRADIUS accounting directory
 - show run (xml | set)                           |  Show the RadiUID configuration in XML format (default) or as set commands
 - show config (xml | set)                        |  Show the RadiUID configuration in XML format (default) or as set commands
 - show clients (file | table)                    |  Show the FreeRADIUS clients and config file
 - show status                                    |  Show the RadiUID and FreeRADIUS service statuses
 - show mappings (<target> | all | consistency)   |  Show the current IP-to-User mappings of one or all targets or check consistency
-------------------------------------------------------------------------------------------------------------------------------

 - set logfile                                    |  Set the RadiUID logfile path
 - set radiuslogpath <directory path>             |  Set the path used to find FreeRADIUS accounting log files
 - set acctlogcopypath <directory path>           |  Set the path where RadiUID should copy acct log files before deletion
 - set maxloglines <number-of-lines>              |  Set the max number of lines allowed in the log ('0' turns circular logging off)
 - set userdomain (none | <domain name>)          |  Set the domain name prepended to User-ID mappings
 - set timeout                                    |  Set the timeout (in minutes) for User-ID mappings sent to the firewall targets
 - set looptime                                   |  Set the waiting loop time (in seconds) to pause between checks of the RADIUS logs
 - set tlsversion (1.0 | 1.1 | 1.2)               |  Set the version of TLS used for XML API communication with the firewall targets
 - set radiusstopaction (clear | ignore | push)   |  Set the action taken by RadiUID when RADIUS stop messages are received
 - set client (ipv4|ipv6) <ip-block> <secret>     |  Set configuration elements for RADIUS clients to send accounting data FreeRADIUS
 - set munge <rule>.<step> [parameters]           |  Set munge (string processing rules) for User-IDs
 - set target <hostname>:<vsys-id> [parameters]   |  Set configuration elements for existing or new firewall targets
-------------------------------------------------------------------------------------------------------------------------------

 - push (<hostname>:<vsys-id> | all) [parameters] |  Manually push a User-ID mapping to one or all firewall targets
-------------------------------------------------------------------------------------------------------------------------------

 - tail log (<# of lines>)                        |  Watch the RadiUID log file in real time
-------------------------------------------------------------------------------------------------------------------------------

 - clear log                                      |  Delete the content in the log file
 - clear acct-logs                                |  Delete the log files currently in the FreeRADIUS accounting directory
 - clear client (<ip-block> | all)                |  Delete one or all RADIUS client IP blocks in FreeRADIUS config file
 - clear munge (<rule> | all) (<step> | all)      |  Delete one or all munge rules in the config file
 - clear target (<hostname>:<vsys-id> | all)      |  Delete one or all firewall targets in the config file
 - clear mappings [parameters]                    |  Remove one or all IP-to-User mappings from one or all firewalls
-------------------------------------------------------------------------------------------------------------------------------

 - edit config                                    |  Edit the RadiUID config file
 - edit clients                                   |  Edit RADIUS client config file for FreeRADIUS
-------------------------------------------------------------------------------------------------------------------------------

 - service [parameters]                           |  Control the RadiUID and FreeRADIUS system services
-------------------------------------------------------------------------------------------------------------------------------

 - request [parameters]                           |  Make system-level changes for RadiUID service
-------------------------------------------------------------------------------------------------------------------------------

 - version                                        |  Show the current version of RadiUID and FreeRADIUS
-------------------------------------------------------------------------------------------------------------------------------

TIMEOUT TUNING

RadiUID pushes ephemeral User-ID information to the firewall whenever new RADIUS accounting information is recieved and by default sets a timeout of 60 minutes. If this accounting information comes from a wireless system (where most devices re-authenticate regularly) then you may be able to tune down that timeout to make the mapping information expire more quickly. If the RADIUS authenticator is something like a VPN concentrator (where re-authentication doesn't typically happen), then you may want to turn up the timeout period. Either way, you should expect to have to play with the timeout settings to make sure your firewalls are not prematurely expiring User-ID data from their mapping tables.


THE MUNGE ENGINE

The Munge Engine is a rule-based string processor which is used in RadiUID to filter and process User-IDs based on rules you configure. The munge feature was introduced in version 2.2.0.



Updates


UPDATES IN V1.1.0 --> V2.0.0

ADDED FEATURES:


UPDATES IN V2.0.0 --> V2.0.1

BUG FIXES:


UPDATES IN V2.0.1 --> V2.1.0

ADDED FEATURES:

BUG FIXES:


UPDATES IN V2.1.0 --> V2.2.0

ADDED FEATURES:

BUG FIXES:


UPDATES IN V2.2.0 --> V2.2.1

BUG FIXES:


UPDATES IN V2.2.1 --> V2.3.0

ADDED FEATURES:


UPDATES IN V2.3.0 --> V2.3.1

BUG FIXES:


UPDATES IN V2.3.1 --> V2.3.2

BUG FIXES:


UPDATES IN V2.3.2 --> V2.4.0

ADDED FEATURES:

BUG FIXES:

DEFAULT BEHAVIOR CHANGES: With the exposure of the tlsversion and radiusstopaction elements to configuration, best-practices have also been set for those values. The legacy behaviors are also supported and configurable if desired.


UPDATES IN V2.4.0 --> V2.4.1

BUG FIXES:


UPDATES IN V2.4.1 --> V2.4.2

BUG FIXES:


UPDATES IN V2.4.2 --> V2.4.3

BUG FIXES:


UPDATES IN V2.4.3 --> V2.5.0

ADDED FEATURES:

BUG FIXES:


UPGRADE PROCESSES

Upgrading from v2.X to v2.5.0:

  1. Perform a radiuid show config set command and save the set commands displayed in a safe place (just in case)
  2. Download the code from the GitHub repo by using git clone https://github.com/PackeTsar/radiuid.git
    • If the "radiuid" folder already exists, you can use git to update the clone cd radiuid/; git pull
  3. Move to the radiuid folder created by git using the cd radiuid/ command
  4. Change to the latest branch using the command git checkout v2.5.0
  5. Perform a quick reinstall/update of RadiUID using the command python radiuid.py request reinstall keep-config
  6. Type in CONFIRM and hit ENTER to confirm you want to perform the reinstall
  7. Once the installer exits, you should run radiuid show config set and see your configuration from before.
  8. Check that you are running the new version by issuing radiuid version
  9. Perform a radiuid service all restart command to restart RadiUID to use the new app version
    • NOTE: The RadiUID service will continue running in the background throughout the install/upgrade process. It is not until you restart/stop the service that the new version and configuration will take effect.
  10. You may also want to log out of the shell and back in to activate any new auto-complete functions.

Upgrading from v1.X to v2.X.X:

  1. Change the name of your config file (/etc/radiuid/radiuid.conf) by issuing the command mv /etc/radiuid/radiuid.conf /etc/radiuid/radiuid.conf.backup
  2. Grab the contents to have them handy during the install of the new version more /etc/radiuid/radiuid.conf.backup
  3. Download the v2.X.X code from the GitHub repo by using git clone https://github.com/PackeTsar/radiuid.git
    • If the "radiuid" folder already exists, you may want to use git to update the clone cd radiuid/; git pull
  4. Move to the radiuid folder created by git using the cd radiuid/ command
  5. Perform a full install of RadiUID using the command python radiuid.py install
  6. Follow the prompts and fill out the appropriate information using the information from the old configuration file
  7. Once the installer exits, you should run radiuid show config set and see your configuration.
  8. Perform a radiuid service all restart command to restart RadiUID to use the new app version

DOCKERFILES

These are the dockerfile script files used to build the SSH and non-SSH Docker images hosted on Docker Hub. You can use these on a Docker host to build your own RadiUID image if you don't want to download the pre-made one from Docker Hub.

With SSH

FROM centos:latest
MAINTAINER John W Kerns "jkerns@packetsar.com"

### Install and configure SSH Server for SSH access to container ###
RUN yum install -y openssh openssh-server openssh-clients sudo passwd
RUN sshd-keygen
RUN sed -i "s/UsePAM.*/UsePAM yes/g" /etc/ssh/sshd_config
RUN sed -i "s/#UsePrivilegeSeparation.*/UsePrivilegeSeparation no/g" /etc/ssh/sshd_config
RUN useradd admin -G wheel -s /bin/bash -m
RUN echo 'root:radiuid' | chpasswd
RUN echo '%wheel ALL=(ALL) ALL' >> /etc/sudoers

### Download and install RadiUID from latest release ###
RUN curl -sL https://codeload.github.com/PackeTsar/radiuid/tar.gz/2.5.0 | tar xz
RUN cd radiuid-2.5.0;python radiuid.py request reinstall replace-config no-confirm
RUN cd radiuid-2.5.0;python radiuid.py request freeradius-install no-confirm

### Expose ports and provide run commands ###
EXPOSE 1813/udp
EXPOSE 1813/tcp
EXPOSE 22/tcp
CMD radiusd & radiuid run >> /etc/radiuid/STDOUT & /usr/sbin/sshd >> /etc/radiuid/SSH-STDOUT & /bin/bash

Without SSH

FROM centos:latest
MAINTAINER John W Kerns "jkerns@packetsar.com"

### Download and install RadiUID from latest release ###
RUN curl -sL https://codeload.github.com/PackeTsar/radiuid/tar.gz/2.5.0 | tar xz
RUN cd radiuid-2.5.0;python radiuid.py request reinstall replace-config no-confirm
RUN cd radiuid-2.5.0;python radiuid.py request freeradius-install no-confirm

### Expose ports and provide run commands ###
EXPOSE 1813/udp
EXPOSE 1813/tcp
CMD radiusd & radiuid run >> /etc/radiuid/STDOUT & /bin/bash

Docker Build

To build your own Docker image: follow the instructions below

  1. After installing Docker (yum install docker or an equivalent) and starting it up (systemctl start docker or an equivalent), create a new file called "Dockerfile": vi Dockerfile
  2. Paste in the text from one of the above scripts: Hit i to get into insert mode, and paste in the text, then hit ESC to leave insert mode, then type in :wq and hit ENTER to save and exit
  3. Build the Docker image using the command docker build -t mydockerradiuidimage . Docker will run through the script and install RadiUID and FreeRADIUS.
  4. You can now run the docker images command and see your new image
  5. To run the image, issue the command docker run -it -p 1813:1813/udp -p 1813:1813/tcp -p 222:22/tcp --name radiuid -t mydockerradiuidimage
  6. You will enter into interactive mode in the container where you can run radiuid commands. After you are done in the container, hit CTRL + P + Q to exit interactive mode but leave the container running.
  7. If you used the "With SSH" Dockerfile script, then you should be able to SSH to the Docker host's IP on port 222 to directly access the container.
  8. If you want to save this image to Docker Hub, use the command docker push mydockerradiuidimage.

CONTRIBUTING

If you would like to help out by contributing code or reporting issues, please do!

Visit the GitHub page (https://github.com/PackeTsar/radiuid) and either report an issue or fork the project, commit some changes, and submit a pull request.