Child pages
  • 802.1X secured wifi installation

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

log_iddevice_usernamedevice_ipdevice_macrad_attr_NAS-IP-Addressrad_attr_NAS-Portrad_attr_Called-Station-Idrad_attr_NAS-Identifierrad_attr_Framed-MTUrad_attr_NAS-Port-Typerad_attr_EAP-Typerad_attr_Event-Timestamplog_timeevent
A unique identifier for the entry, auto-generated by MySQL   The value of the NAS-IP-Address FreeRADIUS attribute, when applicableThe value of the NAS-Port FreeRADIUS attribute, when applicableThe value of the Called-Station-Id FreeRADIUS attribute, when applicableThe value of the NAS-Identifier FreeRADIUS attribute, when applicableThe value of the Framed-MTU FreeRADIUS attribute, when applicableThe value of the NAS-Port-Type FreeRADIUS attribute, when applicableThe value of the EAP-Type FreeRADIUS attribute, when applicableThe value of the Event-Timestamp FreeRADIUS attribute, when applicableThe time when the entry is loggedDescription of the event, see the below for details.sections on each script for all possible values

 

shwl_add.sh

This script reads 10 lines on stdin, as follows:

1Username (RADIUS attribute: User-Name)
2Supplicant MAC address (RADIUS attribute: Calling-Station-Id)
3RADIUS attribute: NAS-IP-Address
4

RADIUS attribute: NAS-Port

5RADIUS attribute: Called-Station-Id
6RADIUS attribute: NAS-Identifier
7RADIUS attribute: Framed-MTU
8RADIUS attribute: NAS-Port-Type
9RADIUS attribute: EAP-Type
10RADIUS attribute: Event-Timestamp

The supplicant MAC address is used in the script, the remaining values are simply logged into the MySQL database. Some sanity check is performed on the username before the script continues. The supplicant MAC address is processed so as to obtain it in both of the following formats regardless of the format the NAS specified it in: filename friendly version: 0123456789ab, normal version: 01:23:45:67:89:ab. The script then checks if a file named as the filename friendly version of the supplicant MAC address already exists (referred to by the script as an IP file). If it does not, the script runs an ARP scan on the configured network interface and in the resulting table, looks for the IP address matching the specified supplicant MAC address. In case no such device is found, it repeats the scan a configurable amount of times at a configurable interval before giving up. Once a matching IP is found some amount of sanity check is performed on the scan results (e.g. to detect multiple MACs being used by the found IP), and then the event is logged into MySQL with "connect" mentioned in the 'event' column, the found IP is added to the configured shorewall dynamic zone, and a file named as the filename friendly version of the supplicant MAC address is created containing the device's IP, and a file named as the device's IP (referred to by the script as a timestamp file) is created containing the present timestamp. In case adding the IP address to the shorewall dynamic zone is not successful, the script waits a configurable amount of time, and then attempts a second time, after which it gives up (it was observed that it might happen that FreeRADIUS starts earlier in the boot process than Shorewall, and if this script is started during that timeframe the shorewall add command fails). In case the IP file is already present, the script simply logs the event to MySQL with "re-auth" mentioned in the 'event' column and re-writes the timestamp file with the present timestamp. In case an error is encountered, the script logs the error to MySQL mentioning "err-add-N" (where N is the error number) in the 'event' column, populating the remaining columns with their respective information as may be available at the time of the error, and exits immediately, returning the error number as exit code. In case access is available to the script's stdout and stderr, a description of the error message is also printed (and the script is quite verbose about what's happening), in case not, it is possible to look in the script's code for calls to the shwl_add_error_message_close() function, identify the call where the error number in question is passed to the function, and the error description can be found in the same function call. The configurable options can be found at the top of the script. The username is logged into the 'device_username' column, the IP address found during the scan is logged in the 'device_ip' column, the above mentioned normal version of the supplicant MAC address is logged in the 'device_mac' column, and the remaining RADIUS attributes are logged in the columns with the respective names.

This script is intended to be run by script_launcher.py (below mentioned).

shwl_del.sh '@@@'

This script loops through all the IP addresses present in the configured shorewall dynamic zone, reads their corresponding timestamp file (see shwl_add.sh description) and checks whether the configured amount of time has elapsed since. If it has, it logs the event to MySQL specifying "expire" in the 'event' column, removes the IP from the shorewall dynamic zone, deletes the timestamp file and searches for files (although there should be only one) containing the IP address (to find the IP file, see shwl_add.sh description) and deletes them. In the unexpected case that no timestamp file is found for a given IP or it does not contain a valid timestamp, the same actions are taken as when the configured amount of time has elapsed, but "untracked" is mentioned in the 'event' column instead of "expire". In case an error is encountered, the script logs the error to MySQL mentioning "err-del-N" (where N is the error number) in the 'event' column, populating the remaining columns with their respective information as may be available at the time of the error, but continues execution. At the end, it returns the error number as exit code, or, in case there were multiple errors, 127. In case access is available to the script's stdout and stderr, a description of the error message is also printed (and the script is quite verbose about what's happening), in case not, it is possible to look in the script's code for calls to the shwl_del_error_message() function, identify the call where the error number in question is passed to the function, and the error description can be found in the same function call. The configurable options can be found at the top of the script. No username is logged into the 'device_username' column, the IP address being processed is logged in the 'device_ip' column, a comma separated list of the IP files is logged in the  'device_mac' column, or the text "/// no-ip-files ///" in case no IP files were present, or the text "/// err-del-N ///" (where N is the error number) in case an error occurred while searching for the file(s), and the rad_attr_* columns are left empty. The text "/// n/a ///" may be present in the 'device_ip' and 'device_mac' columns if this information is not applicable.

This script is intended to be run by crontab at a regular interval.

script_launcher.py

 

pam_to_mysql_update.sh

Installation

...