Direwolf and Jnos (review)

In the previous post about Direwolf and jnos i use Direwolf-1.3 and does not know about the SERIALKISS port.
John WQ6N point it out to me… Tnx John WQ6N. Nice one.
Read the previous post.
So maybe I wrote that script for nothing. This is working pretty simple 🙂

In Direwolf 1.5-beta is it possible to use SERIALKISS to connect com to com.
I have try to use a PTY pair created with socat.

# Create pty pair
socat -d -d -ly PTY,link=/dev/ttyq1 PTY,link=/dev/ptyq1 &
sleep 2
# Start Direwolf
direwolf -d kn -c /direwolf/direwolf.conf &> /var/log/direwolf.log >/dev/tty3 &
sleep 2

Direwolf.conf
SERIALKISS  /dev/ttyq1 19200

# Jnos autoexec.nos
attach asy ptyq1 - ax25 ax0 4096 256 19200

Fireup Jnos
./jnos -C -g2 -u3 -f nos.cfg -i

I use conspy to look at the output of Direwolf. apt-get install conspy
Use it just like this “conspy 3” The number 3 stands for the tty were Direwolf is running on /dev/tty3.
Hit the escape button a couple of times to exit.

Here is the output of Direwolf

>>> Data frame to KISS client application, port 0, total length = 82
  000:  c0 00 92 88 40 40 40 40 e0 9c 98 70 b4 b4 8a 60  ....@@@@...p...`
  010:  ae 92 88 8a 62 40 63 03 f0 43 6f 6e 6e 65 63 74  ....b@c..Connect
  020:  20 4e 4c 36 5a 5a 45 20 66 6f 72 20 74 68 65 20   PD2LT-6 for the
  030:  4a 4e 4f 53 20 43 6f 6e 76 65 72 73 20 28 6c 69  JNOS Convers (li
  040:  6e 6b 65 64 20 77 69 74 68 20 6f 74 68 65 72 73  nked with others
  050:  29 c0

Ok that is working quit well.
I start Direwolf with the option “-d kn” So you can look at the kiss communication between Direwolf and Jnos.

Some text out of the User-Guide.pdf.
“Up to 3 concurrent TCP KISS client applications are allowed at the same time.
You can raise this limit by increasing the value of MAX_NET_CLIENTS, in source file kissnet.c and recompiling.”

Whoooo thats nice up to 3 (and more) applications can connect to Direwolf on the KISSPORT.
And there is also the AGW and the SERIALKISS port. Men where do I start.

John WQ6N

John WQ6N has found something that is useful. He use a Legacy BSD pseudo pair.
There are no Legacy BSD pseudo pairs in Linux any more. But it is possible to create some.

/etc/default/grub:
Change line from:
GRUB_CMDLINE_LINUX=""
to:
GRUB_CMDLINE_LINUX="pty.legacy_count=10"
(Where 10 is the number of pty legacy devices you require.)
This created 10 ptypX/ttypX terminal pairs.

After editing the grub file run the command “update-grub” and reboot.

So now it`s time to set Direwolf and Jnos to use the pty Legacy devices.

The Direwolf SERIALKISS 
SERIALKISS /dev/ptyp0 19200

The associated JNOS2 attach line:
attach asy ttyp0 - ax25 hfgw 4096 256 19200

Direwolf and Jnos

#!/bin/bash
# 6 march 2018
# Wrote a small script to get the shittie PTS to a file where its belongs.
# Yes you can also use the agw driver from Direwolf for Jnos.
# Now its also possible to "sed" the right PTS to your ax25 start file
#
# socat -d -d -lf /tmp/socat.pts PTY,link=/tmp/kisstnc TCP4:127.0.0.1:8001 &
# sleep 2
# grep -o "/dev/pts/." /tmp/socat.pts > /tmp/devs.pts
# attachthem () {
# read PTS1
# sed -i "s,kissattach -m 256 /dev/.*$,kissattach -m 256 $PTS1 ax0 44.137.31.73," /etc/ax25/ax-start
#
# }
#
# tail -n 1 /tmp/devs.pts | attachthem
# rm /tmp/socat.pts
# rm /tmp/devs.pts
# sleep 3
#
# Or use it with (X)net.
# sed -i "s,attach sdev4 kiss 4 1 19200 /dev/.*$,attach sdev4 kiss 4 1 19200 $PTS1," /usr/local/xnet/AUTOBOOT.NET
#
# Or with BPQ
# sed -i "s,COMPORT=/dev/.*$,COMPORT=$PTS1," /usr/local/linbpq/bpq32.cfg
#
# Oo well maybe work this better
# IPADDR=127.0.0.1
# TCPPORT=8001
#
# Yes there are many way`s to do this, but i had some fun to play with it.
# Maybe it is useful for someone.
#################################################################################################

