Sometimes you would either like to share internet or use Fancy wireless equipment to compete against corporate signal. Here are commands to setup a NAT to provide your device with internet and an IP. Afterwards you can create a RADIUS server to authenticate clients to your hardware.
I have created 2 scripts to do this automaticaly:
Share Internet: https://gist.github.com/Cablethief/9b75affb1d6f1a14fd989329b179cb87#file-share_internet-sh
Create RADIUS: https://gist.github.com/Cablethief/9b75affb1d6f1a14fd989329b179cb87#file-create_radius-sh
sudo ip addr add 192.168.55.1/24 dev enp0s20f0u2u3
sudo dnsmasq -i enp0s20f0u2u3 --dhcp-range=192.168.55.50,192.168.55.150,12h --dhcp-option=option:router,192.168.55.1 -q -d
sudo sysctl net.ipv4.ip_forward=1
sudo iptables -t nat -A POSTROUTING -o wlp58s0 -j MASQUERADE
sudo iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i enp0s20f0u2u3 -o wlp58s0 -j ACCEPT
openssl genrsa -out server.key 2048
openssl req -new -sha256 -key server.key -out csr.csr
openssl req -x509 -sha256 -days 365 -key server.key -in csr.csr -out server.pem
ln -s server.pem ca.pem
cat << EOF >> hostapd.radius_clients
0.0.0.0/0 P@ssw0rd
EOF
This requires certain compilation settings to work (CONFIG_DRIVER_NONE=y
), if your hostapd errors try using hostapd-mana which by default is compiled with the flag.
cat << EOF >> radius_server.config
driver=none
eap_server=1
eap_user_file=hostapd.eap_user
ca_cert=ca.pem
server_cert=server.pem
private_key=server.key
private_key_passwd=
radius_server_clients=hostapd.radius_clients
radius_server_auth_port=1812
logger_syslog=-1
logger_stdout=-1
logger_syslog_level=1
logger_stdout_level=1
EOF
Now you may add your radius server to your EAP configuration on your AP. An OpenWRT example may be seen here: https://gist.github.com/Cablethief/9b75affb1d6f1a14fd989329b179cb87#file-zopenwrtconfig-png.