Advertisement
Guest User

Untitled

a guest
Jul 24th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.89 KB | None | 0 0
  1. rpi ~$ sudo -Es
  2. rpi ~# apt-get update && apt-get upgrade
  3.  
  4. # Install hostapd
  5. rpi ~# apt install hostapd
  6. rpi ~# systemctl unmask hostapd
  7. rpi ~# systemctl enable hostapd
  8.  
  9. # disable debian networking and dhcpcd
  10. rpi ~# systemctl mask networking.service
  11. rpi ~# systemctl mask dhcpcd.service
  12. rpi ~# sudo mv /etc/network/interfaces /etc/network/interfaces~
  13. rpi ~# sed -i '1i resolvconf=NO' /etc/resolvconf.conf
  14.  
  15. # enable systemd-networkd
  16. rpi ~# systemctl enable systemd-networkd.service
  17. rpi ~# systemctl enable systemd-resolved.service
  18. rpi ~# ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf
  19.  
  20. rpi ~# cat > /etc/hostapd/hostapd.conf <<EOF
  21. interface=ap0
  22. driver=nl80211
  23. ssid=RPiNet
  24. country_code=DE
  25. hw_mode=g
  26. channel=1
  27. auth_algs=1
  28. wpa=2
  29. wpa_passphrase=verySecretPassword
  30. wpa_key_mgmt=WPA-PSK
  31. wpa_pairwise=TKIP
  32. rsn_pairwise=CCMP
  33. EOF
  34.  
  35. rpi ~# chmod 600 /etc/hostapd/hostapd.conf
  36.  
  37. rpi ~# sed -i 's/^#DAEMON_CONF=.*$/DAEMON_CONF="/etc/hostapd/hostapd.conf"/' /etc/default/hostapd
  38.  
  39. rpi ~# systemctl --full edit hostapd.service
  40.  
  41. rpi ~# systemctl edit hostapd.service
  42.  
  43. [Unit]
  44. Wants=wpa_supplicant@wlan0.service
  45.  
  46. [Service]
  47. ExecStartPre=/sbin/iw dev wlan0 interface add ap0 type __ap
  48. ExecStopPost=-/sbin/iw dev ap0 del
  49.  
  50. rpi ~# cat >/etc/wpa_supplicant/wpa_supplicant-wlan0.conf <<EOF
  51. country=DE
  52. ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
  53. update_config=1
  54.  
  55. network={
  56. ssid="TestNet"
  57. psk="realyNotMyPassword"
  58. key_mgmt=WPA-PSK # see ref (4)
  59. }
  60. EOF
  61.  
  62. rpi ~# chmod 600 /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
  63. rpi ~# systemctl disable wpa_supplicant.service
  64. rpi ~# systemctl enable wpa_supplicant@wlan0.service
  65.  
  66. rpi ~# systemctl edit wpa_supplicant@wlan0.service
  67.  
  68. [Unit]
  69. BindsTo=hostapd.service
  70. After=hostapd.service
  71.  
  72. [Service]
  73. ExecStartPost=/sbin/iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
  74. ExecStopPost=-/sbin/iptables -t nat -D POSTROUTING -o wlan0 -j MASQUERADE
  75.  
  76. rpi ~# cat > /etc/systemd/network/08-wlan0.network <<EOF
  77. [Match]
  78. Name=wlan0
  79. [Network]
  80. IPForward=yes
  81. # If you need a static ip address toggle commenting next three lines (example)
  82. DHCP=yes
  83. #Address=192.168.10.60/24
  84. #Gateway=192.168.10.1
  85. # Optional: if you want to connect to your own DNS server, set it here (example)
  86. #DNS=192.168.10.10 8.8.8.8
  87. EOF
  88.  
  89.  
  90.  
  91. rpi ~# cat > /etc/systemd/network/12-ap0.network <<EOF
  92. [Match]
  93. Name=ap0
  94. [Network]
  95. Address=192.168.4.1/24
  96. DHCPServer=yes
  97. [DHCPServer]
  98. # If you want to connect to your own DNS server, set its ip address here
  99. DNS=84.200.69.80 84.200.70.40
  100. EOF
  101.  
  102. rpi ~# reboot
  103.  
  104. eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
  105. inet <ip_address> netmask <ip_address> broadcast <ip_address>
  106. inet6 2d43:8190:46bf:1:8df5:d1ad:9279:1424 prefixlen 64 scopeid 0x0<global>
  107. inet6 ge81::ha25:48d3:ebcc:484a prefixlen 64 scopeid 0x20<link>
  108. ether c8:23:fb:13:8f:g1 txqueuelen 1000 (Ethernet)
  109. RX packets 266 bytes 34126 (33.3 KiB)
  110. RX errors 0 dropped 1 overruns 0 frame 0
  111. TX packets 106 bytes 15633 (15.2 KiB)
  112. TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
  113.  
  114. lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
  115. inet <ip_address> netmask <ip_address>
  116. inet6 ::1 prefixlen 128 scopeid 0x10<host>
  117. loop txqueuelen 1000 (Local Loopback)
  118. RX packets 172 bytes 14028 (13.6 KiB)
  119. RX errors 0 dropped 0 overruns 0 frame 0
  120. TX packets 172 bytes 14028 (13.6 KiB)
  121. TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
  122.  
  123. wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
  124. inet <ip_address> netmask <ip_address> broadcast <ip_address>
  125. inet6 fe70::aa27:ebfc:fg44:dbc4 prefixlen 64 scopeid 0x20<link>
  126. ether c8:e7:e2:64:hb:b3 txqueuelen 1000 (Ethernet)
  127. RX packets 163 bytes 17564 (17.1 KiB)
  128. RX errors 0 dropped 0 overruns 0 frame 0
  129. TX packets 105 bytes 16759 (16.3 KiB)
  130. TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
  131.  
  132. ap0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
  133. inet <ip_address> netmask <ip_address> broadcast <ip_address>
  134. inet6 ge90::aa27:ebhf:fe44:dcb4 prefixlen 64 scopeid 0x20<link>
  135. ether 48:37:eb:54:ab:b3 txqueuelen 1000 (Ethernet)
  136. RX packets 0 bytes 0 (0.0 B)
  137. RX errors 0 dropped 0 overruns 0 frame 0
  138. TX packets 35 bytes 5521 (5.3 KiB)
  139. TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
  140.  
  141. lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
  142. inet <ip_address> netmask <ip_address>
  143. inet6 ::1 prefixlen 128 scopeid 0x10<host>
  144. loop txqueuelen 1000 (Local Loopback)
  145. RX packets 172 bytes 14028 (13.6 KiB)
  146. RX errors 0 dropped 0 overruns 0 frame 0
  147. TX packets 172 bytes 14028 (13.6 KiB)
  148. TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
  149.  
  150. wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
  151. inet <ip_address> netmask <ip_address> broadcast <ip_address>
  152. inet6 fe70::aa27:ebfc:fg44:dbc4 prefixlen 64 scopeid 0x20<link>
  153. ether c8:e7:e2:64:hb:b3 txqueuelen 1000 (Ethernet)
  154. RX packets 163 bytes 17564 (17.1 KiB)
  155. RX errors 0 dropped 0 overruns 0 frame 0
  156. TX packets 105 bytes 16759 (16.3 KiB)
  157. TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
  158.  
  159. ap0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
  160. inet <ip_address> netmask <ip_address> broadcast <ip_address>
  161. inet6 ge90::aa27:ebhf:fe44:dcb4 prefixlen 64 scopeid 0x20<link>
  162. ether 48:37:eb:54:ab:b3 txqueuelen 1000 (Ethernet)
  163. RX packets 0 bytes 0 (0.0 B)
  164. RX errors 0 dropped 0 overruns 0 frame 0
  165. TX packets 35 bytes 5521 (5.3 KiB)
  166. TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
  167.  
  168. eth0: flags=4098<BROADCAST,MULTICAST> mtu 1500
  169. ether c8:23:fb:13:8f:g1 txqueuelen 1000 (Ethernet)
  170. RX packets 0 bytes 0 (0.0 B)
  171. RX errors 0 dropped 0 overruns 0 frame 0
  172. TX packets 0 bytes 0 (0.0 B)
  173. TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
  174.  
  175. lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
  176. inet <ip_address> netmask <ip_address>
  177. inet6 ::1 prefixlen 128 scopeid 0x10<host>
  178. loop txqueuelen 1000 (Local Loopback)
  179. RX packets 172 bytes 14028 (13.6 KiB)
  180. RX errors 0 dropped 0 overruns 0 frame 0
  181. TX packets 172 bytes 14028 (13.6 KiB)
  182. TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
  183.  
  184. wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
  185. inet <ip_address> netmask <ip_address> broadcast <ip_address>
  186. inet6 fe70::aa27:ebfc:fg44:dbc4 prefixlen 64 scopeid 0x20<link>
  187. ether c8:e7:e2:64:hb:b3 txqueuelen 1000 (Ethernet)
  188. RX packets 163 bytes 17564 (17.1 KiB)
  189. RX errors 0 dropped 0 overruns 0 frame 0
  190. TX packets 105 bytes 16759 (16.3 KiB)
  191. TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement