kernel-module-iptable-nat / share internet

Hello

I want to share the internet connection of eth0 with wlan0. (like wifi AP, hostapd and dhcp-server already working)

I tried to use iptables for NAT.

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

But i get following error:
“iptables v1.4.15: can’t initialize iptables table `nat’: Table does not exist (do you need to insmod?)
Perhaps iptables or your kernel needs to be upgraded.”

So i tried to install kernel-module-iptable-nat, but it is not available for the 3.8 kernel.

Is there another method to share the internet connection / build kernel-module-iptable-nat for the 3.8 kernel?

Using BBB / latest Angstrom.

Hi,

I did a similar thing except with a Sierra 3G USB modem providing a VOICE/Internet connection and client computers connecting via eth0. So my experience has some relevance. I found it necessary to not use CONNMAN, otherwise it appeared to be impossible to use ppp. My project requires the main AT interface to be used to manage voice communication (dialling, answer and hangup, etc …) and a second data interface is used for data connection. pppd is used to manage the second data interface. This is totally incompatible with connman/ofono unless I’m prepared to modify ofono. Also pppd runs as an autonomous entity handling the data connection completely independent of the voice connection. Try doing that with ofono?

Angstrom 2012.12 with kernel 3.8.13 needs to be recompiled to support NAT with the following settings for IPV4

Enable NAT:

→ Networking support (NET [=y])
→ Networking options
→ Network packet filtering framework (Netfilter) (NETFILTER [=y])
→ Core Netfilter Configuration
Netfilter connection tracking support
{M} Netfilter Xtables support (required for ip_tables)
*** Xtables combined modules ***
“NFLOG” target support
“conntrack” connection tracking match support
“state” match support
→ IP: Netfilter Configuration
IPv4 connection tracking support (required for NAT)
[*] proc/sysctl compatibility with old connection tracking (NEW)
IP Userspace queueing via NETLINK (OBSOLETE)
IP tables support (required for filtering/masq/NAT)
“ah” match support
“ecn” match support
“rpfilter” reverse path filter match support
“ttl” match support
Packet filtering
REJECT target support
ULOG target support
IPv4 NAT
MASQUERADE target support
NETMAP target support
REDIRECT target support
Packet mangling

To implement the connection to the modem I decided to ditch connman/ofono and revert to pppd. So I configured /etc/network/interfaces to handle the ethernet

Ethernet Interface

I wanted a static IP address on the ethernet. (ppp0 interface address is dynamically assigned by 3G system).

Modify the file /etc/network/interfaces to contain the following:

/etc/network/interfaces – configuration file for ifup(8), ifdown(8)

The loopback interface

auto lo
iface lo inet loopback

Wired interfaces

auto eth0
iface eth0 inet static
address 192.168.0.1
netmask 255.255.255.0
network 192.168.0.0
gateway 192.168.0.2

Modify the file /etc/resolv.conf to contain the following:

Generated by Connection Manager

nameserver 8.8.8.8

Connman

Disable the connman network service with the following commands

systemctl daemon-reload

systemctl stop connman.service

systemctl disable connman.service

Network Service

Create a file /lib/systemd/networking.service which contains:

[Unit]
Description=Run the Networking Service
After=syslog.target

[Service]
Type=simple
ExecStartPre=/bin/sh -c ‘iptables-restore < /etc/iptables.sav’
ExecStart=/etc/init.d/networking start

[Install]
WantedBy=multi-user.target

Create a link to the networking service file

cd /etc/systemd/system

ln -f /lib/systemd/networking.service networking.service

Start the service:

systemctl daemon-reload

systemctl enable networking.service

IPTABLES

For forwarding, modify line in the file /etc/sysctl.conf

net.ipv4.ip_forward=1

to

net.ipv4.ip_forward=1

Set-up the routing with the command:

cd /etc

iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE

iptables-save > /etc/iptables.sav

Reboot the machine. It should possible to connect a PC to the beagle via Ethernet.

DHCP

To provide a dhcp server I decided to use dnsmasq as it did nice things like ensure the correct namerserver addressing was passed to the dhcp clients. You will need to download the source code and compile it yourself.

It works rather well. I’m getting 7.2 MBits/sec download and 5 MBIts/sec upload (Telstra NextG carrier) which is good for pppd. pppd ensures default route is via ppp0 while connection is up. The project was/is to build a not-so-mobile phone for use in the rail industry.

Regards …