forked from stratux/stratux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinterfaces.template
69 lines (54 loc) · 2.09 KB
/
interfaces.template
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
auto lo
iface lo inet loopback
# allow-hotplug eth0 # configured by ifplugd
iface eth0 inet dhcp
allow-hotplug wlan0
{{if or (eq .WiFiMode 0) (eq .WiFiMode 2)}}
# AP or AP+Client -> create seperate ap0 virtual interface for the AP; optionally use wlan0 for client connection
iface ap0 inet static
address {{.IpAddr}}
netmask 255.255.255.0
post-up /opt/stratux/bin/stratux-wifi.sh ap0 0;
{{end}}
{{if eq .WiFiMode 0}}
# Pure AP mode
iface wlan0 inet manual
pre-up ifdown ap0; ifconfig ap0 down; iw ap0 del || true
pre-up iw wlan0 set type managed; iw phy0 interface add ap0 type __ap; ifup ap0
wireless-power off
post-down ifdown ap0; ifconfig ap0 down; iw ap0 del
{{end}}
{{if eq .WiFiMode 2}}
# AP+Client mode
iface wlan0 inet manual
pre-up ifdown ap0; ifconfig ap0 down; iw ap0 del || true
pre-up iw wlan0 set type managed; iw phy0 interface add ap0 type __ap; ifup ap0
# Enable routing
{{if .WiFiInternetPassThroughEnabled}}
pre-up echo 1 > /proc/sys/net/ipv4/ip_forward
post-up iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
post-up iptables -A FORWARD -i wlan0 -o ap0 -m state --state RELATED,ESTABLISHED -j ACCEPT
post-up iptables -A FORWARD -i ap0 -o wlan0 -j ACCEPT
{{else}}
pre-up echo 0 > /proc/sys/net/ipv4/ip_forward
{{end}}
wireless-power off
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
post-down ifdown ap0; ifconfig ap0 down; iw ap0 del
# The post-down hook seems to be buggy when wpa-roam is used. Because of that, we run this as pre-up for all other configurations as well to make sure everything is gone
# pseudo iface triggered by wpa_supplicant
iface default inet dhcp
{{end}}
{{if eq .WiFiMode 1}}
# Wifi-Direct -> run stratux-wifi on wlan0, p2p-wlan0-0 will be created by it / by wpa_supplicant
iface wlan0 inet manual
pre-up ifdown ap0; ifconfig ap0 down; iw ap0 del || true
pre-down ifdown p2p-wlan0-0
post-up /opt/stratux/bin/stratux-wifi.sh wlan0 1 {{.WiFiDirectPin}}
wireless-power off
allow-hotplug p2p-wlan0-0
iface p2p-wlan0-0 inet static
address {{.IpAddr}}
netmask 255.255.255.0
post-down wpa_cli -i wlan0 terminate
{{end}}