LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   ethernet bridge for a LAN (ubuntu) (https://www.linuxquestions.org/questions/linux-networking-3/ethernet-bridge-for-a-lan-ubuntu-771042/)

andrews-mark 11-23-2009 12:54 PM

ethernet bridge for a LAN (ubuntu)
 
Hi - I have a problemo that is stumping me. I am trying to get a machine on a LAN to get to the internet. Seems quite like a standard problem, and its solution I presume involves an ethernet bridge. But so far, I have been unsuccessful.

The set up as follows (all machines are Ubuntu): Machine A has two NICs (eth0 and eth1). Machine B connects to Machine A through a switch connected to eth0. Machine A connects to internet via eth1. Machine A also is a dhcp server giving a local IP to Machine B. Here is a drawing
Code:

                          MACHINE A
  MACHINE B <===========  ETH0 ETH1  =========> INTERNET

Machine A serves Machine B an Ip address via dhcp. So I can use, say, ssh to go from Machine A to Machine B and back without any trouble. However, what I also really want to do is to go from Machine B out into the internet. At the moment this is impossible. So, e.g. doing "ping www.somedomain.org" will work from Machine A but not from Machine B.

I have tried to build a bridge by getting "bridge-utils" on ubuntu and running the following commands on Machine A:
Code:

sudo brctl addbr br0
sudo brctl addif br0 eth0
sudo brctl addif br0 eth1
sudo brctl stp br0 on

where my interface set up for Machine A is as shown below.

If I do "sudo brctl show", I get
Code:

bridge name    bridge id              STP enabled    interfaces
br0            8000.0016e6ddae0c      yes            eth0
                                                        eth1

but this does not work and all it does is shut down any internet/intranet on Machine A, and I have to do "sudo brctl delbr br0" to get it back.

I'm out of options now.

My two main questions are
1) To get Machine B to talk to the internet in the above scenario is it necessary to make a ethernet bridge, or is some other method to be used, if so, what?
2) If an ethernet bridge is correct, is there something obviously wrong with my setup.

thanks in advance,
mark



Code:

andrews@wotan ~> cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo eth0 eth1
iface lo inet loopback

# The internet interface
iface eth1 inet static
        address 128.40.26.160
        netmask 255.255.255.0
        network 128.40.26.0
        broadcast 128.40.26.255
        gateway 128.40.26.245
        up route add default gw 128.40.26.245 dev $IFACE
        down route del default gw 128.40.26.245 dev $IFACE
        # dns-* options are implemented by the resolvconf package, if installed
        dns-nameservers 144.82.100.1 144.82.100.41
        dns-search psychol.ucl.ac.uk

## The lan interface
iface eth0 inet static
        address 192.168.0.1
        netmask 255.255.255.0
        network 192.168.0.0
        up route add -net 192.168.0.0 netmask 255.255.255.0 dev $IFACE
        down route del -net 192.168.0.0 netmask 255.255.255.0 dev $IFACE


samborambo 11-23-2009 01:54 PM

You need to set up NAT, not bridging, on machine A. There are plenty of howto's on setting up NAT in ubuntu.

andrews-mark 11-24-2009 02:15 AM

many thanks for the tip on NAT. I'll look into it.
-m

andrews-mark 11-24-2009 07:05 AM

indeed I was barking up the wrong tree with the ethernet bridge. Nat is what I wanted, and with a few lines in my /etc/rc.local, namely
Code:

sysctl -w net.ipv4.ip_forward=1
/sbin/iptables -P FORWARD ACCEPT
/sbin/iptables --table nat -A POSTROUTING -o eth1 -j MASQUERADE

all is working now.

Many thanks to samborambo for the tip.

-m


All times are GMT -5. The time now is 02:22 PM.