Set up an AP using a wireless network card in Linux
Source: Internet
Author: User
In Linux, the wireless network card is used to set up an AP. due to the need of the experiment, we need to set up a wireless AP. after a long time, we finally finished the setup. Www.2cto.com my machine is equipped with two NICs, the wired Nic is connected to the network through the network, and there is also a Wireless NIC, as a wireless AP. In Linux, I used wireless network cards to set up an AP. because of the experimental requirements, I needed to set up a wireless AP. after a long time, I was able to build a wireless AP. Www.2cto.com my machine is equipped with two NICs, the wired Nic is connected to the network through the network, and there is also a Wireless NIC, as a wireless AP. Because madwifi driver is used in my experiment, I can only use a Nic with an Atheros chip. In theory, it is okay to change the driver. The first article on the official website of madwifi is that the kernel higher than 2.6.25 needs to be installed with a patched madwifi driver; otherwise, the compilation will not pass. My system is CentOS 6.3 and the kernel version is 2.6.32. At present, most kernels are generally higher than 2.6.25. Madwifi driver: kernel version 2.6.25 or earlier: http://madwifi-project.org/wiki/Releases/0.9.4 Kernel version 2.6.25 or later: http://snapshots.madwifi-project.org/madwifi-0.9.4-current.tar.gz Step 1: install madwifi 1. decompress the downloaded madwifi folder and enter the decompressed folder. # Tar zvxf madwifi * # cd madwifi * 2. if madwifi is already installed, clear it first. #. /Scripts/madwifi-unload #. /scripts/find-madwifi-modules.sh/lib/modules 2. compile and install madwifi # make install 3. if it was originally the ath5k driver, because it has a higher priority than madwifi, you need to disable the ath5k driver. # Modprobe-r ath5k # vi/etc/modprobe. d/blacklist. add blacklist ath5k 4 at the end of conf. load the madwifi driver and set it to AP mode. set the ssid to madwifi # modprobe ath_pci autocreate = ap # iwconfig ath0 essid "madwifi" # iwconfig ath0 key off, wireless devices should be able to find the "madwifi" signal. if your device shows an open signal, you can skip the following section. I disabled WEP encryption in Settings. In theory, it should be possible to connect without encryption, but here I show "using WPA/WPA2 PSK for protection ". After searching for half a day, I guess it may be that wpa_supplicant is playing a strange role. after uninstalling it together with NetworkManager, "madwifi" is displayed as an open network. If you do not want to unload wpa_supplicant and NetworkManager, you can modify the wpa_supplicant configuration file (/etc/wpa_supplicant/wpa_supplicant.conf .. I think these two software are useless to my experimental machine. just unload it .. Step 2 of www.2cto.com: Configure DHCP. The network segment of my wired network adapter is 192.168.0.1 and the gateway is 192.168.0.2. configure the network segment 192.168.3.1 for the wireless AP Lan. The device name of the wired network adapter is p128p1 and that of the wireless network adapter is ath0. 1. configure the nic ip address, Gateway, and other environments # because NetworkManager is killed, you need to start the network service. # Service network start # ifconfig p128p1 192.168.0.235 netmask 255.255.255.0 # route add default gw 192.168.0.2 p128p1 # ifconfig ath0 192.168.3.1 netmask 255.255.255.0 # ifconfig p128p1 on # ifconfig ath0 on 2. download and install the dhcp package # yum install dhcp 3. modify the dhcp configuration file/etc/dhcp/dhcpd. conf, and there is a dhcpd in/usr/share/doc/dhcp-4.1.1. conf. sample, which can be copied and directly changed. (Different versions may vary depending on the path .) # Cp/usr/share/doc/dhcp-4.1.1/dhcpd. conf. sample/etc/dhcp/dhcpd. conf # vi/etc/dhcp/dhcpd. conf: My configuration file is as follows. you can change it according to your network environment. the sample contains comments. DHCPDARGS = ath0; option routers 192.168.3.1; option broadcast-address 192.168.3.255; option subnet-mask limit 255.255.0; option domain-name "example.org"; option domain-name-servers 123.123.123.123; ddns-update-style ad-hoc; default-lease-time 21600; max-lease-time 43200; subnet 192.168.3.0 netmask 255.255.255.0 {range 192.168.3.50 192.168.3.254;} 3. start DHCP service www.2cto.com # service dhcpd start now your wireless The device connected to "madwifi" should be able to automatically or get an IP address. Next, let him connect to the Internet. Step 3: Use iptables for forwarding 1. install iptables # yum install iptables 2. start Kernel ip forwarding # echo '1'>/proc/sys/net/ipv4/ip_forward 3. set forwarding rules # modproble ip_conntrack # iptables-t filter-F # iptables-t nat-a postrouting-o p128p1-j masquerade OK, now your device should be able to access the Internet. If you still cannot access the Internet, check if you have written a mistake or reload the NIC. Step 4: set boot to start. this is the last step and the most important step. Otherwise, many configurations will be re-configured once the instance is restarted .. Write the command to the boot script and you can use www.2cto.com # vi/etc/rc. d/rc. add the following content at the end of the local file. the ip address or something may be slightly different because of different network environments. # Madwifi service network start ifconfig p128p1 uninstall netmask route add default gw 192.168.0.2 p128p1 modprobe-r ath_pci modprobe ath_pci autocreate = ap iwconfig ath0 essid madwifi ifconfig restart on ifconfig restart 192.168.3.1 netmask restart # dhcp dhcpd start # iptables echo '1'>/proc/sys/net/ipv4/ip_forward modproble ip_conntrack iptables-t filter-F iptables -T nat-F iptables-t nat-a postrouting-o p128p1-j MASQUERADE after restart, the wireless device can connect to "madwifi" and access the internet normally!
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.