1+ #! /bin/bash
2+ # Setup WiFi Access Point for GoNoteGo
3+
4+ # Install required packages
5+ sudo apt install -y rng-tools hostapd dnsmasq
6+
7+ # Configure dhcpcd
8+ cat << EOF > /etc/dhcpcd.conf
9+ # Allow users of this group to interact with dhcpcd via the control socket.
10+ #controlgroup wheel
11+
12+ # Inform the DHCP server of our hostname for DDNS.
13+ hostname
14+
15+ # Use the hardware address of the interface for the Client ID.
16+ clientid
17+ # or
18+ # Use the same DUID + IAID as set in DHCPv6 for DHCPv4 ClientID as per RFC4361.
19+ # Some non-RFC compliant DHCP servers do not reply with this set.
20+ # In this case, comment out duid and enable clientid above.
21+ #duid
22+
23+ # Persist interface configuration when dhcpcd exits.
24+ persistent
25+
26+ # Rapid commit support.
27+ # Safe to enable by default because it requires the equivalent option set
28+ # on the server to actually work.
29+ option rapid_commit
30+
31+ # A list of options to request from the DHCP server.
32+ option domain_name_servers, domain_name, domain_search, host_name
33+ option classless_static_routes
34+ # Respect the network MTU. This is applied to DHCP routes.
35+ option interface_mtu
36+
37+ # Most distributions have NTP support.
38+ #option ntp_servers
39+
40+ # A ServerID is required by RFC2131.
41+ require dhcp_server_identifier
42+
43+ # Generate SLAAC address using the Hardware Address of the interface
44+ #slaac hwaddr
45+ # OR generate Stable Private IPv6 Addresses based from the DUID
46+ slaac private
47+
48+ # Example static IP configuration:
49+ #interface eth0
50+ #static ip_address=192.168.0.10/24
51+ #static ip6_address=fd51:42f8:caae:d92e::ff/64
52+ #static routers=192.168.0.1
53+ #static domain_name_servers=192.168.0.1 8.8.8.8 fd51:42f8:caae:d92e::1
54+
55+ # It is possible to fall back to a static IP if DHCP fails:
56+ # define static profile
57+ #profile static_eth0
58+ #static ip_address=192.168.1.23/24
59+ #static routers=192.168.1.1
60+ #static domain_name_servers=192.168.1.1
61+
62+ # fallback to static profile on eth0
63+ #interface eth0
64+ #fallback static_eth0
65+
66+ # Interface for Go Note Go Access Point
67+ interface uap0
68+ static ip_address=192.168.4.1/24
69+ nohook wpa_supplicant
70+ EOF
71+
72+ # Configure dnsmasq
73+ cat << EOF >> /etc/dnsmasq.conf
74+ interface=uap0
75+ dhcp-range=192.168.4.2,192.168.4.20,255.255.255.0,24h
76+ EOF
77+
78+ # Create uap0 service
79+ cat << EOF >> /etc/systemd/system/uap0.service
80+ [Unit]
81+ Description=Create uap0 interface
82+ After=sys-subsystem-net-devices-wlan0.device
83+
84+ [Service]
85+ Type=oneshot
86+ RemainAfterExit=true
87+ ExecStart=/sbin/iw phy phy0 interface add uap0 type __ap
88+ ExecStartPost=/usr/bin/ip link set dev uap0 address d8:3a:dd:06:5e:ca
89+ ExecStartPost=/sbin/ifconfig uap0 up
90+ ExecStop=/sbin/iw dev uap0 del
91+
92+ [Install]
93+ WantedBy=multi-user.target
94+ EOF
95+
96+ # Enable and start uap0 service
97+ sudo systemctl daemon-reload
98+ sudo systemctl start uap0.service
99+ sudo systemctl enable uap0.service
100+
101+ # Configure hostapd
102+ cat << EOF >> /etc/hostapd/hostapd.conf
103+ interface=uap0
104+ ssid=GoNoteGo-Wifi
105+ hw_mode=g
106+ channel=4
107+ wmm_enabled=0
108+ macaddr_acl=0
109+ auth_algs=1
110+ ignore_broadcast_ssid=0
111+ wpa=2
112+ wpa_passphrase=swingset
113+ wpa_key_mgmt=WPA-PSK
114+ wpa_pairwise=TKIP
115+ rsn_pairwise=CCMP
116+ EOF
117+
118+ # Update hostapd defaults
119+ cat << EOF >> /etc/default/hostapd
120+ DAEMON_CONF="/etc/hostapd/hostapd.conf"
121+ EOF
122+
123+ # Start and enable hostapd and dnsmasq
124+ sudo systemctl start hostapd
125+ sudo systemctl start dnsmasq
126+ sudo systemctl enable hostapd
127+ sudo systemctl enable dnsmasq
128+
129+ # Enable IP forwarding
130+ cat << EOF >> /etc/sysctl.conf
131+ net.ipv4.ip_forward=1
132+ EOF
0 commit comments