View previous topic :: View next topic |
Author |
Message |
Remorse_Of_Nero n00b
Joined: 19 Jul 2004 Posts: 6 Location: Biochemist
|
Posted: Tue Jan 04, 2005 6:54 pm Post subject: Making a Ad-Hoc Wlan access point (mixing Wlan and Lan) |
|
|
Hi there
(this is kind of a poor mans howto )
Ive been trying to do this for the last three days and searched these forums and google and couldnt find anything usefull. I wanted the laptop to be able to access the internet connected supplied by an ADSL modem on another network (10.0.0.2) through a gentoo box
with a Wlan card (kinda acting as a acess point) installed working in Ad-Hoc mode
Tried making a bridge from Wlan0 / eht0, but couldn't make it work at all (I think you cant mix them). Most people talk about using a WLAN card with a prism chipset but I didnt have one
I have this setup:
ADSL-Router-10.0.0.2 <->HUB <->LAN 10.0.0.x<->10.0.0.9-eth0-Gentoo box-wlan0-10.0.1.1 < ~~> 10.0.1.10-wlan0 -laptop
All IPS static (dhcp doesn't work for the Wlan section)
But this is really easy when you know how:-
First make sure you have IP_FORWARD and stuff required for IPTABLES in the kernel on the gentoo-router and emerge IPTABLES (gies without saying )
and Ndiswrapper on all computers that want to use Wlan (really ...!!!! ) with the WLAN card driver installed
run this script on the gentoo-box when after booting (10.0.0.9- acting as a gateway for the
wlan netwok)
Code: | #! /bin/bash
iwconfig wlan0 mode Ad-Hoc essid rich channel 11 # turn other things on like encryption
ifconfig wlan0 -promisc 10.0.1.1 netmask 255.255.255.0 broadcast 10.0.0.255 # ip of wlan
# turn on forwarding
echo "1" > /proc/sys/net/ipv4/ip_forward # ip_forward needed in kernel
# setup iptables
iptables -F
iptables -A FORWARD -i eth0 -o wlan0 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
|
Then on each computer trying to connect to the WLAN run this script but change the IPs to whatever you want but not (10.0.1.1 cos thats the gentoo router)
BUT DO NOT USE dhcpcd to assign address to wlan cos it just dont work
Code: | #! /bin/bash
iwconfig wlan0 mode Ad-Hoc essid rich channel 11 # turn other things on like encryption
ifconfig wlan0 -promisc 10.0.1.10 netmask 255.255.255.0 broadcast 10.0.0.255 # ip
# route
route add -net 0.0.0.0 netmask 0.0.0.0 gw 10.0.1.1 |
This allows each Wlan to use 10.0.1.1 as a gatway, thus you can ping all the network and access the internet by 10.0.0.2. The ips of each network should be changed to what you need but works fine for me
Hope this helps some people trying to mix wired and wireless networks
Me a noob so maybe lots mistakes
All this thinking hurts me head
Thanks
Rich
p.s.
I guess this is quite insecure method but it works at the moment
If people have any ideas to better secure the Wlan please tell me ??????
Also I wonder whether these scripts should be run after booting (automatically, not worked how to do that yet) or the commands added to some other script somewhere else |
|
Back to top |
|
|
Helper_Monkey Tux's lil' helper
Joined: 22 Feb 2003 Posts: 141
|
Posted: Sun Jan 09, 2005 9:06 pm Post subject: |
|
|
thanks for this, I just tried it and it works great. _________________ It is a poverty to decide that a child must die so that you may live as you wish. -Mother Teresa |
|
Back to top |
|
|
dreville n00b
Joined: 17 Jul 2003 Posts: 13
|
Posted: Tue Dec 13, 2005 7:19 pm Post subject: |
|
|
Hi.
Thanks for these directions. Just wondering if somebody has figured out how to use DHCP with this setup.
Thanks. |
|
Back to top |
|
|
daeghrefn Tux's lil' helper
Joined: 02 Jan 2005 Posts: 112
|
Posted: Tue Dec 13, 2005 10:12 pm Post subject: |
|
|
I have a similar setup with DHCP working. Here's how:
1. emerge dhcp
2. man dhcrelay, read up on it.
3. nano /etc/conf.d/dhcrelay. Modify the IFACE list to include BOTH interfaces, the wireless iface AND the interface that connects to the network with the DHCP server on it. Add the IP address of the DHCP server, and your options, that you picked out from the dhcrelay man page. (I use "-q").
4. Modify your IPTables rules (or shorewall rules, or other frontend application if you use one) to allow your "router" to accept DHCP on both interfaces. This means both tcp and udp port 67.
5. /etc/init.d/dhcrelay start If you have no errors that's a good thing.
6. rc-update add dhcrelay default To add dhcrelay to your bootup.
7. Modify your /etc/dhcp/dhcp.conf file on your DHCP server, not the router, to add a new subnet for your wireless segment. It needs to be the same range as the IP assigned statically to the wireless interface.
8. Restart dhcpd on the DHCP server to apply the configuration changes. Reload your IPtables rules (or restart shorewall, or whatever frontend you use).
9. Connect.
A few things. In my setup, my gentoo router is the main router. I have a NIC through which my modem connects, a NIC through which the LAN connects, and a wireless interface which is hosting the wireless subnet, via hostapd, not ad-hoc. Secondly, the DHCP server needs to know how to route the DHCP packets. If the ADSL router is the server's "Default Gateway" the ADSL router won't know where 10.0.1.0 is at, so you may have to add a kernel route to tell it where to go.
For troubleshooting, check the logs on the DHCP server to verify which packets it is receiving. You should see the handshakes for the request.
Hopefully I am not being too vague. If you have any specific questions, let me know.
Oh, and as a side note, the SIMPLEST solution is to just run dhcpd on the machine that is connected to both networks. I didn't set it up that way for personal reasons (I wanted to make dhcp relay work). |
|
Back to top |
|
|
thecooptoo Veteran
Joined: 27 Apr 2003 Posts: 1353 Location: UK
|
Posted: Sun Feb 24, 2008 8:37 am Post subject: |
|
|
thanks -I'll have a look next time openoffice needs upgrading.
Is the problem that you cant use CIDR notation in /etc/distcc/hosts. Should the docs explicitly say that ? _________________ join the optout - http://nhsconfidentiality.org |
|
Back to top |
|
|
Lucipher Tux's lil' helper
Joined: 11 Feb 2007 Posts: 78
|
Posted: Sat Mar 29, 2008 8:28 pm Post subject: |
|
|
Just an update and a question.
Update: you don't need to put your network card in promiscuous mode, at least I didn't.
Question: is there any way to put up the server automatically on boot?
What I did on my laptop's /etc/conf.d/net was:
Code: | modules=( "iwconfig" )
mode_wlan0="ad-hoc"
essid_wlan0="HellPass"
channel_wlan0="10"
config_wlan0=( "192.168.10.5 netmask 255.255.255.0 broadcast 192.168.10.255" )
routes_wlan0=( "default via 192.168.10.10" )
|
and on my desktop was:
Code: |
modules=( "iwconfig" )
mode_wlan0="ad-hoc"
essid_wlan0="HellPass"
channel_wlan0="10"
config_wlan0=( "192.168.10.10 netmask 255.255.255.0 broadcast 192.168.10.255" )
|
The latter seems not work, however the laptop's configuration works perfectly. |
|
Back to top |
|
|
|