Skip to content

Commit

Permalink
Documentation for access points and dchpd
Browse files Browse the repository at this point in the history
  • Loading branch information
grace-in-wonderland authored and fhunleth committed Feb 23, 2022
1 parent 3fda6ee commit 55d5b37
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 17 deletions.
8 changes: 7 additions & 1 deletion docs/cookbook.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,12 @@ involved. Here is a basic configuration:
},
dhcpd: %{
start: "192.168.24.2",
end: "192.168.24.10"
end: "192.168.24.10",
options: %{
dns: ["1.1.1.1", "1.0.0.1"],
subnet: "192.168.24.255",
router: ["192.168.24.1"]
}
}
}
```
Expand Down Expand Up @@ -377,6 +382,7 @@ the following commands need to be called on each boot:
wan = "eth0"
cmd "sysctl -w net.ipv4.ip_forward=1"
cmd "iptables -t nat -A POSTROUTING -o #{wan} -j MASQUERADE"
cmd "iptables --append FORWARD --in-interface wlan0 -j ACCEPT"
# 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"
```
Expand Down
55 changes: 39 additions & 16 deletions lib/vintage_net/ip/dhcpd_config.ex
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,45 @@ defmodule VintageNet.IP.DhcpdConfig do
* `:min_lease` - If client asks for lease below this value, it will be rounded up to this value (seconds)
* `:auto_time` - The time period at which udhcpd will write out leases file.
* `:static_leases` - list of `{mac_address, ip_address}`
* `:options` - a map DHCP response options to set. See below.
DHCP response options are (see RFC 2132 for details):
* `:dns` - IP_LIST
* `:domain` - STRING - [0x0f] client's domain suffix
* `:hostname` - STRING
* `:mtu` - NUM
* `:router` - IP_LIST
* `:search` - STRING_LIST - [0x77] search domains
* `:serverid` - IP (defaults to the interface's IP address)
* `:subnet` - IP
Options may also be passed in as integers. These are passed directly to the DHCP server
and their values are strings that are not interpreted by VintageNet. Use this to support
custom DHCP header options.
* `:options` - a map DHCP response options to set. Such as:
* `:dns` - IP_LIST
* `:domain` - STRING - [0x0f] client's domain suffix
* `:hostname` - STRING
* `:mtu` - NUM
* `:router` - IP_LIST
* `:search` - STRING_LIST - [0x77] search domains
* `:serverid` - IP (defaults to the interface's IP address)
* `:subnet` - IP (as a subnet mask)
> #### :options {: .info}
> Options may also be passed in as integers. These are passed directly to the DHCP server
> and their values are strings that are not interpreted by VintageNet. Use this to support
> custom DHCP header options. For more details on DHCP response options see RFC 2132
## Example
```
VintageNet.configure("wlan0", %{
type: VintageNetWiFi,
vintage_net_wifi: %{
networks: [
%{
mode: :ap,
ssid: "test ssid",
key_mgmt: :none
}
]
},
dhcpd: %{
start: "192.168.24.2",
end: "192.168.24.10",
options: %{
dns: ["1.1.1.1", "1.0.0.1"],
subnet: "192.168.24.255",
router: ["192.168.24.1"]
}
}
})
```
"""

alias VintageNet.{Command, IP}
Expand Down

0 comments on commit 55d5b37

Please sign in to comment.