Setting up a WiFi AP in BackTrack Linux 5
# I'm using two wireless interfaces:
# Interface Chipset Driver
#
# wlan0 Broadcom b43 - [phy0]
# wlan1 Ralink RT2870/3070 rt2800usb - [phy1]
#
# I'm connected to a wireless network with wlan0
# My wlan1 is used to create the AP (an Alfa wireless USB dongle)
#
#install dhcp-server
apt-get install dhcp3-server
#backup the std. configuration-file
mv /etc/dhcp3/dhcp.conf /etc/dhcp3/dhcp3.conf.backup
#create a new dhcp-conf with class C IP and /25 subnet
nano /etc/dhcp3/dhcp.conf
#insert the following:
ddns-update-style ad-hoc;
default-lease-time 600;
max-lease-time 7200;
subnet 192.168.2.128 netmask 255.255.255.128 {
option subnet-mask 255.255.255.128;
option broadcast-address 192.168.2.255;
option routers 192.168.2.129;
option domain-name-servers 8.8.8.8;
range 192.168.2.130 192.168.2.140;
}
#the dhcp.conf ends here
#fire up the accesspoint
#create monitor-mode mon0
airmon-ng start wlan1
airbase-ng -e "AP_NAME" -c 9 mon0
# -e for name, -c for channel, on the monitor mon0
#this will create a virtuel interface called at0
#configuring at0 with the dhcp.conf
ifconfig at0 up
ifconfig at0 192.168.2.129 netmask 255.255.255.128
#add a route for the traffic
route add -net 192.168.2.128 netmask 255.255.255.128 gw 192.168.2.129
#192.168.2.128 == the netmask
#255.255.255.128 == the subnet which is /25
#192.168.2.129 == the gatway aka first avaible IP address on the network
#now point the new dhcp.conf to the dhcp3-server
dhcpd3 -cf /etc/dhcp3/dhcpd.conf -pf /var/run/dhcp3-server/dhcpd.pid at0
# run the following commands to flush all ip-tables and setup new ones
iptables --flush && iptables --table nat --flush && iptables --delete-chain && iptables --table nat --delete-chain &&
iptables --table nat --append POSTROUTING --out-interface wlan0 -j MASQUERADE &&
iptables --append FORWARD --in-interface at0 -j ACCEPT &&
echo 1 > /proc/sys/net/ipv4/ip_forward
#I wrote it this way, so that it's easy to put into a bash-script
#WiFi AP is now setup and should work..
# Links:
#
http://www.howtoforge.com/nat_iptables
#
http://adaywithtape.blogspot.com/200...irbase-ng.html