Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use hostapd to build Wireless routing in ubuntu

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

Ubuntu how to use hostapd to build wireless routing, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can gain something.

Because the company's IP is not fixed, static IP can not be used to configure raspberry pie ap mode, only one IP can be fixed to the wireless network card. If it is a fixed IP, using netplan is sufficient.

# This file describes the network interfaces available on your system# For more information, see netplan (5). Network: version: 2 renderer: networkd ethernets: eno1: dhcp4: no dhcp6: no addresses: [192.168.0.1 nameservers] gateway4: 192.168.0.1 nameservers: addresses: [8.8.8.8 1.1.1.1] wifis: wlp58s0: dhcp4: yes dhcp6: no access-points: "your-wifi-SSID-name": password: "your-wifi-password"

I use client dnsmasq + hostapd-wlan0-> iptables nat-> eth0

Hostapd

Hostapd configuration: / etc/hostapd/hostpad.conf

Interface=wlan0driver=nl80211ssid=MyWiFiNetworkhw_mode=gchannel=7wmm_enabled=0macaddr_acl=0auth_algs=1ignore_broadcast_ssid=0wpa=2wpa_passphrase=12345678wpa_key_mgmt=WPA-PSKwpa_pairwise=TKIPrsn_pairwise=CCMP

Modify hostapd default load configuration file: / etc/default/hostapd

DAEMON_CONF= "/ etc/hostapd/hostapd.conf"

Reload the systemd service and restart hostapd

Sudo systemctl unmask hostapdsudo systemctl enable hostapdsudo systemctl start hostapddnsmasq

Dnsmasq upstream dns configuration: / etc/resolv.dnsmasq

Nameserver 223.5.5.5nameserver 8.8.8.8

Dnsmasq configuration: / etc/dnsmasq.conf

Listen-address=192.168.89.1resolv-file=/etc/resolv.dnsmasqinterface=wlan0dhcp-range=192.168.89.2192.168.89.20255.255.255.0,24h

Unconfigure systemd-resolv: / etc/systemd/resolv.conf, unbind port 53:

[Resolve] DNS=192.168.89.1DNSStubListener=no

Modify the dnsmasq systemd service file: / lib/systemd/system/dnsmasq.service so that dnsmasq can bind fixed IP

[Unit] After=network-online.targetWants=network-online.target

Reload service, restart service

Systemctl daemon-reloadsystemctl restart systemd-resolved.servicesystemctl restart dnsmasq configuration Network

Netplan file: / etc/netplan/50-cloud-init.yaml

Network: ethernets: eth0: dhcp4: true optional: true wlan0: dhcp4: false addresses:-192.168.89.1 take 24 version: 2

Apply configuration:

Netplan applyNAT configuration

Configure kernel to allow forwarding: / etc/sysctl.d/99-sysctl.conf added:

Net.ipv4.conf.all.forwarding=1

Apply configuration:

Sysctl-p

Iptables:

Sudo iptables-t nat-A POSTROUTING-s 192.168.89.0 take 24-o eth0-j MASQUERADE

Install iptables-persistent to save iptables, boot and start automatic loading:

Sudo apt install iptables-persistent

After installation, you will be asked interactively whether to save the current iptables, or you can save it manually:

Sudo su-c 'iptables-save > / etc/iptables/rules.v4' is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report