2

Is it possible to setup a linux box to act as a hub/switch between two interfaces? I have an ubuntu box connected wirelessly on wlan0. I'd like to connect up another machine to the ubuntu boxes eth0 and have the other machine use that connect AND be on the same network as the ubuntu box. Is this possible?

2

3 Answers 3

4

Hello "unknown" Google-User,

what you want is to set up a bridge rather than a router, if you want to span the subnet over lan and wlan. This will make your two NICs to behave like a switch.

Under Debian/Ubuntu, install the bridge-utils package. Then create a Bridge and add NICs to it:

brctl addbr br0
brctl addif br0 eth0 wlan0

HTH

0

Yes it is possible. What you describe is very simple:

echo 1 > /proc/sys/net/ipv4/ip_forward

Note that this will dissapear when you reboot the "router" box. If you want it to persist across reboots, then you will need to edit /etc/sysctl.conf and either add or edit the following line to look like this

net.ipv4.ip_forward = 1

EDIT: As usual, security comes later. Note that by doing this, any wardriver will be able to connect to your local network, bypassing all firewalls. To get it to firewall, also run (as root)

iptables -t nat -A FORWARD -j CHAIN-OF-YOUR-CHOICE

CHAIN-OF-YOUR-CHOICE might be INPUT, if you have a good chain set up. What I'd do instead is to do:

iptables -I INPUT -j USER_DEFINED_CHAIN
iptables -t nat -I FORWARD -j USER_DEFINED_CHAIN
iptables -I USER_DEFINED_CHAIN <rule definitions of choice>
0

As the question specifically says that they machines need to be on the same network, then IP forwarding or NAT/PAT isn't going to help.

What I think you want is to bridge the two interfaces. Maybe this "Ethernet Bridge + netfilter howto" can help.

IBM has also a nice guide how to build wireless access points in Linux

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .