I used Ubuntu Lucid for the machine, but the stuff I did was entirely CLI and should work on any Linux distro that's semi-standard. All (except one, mentioned later) the relevant files are in the same places under Squeeze.
Overview: The goal is to use a laptop as a wireless adapter for a desktop.
Here, it's a netbook with Madwifi drivers, running Lucid.
Stage 0: Know your systems:
In this case, client is NetBSD, using ethernet port bge0
Bridge is Lucid, connected to client on eth0, and to internet via ath0:
Code: Select all
_________
+------+ \ \
| | \________\ 192.168.2.114 \ /
| | 192.168.3.100| ath0|))))))))))))))))))\ /
| bge0[+-------------+]eth0 | [][][][]========...
+------+ +--------+ 192.168.2.1
192.168.3.101 192.168.3.1
BE SURE TO USE A SUBNET.
Eg, if you use 10.0.0.* while your IP is in the 192.168.*.* range, you must
manually add the proper route; I do not cover this.
ALL COMMANDS MUST BE RUN AS ROOT!
If redirection is listed, it must be done in a root shell;
|sudo tee is equivalent to > in a root shell
sysctl settings MUST be loaded before the interface on which the DHCP
server runs goes up (this cost me several minutes).
Stage 1:
Install packages:
Code: Select all
apt-get install iptables isc-dhcp-server dhcp3-server #last is a dummy package under Squeeze
Code: Select all
#allow forwarding
echo "1" > /proc/sys/net/ipv4/ip_forward #Don't do echo 1>/...--it doesn't do the same thing.
iptables -t nat -A POSTROUTING -o ath0 -j MASQUERADE
In other words, add these lines to /etc/sysctl.conf:
Code: Select all
#Enable routing
net.ipv4.conf.default.forwarding=1
net.ipv4.conf.all.forwarding=1
net.ipv4.conf.all.send_redirects = 1
net.ipv4.conf.all.accept_source_route = 1
net.ipv6.conf.all.accept_source_route = 1
Code: Select all
sysctl -p
ifconfig eth0 down
ifconfig eth0 up
Before doing this stage, I'd suggest plugging in the ethernet cable.
Any old cable will do; you don't need a special crossover cable.
#Note: the first IP address should be appropriate to your preferred subnet...
Code: Select all
ifconfig eth0 192.168.3.1 netmask 255.255.255.0 up
Code: Select all
/etc/default/isc-dcp-server
Change the INTERFACE to the following:
Code: Select all
INTERFACE="eth0"
Edit /etc/dhcp3/dhcpcd.conf #Exact name will vary, depending on packaging
Add this sort of section (EXAMPLE ONLY-change 192.168.*.* to suit your configuration):
Code: Select all
subnet 192.168.3.0 netmask 255.255.255.0 {
range 192.168.3.100 192.168.3.120;
option routers 192.168.3.1;
option domain-name-servers 192.168.2.1;
}
Note: use your preferred nameserver--eg, whoever resolv.conf points to, whether that's 192.168.2.1 or 8.8.8.8
Stage 3. Getting the network up.
On the machine which has internet:
Code: Select all
#Start the DHCP server:
service dhcp3-server restart
Code: Select all
dhclient bge0
#Messages indicate DHCP lease of 192.168.3.101 from 192.168.3.100
#From client:
ping -c 1 192.168.3.100
#Below is purely for troubleshooting the connection, and should not give you errors
ping -c 1 192.168.2.1
ping -c 1 8.8.8.8
nslookup google.com 8.8.8.8
nslookup google.com
ping -c 1 google.com
Code: Select all
ping -Rc 1 192.168.3.101