The scipt…. Small but work quit well

#!/bin/bash
echo "Starting direwolf with socat for jnos/ax25"
# Set the path to direwolf and some stuff
PATH=/direwolf:/usr/bin:/bin:/usr/local/bin
# Start Direwolf
direwolf -c /direwolf/direwolf.conf &> /var/log/direwolf.log >/dev/tty3 &
sleep 3
# Socat kisstnc link with a PTS
socat -d -d -lf /tmp/socat.pts PTY,link=/tmp/kisstnc TCP4:127.0.0.1:8001 &
sleep 2
grep -o "/dev/pts/." /tmp/socat.pts > /home/pd2lt/jnos/spool/ptmx_radio.cfg
echo "Direwolf is connect to" `cat /home/pd2lt/jnos/spool/ptmx_radio.cfg`
echo "Now Jnos is ready to Rock and Roll :)"
rm /tmp/socat.pts
# Dont delete ptmx_radio.cfg before starting Jnos
rm /home/pd2lt/jnos/spool/ptmx_radio.cfg
sleep 1

This is what i found in the change.log of Jnos

Better support for PTY98 (/dev/ptmx, /dev/pts/N) pseudo devices. Bob (VE3TOK)
   asked for this a long time ago, so I figured I better get it implemented.

   Note : Technically one can use the new jnos 'attach baycom' and go direct to
   a kernel KISS type interface, meaning you don't need to run an intermediary
   program (kissattach or net2kiss) anymore. Try it, let me know how it works.

   COMPILE : Make sure '#define JNOSPTY98' exists in your config.h file.

   The best way for me to show how this feature works is by example. One way of
   getting JNOS to use a linux AX25 device is through the 'kissattach' program,
   but get the one from F6BVP (it has a mod that actually outputs the name of
   the slave device after you run the program). The stock ax25 utilities will
   not tell you that (you have to look for a new /dev/pts/N to appear then).

      kissattach /dev/ptmx radio > /jnos/spool/ptmx_radio.cfg

   The issue here is you don't know what slave device you will get, it could
   change each time you run kissattach, there may be no consistent device name
   for you to depend on when running 'attach asy' in the JNOS autoexec.nos.

   Now in JNOS (autoexec.nos), suppose we have this entry below :

      attach asy ptmx_radio - ax25 ax0 4096 256 9600

   I have added a feature where if the 3rd argument starts with 'ptmx_', then
   JNOS will look for a corresponding *.cfg file, and extract the slave device
   name from it, and then attach using that instead of the original argument.

This is some monitor output of Direwolf.

Dire Wolf version 1.3

Reading config file /direwolf/direwolf.conf
Audio device for both receive and transmit: plughw:0,0 (channel 0)
Channel 0: 1200 baud, AFSK 1200 & 2200 Hz, E+, 44100 sample rate.
Ready to accept AGW client application 0 on port 8000 …
Use -p command line option to enable KISS pseudo terminal.
Ready to accept KISS client application on port 8001 …

Connected to KISS client application …

[0L] PD2LT-2>NODES:<0xfe>
[0L] PD2LT-9>NODES:<0xff>LAPNOS
[0L] PD2LT-9>NODES:<0xfe>LAPNOS

PD2LT-2 audio level = 14(3/3) [NONE] |||||||__
[0.3] PD2LT-2>NODES:<0xfe>

PD2LT-9 audio level = 14(3/3) [NONE] ||||||||_
[0.3] PD2LT-9>NODES:<0xff>LAPNOS

Jnos link local

Setup a local link in jnos to uronode.

root@linux:/etc/ax25# cat axports
# /etc/ax25/axports
#
# The format of this file is:
#
# name  callsign        speed   paclen  window  description
# ----- -----------     ------- ------- ------- ---------------------------
ax6     PD2LT-7         19200   256     2       Link local Jnos pd2lt

