以下是最常见配置类型的示例。这些仅为指南,因为配置网络的方式与要配置的网络一样多,但它们可能会为您提供一个起点。
你们中的许多人可能在家中拥有小型局域网,并希望将该网络上的机器连接到本地无线电 LAN。 这就是我在家使用的配置类型。 我安排为我分配一个合适的地址块,为了方便起见,我可以在单个路由中捕获它,并在我的以太网 LAN 上使用这些地址。 如果您也想尝试,您的本地 IP 协调员将协助您完成此操作。 以太网 LAN 的地址构成了无线电 LAN 地址的子集。 以下配置是我家中网络上 linux 路由器的实际配置
. . . . . . ___ _________ . | Network / \ . Network | 44.136.8.96/29| | . 44.136.8/24 \ | / | | Linux | . \|/ | | | . _____ __________ | | eth0 | Router | . / \ / \ | |_______________| |_____| TNC |____| Radio |__/ | 44.136.8.97 | and | . \_____/ \__________/ | | | sl0 | | Server | 44.136.8.5 | | | . | | | . | \_________/ . _|_ . . . . . . |
#!/bin/sh # /etc/rc.net # This configuration provides one KISS based AX.25 port and one # Ethernet device. echo "/etc/rc.net" echo " Configuring:" echo -n " loopback:" /sbin/ifconfig lo 127.0.0.1 /sbin/route add 127.0.0.1 echo " done." echo -n " ethernet:" /sbin/ifconfig eth0 44.136.8.97 netmask 255.255.255.248 \ broadcast 44.136.8.103 up /sbin/route add 44.136.8.97 eth0 /sbin/route add -net 44.136.8.96 netmask 255.255.255.248 eth0 echo " done." echo -n " AX.25: " kissattach -i 44.136.8.5 -m 512 /dev/ttyS1 4800 ifconfig sl0 netmask 255.255.255.0 broadcast 44.136.8.255 route add -host 44.136.8.5 sl0 route add -net 44.136.8.0 window 1024 sl0 echo -n " NET/ROM: " nrattach -i 44.136.8.5 netrom echo " Routing:" /sbin/route add default gw 44.136.8.68 window 1024 sl0 echo " default route." echo done. # end |
/etc/ax25/axports
# name callsign speed paclen window description 4800 VK2KTJ-0 4800 256 2 144.800 MHz |
/etc/ax25/nrports
# name callsign alias paclen description netrom VK2KTJ-9 LINUX 235 Linux Switch Port |
/etc/ax25/nrbroadcast
# ax25_name min_obs def_qual worst_qual verbose 4800 1 120 10 1 |
您必须在内核中启用 IP_FORWARDING。
AX.25 配置文件与前面章节中用作示例的配置文件非常相似,必要时请参考这些文件。
我选择为我的无线电端口使用一个不在我的家庭网络块内的 IP 地址。 我本不必这样做,我可以轻松地使用44.136.8.97也用于该端口。
44.136.8.68是我的本地 IPIP 封装网关,因此是我指向默认路由的位置。
我的以太网网络上的每台机器都有一条路由
route add -net 44.0.0.0 netmask 255.0.0.0 \ gw 44.136.8.97 window 512 mss 512 eth0 |
mss 和 window 参数的使用意味着我可以从本地以太网和基于无线电的连接获得最佳性能。
我还可以在路由器机器上运行我的 smail、http、ftp 和其他守护进程,以便它成为唯一需要为其他人提供设施的机器。
路由器机器是一台低端的 386DX20,配备 20Mb 硬盘和一个非常小的 linux 配置。
![]() | 此处有关隧道技术的一些信息已过时。 自 2.0.x 内核以来,设置已更改,现在应使用 iproute2 包中的“ip”命令,如高级路由 HOWTO 中所述。 |
Linux 现在非常普遍地用于世界各地的 TCP/IP 封装网关。 新的隧道驱动程序支持多个封装路由,并使旧的 ipip 守护进程过时。
典型的配置如下所示。
. . . . . . ___ _________ . | Network / \ . Network | 154.27.3/24 | | . 44.136.16/24 \ | / | | Linux | . \|/ | | | . _____ __________ | | eth0 | IPIP | . / \ / \ | ___|_______________| |_____| TNC |____| Radio |___/ | 154.27.3.20 | Gateway | . \_____/ \__________/ | | | sl0 | | | 44.136.16.1 | | | . | | | . | \_________/ . _|_ . . . . . . |
感兴趣的配置文件是
# /etc/rc.net # This file is a simple configuration that provides one KISS AX.25 # radio port, one Ethernet device, and utilizes the kernel tunnel driver # to perform the IPIP encapsulation/decapsulation # echo "/etc/rc.net" echo " Configuring:" # echo -n " loopback:" /sbin/ifconfig lo 127.0.0.1 /sbin/route add 127.0.0.1 echo " done." # echo -n " ethernet:" /sbin/ifconfig eth0 154.27.3.20 netmask 255.255.255.0 \ broadcast 154.27.3.255 up /sbin/route add 154.27.3.20 eth0 /sbin/route add -net 154.27.3.0 netmask 255.255.255.0 eth0 echo " done." # echo -n " AX.25: " kissattach -i 44.136.16.1 -m 512 /dev/ttyS1 4800 /sbin/ifconfig sl0 netmask 255.255.255.0 broadcast 44.136.16.255 /sbin/route add -host 44.136.16.1 sl0 /sbin/route add -net 44.136.16.0 netmask 255.255.255.0 window 1024 sl0 # echo -n " tunnel:" /sbin/ifconfig tunl0 44.136.16.1 mtu 512 up # echo done. # echo -n "Routing ... " source /etc/ipip.routes echo done. # # end. |
和
# /etc/ipip.routes # This file is generated using the munge script # /sbin/route add -net 44.134.8.0 netmask 255.255.255.0 tunl0 gw 134.43.26.1 /sbin/route add -net 44.34.9.0 netmask 255.255.255.0 tunl0 gw 174.84.6.17 /sbin/route add -net 44.13.28.0 netmask 255.255.255.0 tunl0 gw 212.37.126.3 ... ... ... |
/etc/ax25/axports
# name callsign speed paclen window description 4800 VK2KTJ-0 4800 256 2 144.800 MHz |
此处需要注意的一些要点是
新的隧道驱动程序使用路由表中的 gw 字段代替 pointopoint 参数来指定远程 IPIP 网关的地址。 这就是为什么它现在支持每个接口多个路由的原因。
您可以使用相同的地址配置两个网络设备。 在此示例中,sl0和tunl0设备已配置为无线电端口的 IP 地址。 这样做是为了让远程网关在发送给它的封装数据报中看到来自您的网关的正确地址。
用于指定封装路由的路由命令可以由 munge 脚本的修改版本自动生成。 这包含在下面。 然后,路由命令将被写入单独的文件,并使用 bash 读取source /etc/ipip.routes命令(假设您使用路由命令调用了文件/etc/ipip.routes),如图所示。 源文件必须采用 NOS 路由命令格式。
请注意在 route 命令上使用 window 参数。 将此参数设置为适当的值可以提高无线电链路的性能。
新的 tunnel-munge 脚本
#!/bin/sh # # From: Ron Atkinson <n8fow@hamgate.cc.wayne.edu> # # This script is basically the 'munge' script written by Bdale N3EUA # for the IPIP daemon and is modified by Ron Atkinson N8FOW. It's # purpose is to convert a KA9Q NOS format gateways route file # (usually called 'encap.txt') into a Linux routing table format # for the IP tunnel driver. # # Usage: Gateway file on stdin, Linux route format file on stdout. # eg. tunnel-munge < encap.txt > ampr-routes # # NOTE: Before you use this script be sure to check or change the # following items: # # 1) Change the 'Local routes' and 'Misc user routes' sections # to routes that apply to your own area (remove mine please!) # 2) On the fgrep line be sure to change the IP address to YOUR # gateway Internet address. Failure to do so will cause serious # routing loops. # 3) The default interface name is 'tunl0'. Make sure this is # correct for your system. echo "#" echo "# IP tunnel route table built by $LOGNAME on `date`" echo "# by tunnel-munge script v960307." echo "#" echo "# Local routes" echo "route add -net 44.xxx.xxx.xxx netmask 255.mmm.mmm.mmm dev sl0" echo "#" echo "# Misc user routes" echo "#" echo "# remote routes" fgrep encap | grep "^route" | grep -v " XXX.XXX.XXX.XXX" | \ awk '{ split($3, s, "/") split(s[1], n,".") if (n[1] == "") n[1]="0" if (n[2] == "") n[2]="0" if (n[3] == "") n[3]="0" if (n[4] == "") n[4]="0" if (s[2] == "1") mask="128.0.0.0" else if (s[2] == "2") mask="192.0.0.0" else if (s[2] == "3") mask="224.0.0.0" else if (s[2] == "4") mask="240.0.0.0" else if (s[2] == "5") mask="248.0.0.0" else if (s[2] == "6") mask="252.0.0.0" else if (s[2] == "7") mask="254.0.0.0" else if (s[2] == "8") mask="255.0.0.0" else if (s[2] == "9") mask="255.128.0.0" else if (s[2] == "10") mask="255.192.0.0" else if (s[2] == "11") mask="255.224.0.0" else if (s[2] == "12") mask="255.240.0.0" else if (s[2] == "13") mask="255.248.0.0" else if (s[2] == "14") mask="255.252.0.0" else if (s[2] == "15") mask="255.254.0.0" else if (s[2] == "16") mask="255.255.0.0" else if (s[2] == "17") mask="255.255.128.0" else if (s[2] == "18") mask="255.255.192.0" else if (s[2] == "19") mask="255.255.224.0" else if (s[2] == "20") mask="255.255.240.0" else if (s[2] == "21") mask="255.255.248.0" else if (s[2] == "22") mask="255.255.252.0" else if (s[2] == "23") mask="255.255.254.0" else if (s[2] == "24") mask="255.255.255.0" else if (s[2] == "25") mask="255.255.255.128" else if (s[2] == "26") mask="255.255.255.192" else if (s[2] == "27") mask="255.255.255.224" else if (s[2] == "28") mask="255.255.255.240" else if (s[2] == "29") mask="255.255.255.248" else if (s[2] == "30") mask="255.255.255.252" else if (s[2] == "31") mask="255.255.255.254" else mask="255.255.255.255" if (mask == "255.255.255.255") printf "route add -host %s.%s.%s.%s gw %s dev tunl0\n"\ ,n[1],n[2],n[3],n[4],$5 else printf "route add -net %s.%s.%s.%s gw %s netmask %s dev tunl0\n"\ ,n[1],n[2],n[3],n[4],$5,mask }' echo "#" echo "# default the rest of amprnet via mirrorshades.ucsd.edu" echo "route add -net 44.0.0.0 gw 128.54.16.18 netmask 255.0.0.0 dev tunl0" echo "#" echo "# the end" |
许多业余无线电互联网网关除了 tcp/ip 之外,还封装了 AX.25、NET/ROM 和 ROSE。 Brian Kantor 在 RFC-1226 中描述了 IP 数据报中 AX.25 帧的封装。 Mike Westerhof 于 1991 年为 UNIX 编写了 AX.25 封装守护进程的实现。 ax25-utils 包包含其针对 Linux 的略微增强版本。
AXIP 封装程序在一端接受 AX.25 帧,查看目标 AX.25 地址以确定要将它们发送到的 IP 地址,将它们封装在 tcp/ip 数据报中,然后将它们传输到适当的远程目标。 它还接受包含 AX.25 帧的 tcp/ip 数据报,解包它们并处理它们,就好像它是直接从 AX.25 端口接收到它们一样。 为了区分包含 AX.25 帧的 IP 数据报与不包含 AX.25 帧的其他 IP 数据报,AXIP 数据报使用协议 ID 4(或现已弃用的 94)进行编码。 RFC-1226 中描述了此过程。
ax25-utils 包中包含的 ax25ipd 程序将自身呈现为一个程序,该程序支持 KISS 接口(您可以通过该接口传递 AX.25 帧)以及与 tcp/ip 协议的接口。 它使用名为以下内容的单个配置文件进行配置/etc/ax25/ax25ipd.conf.
ax25ipd 程序有两种主要操作模式。“digipeater”模式和“tnc”模式。 在“tnc”模式下,守护进程被视为好像它是 kiss TNC,您将 KISS 封装的帧传递给它,它将传输它们,这是通常的配置。 在“digipeater”模式下,您将守护进程视为好像它是 AX.25 数字中继器。 这些模式之间存在细微差别。
在配置文件中,您配置“路由”或目标 AX.25 呼号与您要将 AX.25 数据包发送到的主机的 IP 地址之间的映射。 每个路由都有选项,稍后将对此进行解释。
此处配置的其他选项包括
ax25ipd 守护进程将打开的 tty 及其速度(通常是管道的一端)
您想在“digipeater”模式下使用的呼号
信标间隔和文本
您是否要将 AX.25 帧封装在 IP 数据报中或 UDP/IP 数据报中。 几乎所有 AXIP 网关都使用 IP 封装,但某些网关位于防火墙后面,这些防火墙不允许具有 AXIP 协议 ID 的 IP 通过,并且被迫使用 UDP/IP。 无论您选择什么,都必须与链路另一端的 tcp/ip 主机正在使用的内容相匹配。
# # ax25ipd configuration file for station floyd.vk5xxx.ampr.org # # Select axip transport. 'ip' is what you want for compatibility # with most other gateways. # socket ip # # Set ax25ipd mode of operation. (digi or tnc) # mode tnc # # If you selected digi, you must define a callsign. If you selected # tnc mode, the callsign is currently optional, but this may change # in the future! (2 calls if using dual port kiss) # #mycall vk5xxx-4 #mycall2 vk5xxx-5 # # In digi mode, you may use an alias. (2 for dual port) # #myalias svwdns #myalias2 svwdn2 # # Send an ident every 540 seconds ... # #beacon after 540 #btext ax25ip -- tncmode rob/vk5xxx -- Experimental AXIP gateway # # Serial port, or pipe connected to a kissattach in my case # device /dev/ttyq0 # # Set the device speed # speed 9600 # # loglevel 0 - no output # loglevel 1 - config info only # loglevel 2 - major events and errors # loglevel 3 - major events, errors, and AX.25 frame trace # loglevel 4 - all events # log 0 for the moment, syslog not working yet ... # loglevel 2 # # If we are in digi mode, we might have a real tnc here, so use param to # set the tnc parameters ... # #param 1 20 # # Broadcast Address definition. Any of the addresses listed will be forwarded # to any of the routes flagged as broadcast capable routes. # broadcast QST-0 NODES-0 # # ax.25 route definition, define as many as you need. # format is route (call/wildcard) (ip host at destination) # ssid of 0 routes all ssid's # # route <destcall> <destaddr> [flags] # # Valid flags are: # b - allow broadcasts to be transmitted via this route # d - this route is the default route # route vk2sut-0 44.136.8.68 b route vk5xxx 44.136.188.221 b route vk2abc 44.1.1.1 # # |
# /etc/ax25/axports # axip VK2KTJ-13 9600 256 AXIP port # |
/usr/sbin/kissattach /dev/ptyq0 axip 44.135.96.242 |
/usr/sbin/ax25ipd & |
call axip vk5xxx |
“route”命令是您指定要封装 AX.25 数据包并将其发送到的位置。 当 ax25ipd 守护进程从其接口接收到数据包时,它会将目标呼号与其路由表中的每个呼号进行比较。 如果找到匹配项,则 ax.25 数据包将被封装在 IP 数据报中,然后传输到指定 IP 地址的主机。
您可以将两个标志添加到ax25ipd.conf文件中的任何路由命令中。 这两个标志是
目标地址与“broadcast”关键字定义的列表中的任何地址匹配的流量都应通过此路由传输。
任何与任何路由都不匹配的数据包都应通过此路由传输。
广播标志非常有用,因为它使通常发往所有站点的信息能够到达多个 AXIP 目的地。 通常,axip 路由是点对点的,无法处理“广播”数据包。
许多人喜欢在 Linux 下运行某些版本的 NOS,因为它具有他们习惯的所有特性和功能。 这些人中的大多数人也希望在他们的机器上运行的 NOS 能够与 Linux 内核对话,以便他们可以通过 NOS 向无线电用户提供一些 linux 功能。
Brandon S. Allbery, KF8NH,贡献了以下信息,以解释如何使用 Linux 管道设备将 Linux 机器上运行的 NOS 与内核代码互连。
由于 Linux 和 NOS 都支持 slip 协议,因此可以通过创建 slip 链接将两者链接在一起。 您可以使用两个串行端口和它们之间的环回电缆来完成此操作,但这会很慢且成本很高。 Linux 提供了一个许多其他类 Unix 操作系统提供的功能,称为“管道”。 这些是特殊的伪设备,对于软件来说看起来像标准的 tty 设备,但实际上环回到另一个管道设备。 要使用这些管道,第一个程序必须打开管道的主端,然后第二个程序才能打开管道的从端。 当两端都打开时,程序可以通过简单地向管道写入字符来相互通信,就像它们是终端设备一样。
要使用此功能连接 Linux 内核和 NOS 副本或其他程序,您首先必须选择要使用的管道设备。 您可以通过查看您的/dev目录来找到一个。 管道的主端被命名为ptyq[1-f]管道的从端被称为ttyq[1-f]。 请记住它们是成对出现的,因此如果您选择/dev/ptyqf作为您的主端,那么您必须使用/dev/ttyqf作为从端。
选择要使用的管道设备对后,您应该将主端分配给您的 linux 内核,将从端分配给 NOS 程序,因为 Linux 内核首先启动,并且必须首先打开管道的主端。 您还必须记住,您的 Linux 内核必须具有与您的 NOS 不同的 IP 地址,因此如果您尚未分配,则需要为其分配一个唯一的地址。
您配置管道就像它是串行设备一样,因此要从您的 linux 内核创建 slip 链接,您可以使用类似于以下的命令
# /sbin/slattach -s 38400 -p slip /dev/ptyqf & # /sbin/ifconfig sl0 broadcast 44.255.255.255 pointopoint 44.70.248.67 / mtu 1536 44.70.4.88 # /sbin/route add 44.70.248.67 sl0 # /sbin/route add -net 44.0.0.0 netmask 255.0.0.0 gw 44.70.248.67 |
在此示例中,Linux 内核已被赋予 IP 地址44.70.4.88并且 NOS 程序正在使用 IP 地址44.70.248.67。 最后一行中的 route 命令只是告诉您的 linux 内核通过 slattach 命令创建的 slip 链接路由 amprnet 的所有数据报。 通常,您会将这些命令放入您的/etc/rc.d/rc.inet2文件,在完成所有其他网络配置之后,以便在您重新启动时自动创建 slip 链接。 注意:使用 cslip 而不是 slip 没有任何优势,因为它实际上会降低性能,因为该链接只是一个虚拟链接,并且发生速度足够快,以至于首先压缩标头比传输未压缩的数据报花费的时间更长。
要配置链接的 NOS 端,您可以尝试以下操作
# you can call the interface anything you want; I use "linux" for convenience. attach asy ttyqf - slip linux 1024 1024 38400 route addprivate 44.70.4.88 linux |
这些命令将通过管道设备对的从端到您的 linux 内核创建一个名为“linux”的 slip 端口,并创建一个路由以使其工作。 启动 NOS 后,您应该能够从 Linux 机器 ping 和 telnet 到您的 NOS,反之亦然。 如果没有,请仔细检查您是否没有犯任何错误,尤其要确保您已正确配置地址并将管道设备放置在正确的位置。