I want to implement a basic captive portal. For the test setup, I have a mac mini connect to wifi (192.168.1.1) and ubuntu laptop connected to it via lan.
What I am trying to achieve is for the the mac-mini to act as a router itself and assign an ip to the ubuntu-laptop and control its traffic. I am new to networking so I have no idea with what I am working with.
I have googled a lot of stuff and have seen some examples like the following
- How can I setup my mac (OS X Yosemite) as an internet gateway
- Using iptables and PHP to create a captive portal
As far as I understand, my mini has:
en0which I believe is the wifi connection with ip 192.168.1.101
en1which I believe is the ethernet connection. I believe need a DHCP server to assign IP to devices that connect with it which is available by default, right?
What does the
sysctldo? The command
sudo sysctl -w net.inet.ip.fw.enable=1doesn't work and show
sysctl: unknown oid 'net.inet.ip.fw.enableerror
pfctlis the firewall and will do the actual blocking / redirecting.
As for how it should work, my understanding is the firewall will initially blacklist all ip/mac addresses. then for every new connection it will redirect to my localhost running apache where on successful login the php will remove the blacklisted ip. While I am hopeful to implement the apache/php part, I have no idea how the initial phase of gateway/ip/firewall stuff should be implemented.
TL;DR - How can I implement the gateway and firewall?
Assume that I am a total NOOB and detailed steps to work it out is welcome. But any help is appreciated. Thanks in advance