Setup home network/wireless bridge

Share your own howto's etc. Not for support questions!

Setup home network/wireless bridge

Postby Ibidem » 2012-04-26 19:56

I saw a HOWTO request for setting up a home network for connection and file sharing, and I have notes left over from the last time I did something like that.
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

You will need a working internet connection, dhcp3-server, and iptables.

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

Stage 2:
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

Edit sysctl.conf as root and uncomment and reverse anything about "not a router"
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

Save, then run
Code: Select all
sysctl -p
ifconfig eth0 down
ifconfig eth0 up


Stage 2: Configuring ethernet & the DHCP server
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

If you did not configure the DHCP server on installation, you will need to edit /etc/default/dhcp3-server ( Lucid) or
Code: Select all
/etc/default/isc-dcp-server
(Squeeze; file/location varies with packaging);
Change the INTERFACE to the following:
Code: Select all
INTERFACE="eth0"

Save.

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;
}

Save.
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

On the machine which you are attempting to connect:
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

To check from the wireless bridge:
Code: Select all
ping -Rc 1 192.168.3.101
Thinkpad X100e/Debian Squeeze (All reposiories enabled)/Linux 3.4.11:
1GB RAM/1.6GHz Neo X2/ATI HD 3200/RTL8191SEVA2 wlan0, RTL8169 eth0
Ibidem
 
Posts: 160
Joined: 2010-12-24 18:28

Return to Docs, Howtos, Tips & Tricks

Who is online

Users browsing this forum: No registered users and 1 guest

fashionable