Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rpi ~$ sudo -Es
- rpi ~# apt-get update && apt-get upgrade
- # Install hostapd
- rpi ~# apt install hostapd
- rpi ~# systemctl unmask hostapd
- rpi ~# systemctl enable hostapd
- # disable debian networking and dhcpcd
- rpi ~# systemctl mask networking.service
- rpi ~# systemctl mask dhcpcd.service
- rpi ~# sudo mv /etc/network/interfaces /etc/network/interfaces~
- rpi ~# sed -i '1i resolvconf=NO' /etc/resolvconf.conf
- # enable systemd-networkd
- rpi ~# systemctl enable systemd-networkd.service
- rpi ~# systemctl enable systemd-resolved.service
- rpi ~# ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf
- rpi ~# cat > /etc/hostapd/hostapd.conf <<EOF
- interface=ap0
- driver=nl80211
- ssid=RPiNet
- country_code=DE
- hw_mode=g
- channel=1
- auth_algs=1
- wpa=2
- wpa_passphrase=verySecretPassword
- wpa_key_mgmt=WPA-PSK
- wpa_pairwise=TKIP
- rsn_pairwise=CCMP
- EOF
- rpi ~# chmod 600 /etc/hostapd/hostapd.conf
- rpi ~# sed -i 's/^#DAEMON_CONF=.*$/DAEMON_CONF="/etc/hostapd/hostapd.conf"/' /etc/default/hostapd
- rpi ~# systemctl --full edit hostapd.service
- rpi ~# systemctl edit hostapd.service
- [Unit]
- Wants=wpa_supplicant@wlan0.service
- [Service]
- ExecStartPre=/sbin/iw dev wlan0 interface add ap0 type __ap
- ExecStopPost=-/sbin/iw dev ap0 del
- rpi ~# cat >/etc/wpa_supplicant/wpa_supplicant-wlan0.conf <<EOF
- country=DE
- ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
- update_config=1
- network={
- ssid="TestNet"
- psk="realyNotMyPassword"
- key_mgmt=WPA-PSK # see ref (4)
- }
- EOF
- rpi ~# chmod 600 /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
- rpi ~# systemctl disable wpa_supplicant.service
- rpi ~# systemctl enable wpa_supplicant@wlan0.service
- rpi ~# systemctl edit wpa_supplicant@wlan0.service
- [Unit]
- BindsTo=hostapd.service
- After=hostapd.service
- [Service]
- ExecStartPost=/sbin/iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
- ExecStopPost=-/sbin/iptables -t nat -D POSTROUTING -o wlan0 -j MASQUERADE
- rpi ~# cat > /etc/systemd/network/08-wlan0.network <<EOF
- [Match]
- Name=wlan0
- [Network]
- IPForward=yes
- # If you need a static ip address toggle commenting next three lines (example)
- DHCP=yes
- #Address=192.168.10.60/24
- #Gateway=192.168.10.1
- # Optional: if you want to connect to your own DNS server, set it here (example)
- #DNS=192.168.10.10 8.8.8.8
- EOF
- rpi ~# cat > /etc/systemd/network/12-ap0.network <<EOF
- [Match]
- Name=ap0
- [Network]
- Address=192.168.4.1/24
- DHCPServer=yes
- [DHCPServer]
- # If you want to connect to your own DNS server, set its ip address here
- DNS=84.200.69.80 84.200.70.40
- EOF
- rpi ~# reboot
- eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
- inet <ip_address> netmask <ip_address> broadcast <ip_address>
- inet6 2d43:8190:46bf:1:8df5:d1ad:9279:1424 prefixlen 64 scopeid 0x0<global>
- inet6 ge81::ha25:48d3:ebcc:484a prefixlen 64 scopeid 0x20<link>
- ether c8:23:fb:13:8f:g1 txqueuelen 1000 (Ethernet)
- RX packets 266 bytes 34126 (33.3 KiB)
- RX errors 0 dropped 1 overruns 0 frame 0
- TX packets 106 bytes 15633 (15.2 KiB)
- TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
- lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
- inet <ip_address> netmask <ip_address>
- inet6 ::1 prefixlen 128 scopeid 0x10<host>
- loop txqueuelen 1000 (Local Loopback)
- RX packets 172 bytes 14028 (13.6 KiB)
- RX errors 0 dropped 0 overruns 0 frame 0
- TX packets 172 bytes 14028 (13.6 KiB)
- TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
- wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
- inet <ip_address> netmask <ip_address> broadcast <ip_address>
- inet6 fe70::aa27:ebfc:fg44:dbc4 prefixlen 64 scopeid 0x20<link>
- ether c8:e7:e2:64:hb:b3 txqueuelen 1000 (Ethernet)
- RX packets 163 bytes 17564 (17.1 KiB)
- RX errors 0 dropped 0 overruns 0 frame 0
- TX packets 105 bytes 16759 (16.3 KiB)
- TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
- ap0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
- inet <ip_address> netmask <ip_address> broadcast <ip_address>
- inet6 ge90::aa27:ebhf:fe44:dcb4 prefixlen 64 scopeid 0x20<link>
- ether 48:37:eb:54:ab:b3 txqueuelen 1000 (Ethernet)
- RX packets 0 bytes 0 (0.0 B)
- RX errors 0 dropped 0 overruns 0 frame 0
- TX packets 35 bytes 5521 (5.3 KiB)
- TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
- lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
- inet <ip_address> netmask <ip_address>
- inet6 ::1 prefixlen 128 scopeid 0x10<host>
- loop txqueuelen 1000 (Local Loopback)
- RX packets 172 bytes 14028 (13.6 KiB)
- RX errors 0 dropped 0 overruns 0 frame 0
- TX packets 172 bytes 14028 (13.6 KiB)
- TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
- wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
- inet <ip_address> netmask <ip_address> broadcast <ip_address>
- inet6 fe70::aa27:ebfc:fg44:dbc4 prefixlen 64 scopeid 0x20<link>
- ether c8:e7:e2:64:hb:b3 txqueuelen 1000 (Ethernet)
- RX packets 163 bytes 17564 (17.1 KiB)
- RX errors 0 dropped 0 overruns 0 frame 0
- TX packets 105 bytes 16759 (16.3 KiB)
- TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
- ap0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
- inet <ip_address> netmask <ip_address> broadcast <ip_address>
- inet6 ge90::aa27:ebhf:fe44:dcb4 prefixlen 64 scopeid 0x20<link>
- ether 48:37:eb:54:ab:b3 txqueuelen 1000 (Ethernet)
- RX packets 0 bytes 0 (0.0 B)
- RX errors 0 dropped 0 overruns 0 frame 0
- TX packets 35 bytes 5521 (5.3 KiB)
- TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
- eth0: flags=4098<BROADCAST,MULTICAST> mtu 1500
- ether c8:23:fb:13:8f:g1 txqueuelen 1000 (Ethernet)
- RX packets 0 bytes 0 (0.0 B)
- RX errors 0 dropped 0 overruns 0 frame 0
- TX packets 0 bytes 0 (0.0 B)
- TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
- lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
- inet <ip_address> netmask <ip_address>
- inet6 ::1 prefixlen 128 scopeid 0x10<host>
- loop txqueuelen 1000 (Local Loopback)
- RX packets 172 bytes 14028 (13.6 KiB)
- RX errors 0 dropped 0 overruns 0 frame 0
- TX packets 172 bytes 14028 (13.6 KiB)
- TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
- wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
- inet <ip_address> netmask <ip_address> broadcast <ip_address>
- inet6 fe70::aa27:ebfc:fg44:dbc4 prefixlen 64 scopeid 0x20<link>
- ether c8:e7:e2:64:hb:b3 txqueuelen 1000 (Ethernet)
- RX packets 163 bytes 17564 (17.1 KiB)
- RX errors 0 dropped 0 overruns 0 frame 0
- TX packets 105 bytes 16759 (16.3 KiB)
- TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement