Stop hostapd and dnsmasq services
(self)
| 2789 | """ |
| 2790 | try: |
| 2791 | self.ap_logger.debug("Creating dnsmasq configuration file...") |
| 2792 | |
| 2793 | if not captive: |
| 2794 | config_content = self._dnsmasq_config_no_internet() |
| 2795 | elif dns_enabled: |
| 2796 | # Full configuration with DNS for captive portal |
| 2797 | config_content = f"""# Interface configuration |
| 2798 | interface={self.ap_interface} |
| 2799 | # DHCP range |
| 2800 | dhcp-range=192.168.4.2,192.168.4.20,255.255.255.0,24h |
| 2801 | # DHCP authoritative |
| 2802 | dhcp-authoritative |
| 2803 | # Bind to specific interface only |
| 2804 | bind-interfaces |
| 2805 | # Log DHCP activity |
| 2806 | log-dhcp |
| 2807 | # Gateway option |
| 2808 | dhcp-option=3,{self.ap_ip} |
| 2809 | # DNS option (point to ourselves for captive portal) |
| 2810 | dhcp-option=6,{self.ap_ip} |
| 2811 | # Enable DNS on port 53 |
| 2812 | port=53 |
| 2813 | # Listen only on our AP IP |
| 2814 | listen-address={self.ap_ip} |
| 2815 | # Don't read system files that might conflict |
| 2816 | no-resolv |
| 2817 | no-hosts |
| 2818 | no-poll |
| 2819 | # Captive portal - redirect all domains to AP |
| 2820 | address=/#/{self.ap_ip} |
| 2821 | # But allow some connectivity test domains to work |
| 2822 | server=/connectivitycheck.gstatic.com/8.8.8.8 |
| 2823 | server=/www.gstatic.com/8.8.8.8 |
| 2824 | server=/clients3.google.com/8.8.8.8 |
| 2825 | # Fallback DNS servers |
| 2826 | server=8.8.8.8 |
| 2827 | server=8.8.4.4 |
| 2828 | """ |
| 2829 | else: |
| 2830 | # Minimal configuration - DHCP only, no DNS conflicts |
| 2831 | config_content = f"""# Interface configuration |
| 2832 | interface={self.ap_interface} |
| 2833 | # DHCP range |
| 2834 | dhcp-range=192.168.4.2,192.168.4.20,255.255.255.0,24h |
| 2835 | # DHCP authoritative |
| 2836 | dhcp-authoritative |
| 2837 | # Bind to specific interface only |
| 2838 | bind-interfaces |
| 2839 | # Log DHCP activity |