Introduction
As mentioned in my post on AX.25 over Ethernet, it can frequenly be useful to transport AX.25 traffic over other networks. In the modern era the obvious candidate is the Internet.
There are two common ways of transporting AX.25 frames over Internet Protocol (IP) networks, both often referred to collectively as AXIP.
Packets can be directly encapsulated in IP frames using the protocol type 93, or inside UDP frames. The latter method is sometimes referred to as AXUDP.
AXIP has less overhead than AXUDP but can be harder to handle, particularly with domestic network equipment due to the unusual protocol number.
AXUDP comes with a little more overhead but the advantage of being the more common UDP protocol type, and using a UDP port number allows for several AXUDP connections to be handled by a single IP address.
The Linux implemenation of AX.25 over IP - ax25ipd
can handle both types of encapsulation, but I'll be using AXUDP for this example.
I have also created an AXIP Ansible Role to automate this process.
Concept
ax25ipd
can be seen as a bridge with the IP network on one side and KISS-encapsulated AX.25 frames on the other.
Rather than interacting directly with the Linux AX.25 stack, ax25ipd
connects to a serial port or pseudo terminal. This could be used to connect a hardware KISS TNC at a remote location.
In order to connect it to a Linux system, it is necessary to use an additional peice of software to simulate a serial cable, with ax25ipd
on one end and kissattach
on the other.
The ax25-tools
package provides kissnetd
for this purpose, but it is awkward to use on modern linux systems with dynamic (Unix98) pseudo terminals as it requires its output to be parsed to determine which pseudo terminal has been allocated, and ax25ipd
reconfigured to use this. A more convienent solution is to use socat
, which will manage the pseudo terminal and provide symbolic links in a fixed location for ax25ipd
and kissattach
to use.
socat
The first thing we need to do is set up the systemd service to manage socat.
Create a file at /etc/systemd/system/kiss-socat-axip.service
containing the following:
# /etc/systemd/system/kiss-socat-axip.service
[Unit]
Description=Socat interconnect for AX25 AXIP
After=network-online.target
Wants=network-online.target
[Service]
WorkingDirectory=/var/ax25
ExecStart=socat -d -d -ly pty,raw,echo=0,link=/var/ax25/pty/axip1 pty,raw,echo=0,link=/var/ax25/pty/axip2
ExecStartPost=/usr/bin/bash -c 'while ! [ -h /var/ax25/pty/axip2 ]; do sleep 1 ; done'
ExecStopPost=rm /var/ax25/pty/axip1 /var/ax25/pty/axip2
[Install]
WantedBy=multi-user.target
Create the /var/ax25/pty
directory, then enable and start the service:
$ sudo mkdir -p /var/ax25/pty
$ sudo systemctl daemon-reload
$ sudo systemctl enable kiss-socat-axip
$ sudo systemctl start kiss-socat-axip
axports
we need an entry in /etc/ax25/axports
- use your callign and a suitable SSID:
axip N0CALL-11 115200 255 7 AXIP
This defines the ax.25 port 'tnc' with its callsign, serial port speed, packet size, window size, and finally a comment describing the port.
kissattach
The kissattach
program is used to set up communication between Linux's AX.25 stack and ax25ipd
, via the socat
process.
Create a file at /etc/systemd/system/kiss-tnc@.service
containing the following:
# /etc/systemd/system/kiss-tnc@.service
[Unit]
Description=AX25 KISS TNC %I
[Service]
ExecStart=/usr/sbin/kissattach $TNC_TTY %i
ExecStop=pkill -f "kissattach $TNC_TTY %i"
ExecStartPost=/usr/bin/bash -c 'while ! /usr/sbin/kissparms -c 1 -p %i; do sleep 1; done'
TimeoutStopSec=5
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
This is a template unit file that can be used for several TNCs or AXIP tunnels.
To configure an instance for our AXIP tunnel, first enable it:
$ sudo systemctl enable kiss-tnc@axip
Then edit it:
$ sudo systemctl edit kiss-tnc@axip
Add the following to the top of the file and then save it:
[Unit]
After=kiss-socat-axip.service
After=network-online.target
[Service]
Environment=TNC_TTY=/var/ax25/pty/axip2
This tells kissattach where to fine the pseudo terminal, and systemd to wait until socat
is running before trying to run kissattach
.
As we've already started socat
, we can bring up this service now:
$ sudo systemctl start kiss-tnc@axip
ax25ipd
Next we need to configure ax25ipd. Create /etc/ax25/ax25ipd.conf with the following contents:
# /etc/ax25/ax25ipd.conf
socket udp 10095
mode tnc
device /var/ax25/pty/axip1
speed 115200
loglevel 2
broadcast NODES-0
route N1CALL axip.example.net b
The exact contents of this file will depend on the software you are running and your AXIP peer.
The socket
line dictates with UDP port will be used for this connection, and will need to match what is being sent by your peer.
The broadcast
line is a list of destinations that will be treated as broadcast traffic. NET/ROM
operation requires NODES-0
. If you are running the fbb
bulletin board software you may need to add FBB-0
.
The route
line defines your peer, and should include their callsign and internet host name or IP address. The final 'b' on the line indicates that they should receive broadcast traffic.
Finally, we need to create a systemd service for ax25ipd. Create /etc/systemd/system/ax25ipd.service containing the following:
# /etc/systemd/system/ax25ipd.service
[Unit]
Description=AX.25 over IP (AXIP) daemon
After=network.target
StartLimitInterval=0
[Service]
Type=simple
Restart=always
RestartSec=5
ExecStart=/usr/sbin/ax25ipd
[Install]
WantedBy=multi-user.target
$ sudo systemctl daemon-reload
$ sudo systemctl enable ax25ipd
$ sudo systemctl start ax25ipd
If everything has worked, you should now be able to use axcall axip N1CALL
to connect to your peer.