root@linux:/etc/ax25# cat nrbroadcast
# /etc/ax25/nrbroadcast
#
# The format of this file is:
#
# ax25_name min_obs def_qual worst_qual verbose
#
ax6     5       203     192     1

# create socat device (jnos-uro)
socat -d -d -ly PTY,link=/dev/ttyq4 PTY,link=/dev/ptyq4 &
sleep 2
kissattach -m 256 /dev/ptyq4 ax6 44.137.31.73
ifconfig ax6 44.137.31.73 netmask 255.255.255.224 up
sleep 1

Autoexec.nos

attach asy ttyq4 - ax25 lap 4096 256 19200
ifconfig lap description "Link uronode"
#
ifconfig lap ax25 maxframe 2
ifconfig lap ax25 paclen 256
#ifconfig lap ipadd 44.137.31.81
#
at 15 "mbox kick pi8lap+"
#
arp eaves lap on
arp poll lap on

ip hp lap on
mbox mport lap on

# pi1lap
ax25 bc lap on
ax25 heard lap
ax25 hport lap on
ax25 bcport lap on

netrom  interface       lap 203 201
netrom  bcpoll          lap
netrom  bcnodes         lap
inp     ifaces          lap

trace lap 0111

 

Jnos rewrite

Setup Jnos rewrite

# Handle local sysop, and sysop bulls
pd2lt@* pd2lt
pi1lap@* pd2lt
sysop pd2lt
sysop@pd2lt* pd2lt
sysop@* sysop
*@sysop sysop
###############

#
# Now pass specific bulletins on to our areas
tcpip@* tcpip
wanted@* wanted
want@* wanted
need@* wanted
sale@* sale
4sale@* sale
trade@* sale
swap@* sale
dx@* dx
amsat@* amsat
arrl@* arrl
nldnet@* nldnet
nld@* nldnet
ww@* ww
eu@* eu
latnet@* latnet
baycom@* baycom
#
*@amsat amsat
*@arrl arrl
*@arl arrl
*@ww ww
*@nldnet nldnet
*@eu eu
*@jpn jpn
*@ita ita
*@dl dl
*@gbr gbr
*@noord noord
*@vknet vknet
*@usa usa
*@nld nld
*@ww ww
*@lunet lunet
*@can can
*@ca ca
#
# Anything else means we must add more, above
*@* check

