Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
If you want some security while doing something like this, I would use pfSense. – Brad Gilbert Jul 10 '09 at 16:04
up vote 4 down vote accepted

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


share|improve this answer

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 -t nat -I FORWARD -j USER_DEFINED_CHAIN
iptables -I USER_DEFINED_CHAIN <rule definitions of choice>
share|improve this answer

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

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.