Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

3 Answers 3

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

HTH

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 -I INPUT -j USER_DEFINED_CHAIN
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

 
discard

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.