This is a Linux port of the FreeBSD MacIP gateway implementation originally written by Stefan Bethke. Stefan's original work is hosted on Sourceforge here. Most of the original AppleTalk code required little or no changes. The main work involved converting from FreeBSD tun interfaces to Linux tuntap interfaces. I left the original license intact and it is applied to all of the Linux-specific changes as well.
The primary intent of this port was to have MacIP functionality on the Raspberry Pi so, while it may (and probably will) compile under other Linux variants, it has only been tested on Raspbian.
Note: If you don't want to deal with compiling macipgw yourself, check out http://macip.net for a pre-configured VM that uses this code.
The makefile has debugging enabled with the -DDEBUG switch, comment this out if you intend to run this without debugging. A typical command to run macipgw with debugging would look something like this:
./macipgw -d0x111 -n 126.96.36.199 192.168.1.0 255.255.255.0
The -d switch will specify that the daemon not fork and turn on all debugging (0x111). It is useful for testing purposes or if you are having issues. The rest of the command tells the MacIP clients to use 188.8.131.52 for DNS, assigns 192.168.1.1 as the gateway address and issues MacIP client addresses in the range 192.168.1.2-254. Note that the network you use with this command MUST be unique from the network of any other interface. This is because macipgw sets up a separate MacIP network space and expects the host to route between that MacIP space and any other interface (e.g. eth0, wlan0, etc.)
Assuming that you already have AppleTalk enabled, the above command will be enough to get started with MacIP. However, by default Linux does not have IP forwarding enabled so if you want to route between your normal LAN network and the MacIP network, you need to enable IP forwarding:
sysctl -w net.ipv4.ip_forward=1
Once this has been enabled, you will be able to route between your MacIP network and any other network attached to the host.
The above may be enough for you if you have routing enabled throughout your LAN and can add routes to the MacIP network in the rest of your network devices, however, it is often convenient to just enable NAT on the outbound interface of the host using iptables. A typical iptables configuration to enable NAT on the wlan0 interface for the MacIP network outlined above would be:
# Generated by iptables-save v1.4.14 on Thu Oct 15 22:54:35 2015 *nat :PREROUTING ACCEPT [680:172998] :INPUT ACCEPT [122:18404] :OUTPUT ACCEPT [201:15275] :POSTROUTING ACCEPT [3:180] -A PREROUTING -s 192.168.1.0/24 -i tun0 -A POSTROUTING -o wlan0 -j MASQUERADE COMMIT # Completed on Thu Oct 15 22:54:35 2015 # Generated by iptables-save v1.4.14 on Thu Oct 15 22:54:35 2015 *filter :INPUT ACCEPT [49565:4589890] :FORWARD ACCEPT [10606:4109172] :OUTPUT ACCEPT [32994:7213232] COMMIT # Completed on Thu Oct 15 22:54:35 2015
Once this configuration is put in place, the host will NAT (well, PAT actually) any IP traffic originating from the MacIP network and being sent out the wlan0 interface. This would likely be a typical usage for macipgw on the Raspberry Pi.
Your kernel must be configured with the CONFIG_IPDDP option disabled completely. It is not sufficient to compile it as a module -- in order to support the module, the kernel is modified to intercept all MacIP traffic, so userspace applications such as macipgw cannot handle it.
This was all developed and tested using a PowerBook 5300C, A2SERVER on the Raspberry Pi and an AsanteTalk bridge. The setup looks something like this:
PowerBook 5300C ---- [LocalTalk] ---- AsanteTalk bridge ---- [Ethernet] ---- Raspberry Pi ---- [WiFi] ---- LAN
It has also been tested with the following setup:
PowerMac G3 All-in-One ---- [LocalTalk] ---- AsanteTalk bridge ---- [Ethernet] ---- Ubuntu x86_64, Linux kernel 4.2 ---- LAN