Skip to content

Commit

Permalink
Add recipe for sharing internet access #183
Browse files Browse the repository at this point in the history
  • Loading branch information
LostKobrakai authored and fhunleth committed Jan 21, 2020
1 parent fb1e45d commit 160f011
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions docs/cookbook.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,17 @@ See the
[vintage_net_wizard](https://github.com/nerves-networking/vintage_net_wizard)
for an example of a project that uses AP mode and a web server for WiFi
configuration.

## Network interaction

### Share WAN with other networks

For sharing your WANs connection (e.g. internet access) with other networks `iptables` must be installed. Currently this means building a [custom nerves system](https://hexdocs.pm/nerves/customizing-systems.html). Once this is done the following commands need to be called on each boot:

```elixir
wan = "eth0"
cmd "sysctl -w net.ipv4.ip_forward=1"
cmd "iptables -t nat -A POSTROUTING -o #{wan} -j MASQUERADE"
# Only needed if the connection is blocked otherwise (like a default policy of DROP)
cmd "iptables -A INPUT -i #{wan} -m state --state RELATED,ESTABLISHED -j ACCEPT"
```

0 comments on commit 160f011

Please sign in to comment.