# Try to handle addressing mistakes by mbox users!
*/* check
*\* check
*&* check
*.* check
#
K

 

Jnos axip link

Setup Jnos axip link

# Attach AXIP to SV1CMG
attach axip cmg 256 44.154.142.2 sv1cmg-6
ifconfig cmg description "AXIP to LAMNOS:SV1CMG-6 Jnos"
ifconfig cmg ax25 maxframe 7
ifconfig cmg ax25 paclen 256
#
at 30 "mbox kick sv1cmg+"
#
arp eaves cmg on
arp poll cmg on
mbox mport cmg on

# sv1cmg
ax25 bc cmg on
ax25 heard cmg
ax25 hport cmg on
ax25 bcport cmg on

netrom  interface       cmg 203 201
netrom  bcpoll          cmg
netrom  bcnodes         cmg
inp     ifaces          cmg

trace cmg 0111

 

Jnos network interface

Setup a Jnos network Interface

attach tun tun0 1500 0
ifconfig tun0 ipaddress 44.137.31.67
ifconfig tun0 broadcast 44.137.31.95
ifconfig tun0 netmask 255.255.255.224
ifconfig tun0 mtu 1500
pause 2
shell ifconfig tun0 44.137.31.82 pointopoint 44.137.31.67 mtu 1500 up
pause 1
shell ip route add 44.137.31.67 dev tun0 table 44 src 44.137.31.82
shell echo 1 >/proc/sys/net/ipv4/ip_forward
pause 1
shell /usr/sbin/arp -i eth0 -Ds 44.137.31.67 eth0 pub

arp eaves tun0 on
arp poll tun0 on
arp maxq 10

ip hp tun0 on
route add default tun0 44.137.31.82

 

sexy ifconfig

ax0 voor link fbb
ax1 voor link Convers
eth0 Dit is de Baas
sl0 voor (X)net
tun0 voor Jnos
tunl0 voor ampr Gateway

Om te zorgen dat de data gaat lopen hebben we een aantal ip routes nodig.

ip route add 44.137.31.70 dev sl0 table 44 src 44.137.31.69
ip route add 44.137.31.67 dev tun0 table 44 src 44.137.31.82

En voor de iptables firewall
$ipt -A FORWARD -i tunl0 -o sl0 -j ACCEPT
$ipt -A FORWARD -i sl0 -o tunl0 -j ACCEPT
$ipt -A FORWARD -i tunl0 -o tun0 -j ACCEPT
$ipt -A FORWARD -i tun0 -o tunl0 -j ACCEPT

Met deze bovenstaande regels heeft iedereen toegang tot sl0 en tun0

Tcp Access Control Jnos

Jnos works with an access control list. Here a small example what you can put in there. There are things double in it, this is just an example what is possible

# ACCESS CONTROL
#===============
#Allow a specific Hostname (eerst ff wachten "now+0001" tot de dns online is)
at now+0001 "tcp access permit packet-radio.net all"
# Localhost (altijd handig)
tcp access permit 127.0.0.1 all
# Ampr.org (Compleet ampr.org netwerk)
tcp access permit 44.0.0.0/8 all
# Nederlands Ampr.org netwerk
tcp access permit 44.137/32 all
# Eigen Ampr.org netwerk
tcp access permit 44.137.31.64/27 all
# Lokaal netwerk
tcp access permit 192.168.1.0/24 all
# Lokaal netwerk met toegewezen poort
tcp access permit 192.168.1.175/24 25 110
# Friendjes :)
tcp access permit 82.176.45.213 all
# blacklist bad logins for 15 minutes (900 seconds)
mbox blacklist 900
# run expiry process every 20 minutes
tcp access expiry 20
# Acces deny (Bad boy)
tcp access deny 81.21.45.213
# Subnet access to ports 1 through 25,
tcp access permit 23.1.46/24 1 25
tcp clean

 

Xnet axudp link Jnos

The axudp link from xnet to jnos has caused a lot of problems.
But he is up and running … Here the explanation.

In the line “attach axudp xnet 256 192.168.1.112” (jnos) is the secret.
This must therefore “not” refer to the ip address of xnet like you
have indicated in ip.net at myip, but to the IP address of Linux itself.
So the ip address of (for example) eth0

Autoexec.nos (Jnos)

attach tun tun0 1500 0
#
ifconfig tun0 ipaddress 192.168.1.222
ifconfig tun0 netmask 255.255.255.0
ifconfig tun0 mtu 1500

shell ifconfig tun0 192.168.1.221 pointopoint 192.168.1.222 mtu 1500 up
pause 2
shell echo 1 >/proc/sys/net/ipv4/ip_forward
shell /usr/sbin/arp -i eth0 -Ds 192.168.1.222 eth0 pub

attach axudp xnet 256 192.168.1.112 (ip-adres Linux (eth0))
ifconfig xnet description "axip link xnet"

Eth0 (Linux)

eth0      Link encap:Ethernet  HWaddr 00:12:3f:2b:c6:6f
          inet addr:192.168.1.112  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::212:3fff:fe2b:c66f/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:7844 errors:0 dropped:0 overruns:0 frame:0
          TX packets:7255 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:885500 (864.7 KiB)  TX bytes:1166950 (1.1 MiB)
          Interrupt:16

Ip.net (xnet)

IP.net
#        File: IP.NET
#       (X)Net IP Address
#
myip 192.168.1.201
subnet 192.168.1.0/24
#
# ARP entry for all received IP Frames
arp add 192.168.1.201 slip sdev6
#
#
# Default route
ipr add default SLIP 192.168.1.201
#
iproute add 192.168.1.0/24 slip 192.168.1.201

Autoboot.net (xnet)

attach IP0 axudp 0 1 192.168.1.222   (Ip-adres van Jnos) 

po 0 acon 1
po 0 baud 9600
po 0 dup 0
po 0 win 7
po 0 quality 0
po 0 name pd2lt
r bc ad 0 pd2lt
r bc ad 0 nodes
ro lo a 0 pd2lt-9 d