Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm quite new to Linux networking.

I have a Debian PC with two Ethernet interfaces, one embedded on the motherboard and another on a PCI card. The first one, let say eth0 is connected to my router (which is connected to Inet). I want to "link" eth1 to eth0, in order to access my router (and Inet) when I plug a cable in eth1. The same way the eth0 cable is connected to one of my router's Ethernet ports.

The Debian PC should also be able to access Inet and LAN, and thus not simply behave as a "virtual link" between the cable plugged in eth0 (coming from my router) and the cable plugged in eth1 (going to another PC).

Is this achievable? How?

share|improve this question
add comment

1 Answer

up vote 5 down vote accepted

You can use a bridge interface. You can use brctl from bridge-utils to create a bridge interface. For example,

$ brctl addbr br0
$ brctl addif br0 eth0 eth1
$ brctl show
bridge name     bridge id               STP enabled     interfaces
br0             8000.00004c9f0bd2       no              eth0
                                                        eth1

So after adding interfaces eth0 & eth1 into the bridge device br0 you're left with the following setup. You can use ifconfig to see it:

$ ifconfig eth0
eth0      Link encap:Ethernet  HWaddr BC:AE:AA:34:22:11  
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
...

$ ifconfig eth1
eth1      Link encap:Ethernet  HWaddr BC:AE:AA:34:11:22  
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
...

And the bridge device with the IP address:

$ ifconfig br0
br0       Link encap:Ethernet  HWaddr BC:AE:C5:11:22:33  
          inet addr:192.168.1.20  Bcast:192.168.1.255  Mask:255.255.255.0
...
share|improve this answer
    
Actually, I'm using SSH, and when I added the if, my console has frozen, suggesting me that I lost the connection. I've noticed that eth1 wasn't in /etc/network/interfaces. Should I configured it manually before ? Thanks anyway for the help –  Maxime Piraux Aug 2 '13 at 17:31
    
@MaximePiraux: The Debian PC has to connect to the network through the bridge interface. –  Evan Teitelman Aug 2 '13 at 17:41
    
@MaximePiraux - when you bridge multiple network devices together they will no longer have their own IP addresses. The bridge device (br0) will. –  slm Aug 2 '13 at 18:40
    
@slm: Thank you for the additions to my answer. –  Evan Teitelman Aug 2 '13 at 18:46
1  
I hope you don't mind, it was easier to add to yours vs. starting a competing answer which usually is more confusing. If I ever do it and you disagree always feel free to roll it back. –  slm Aug 2 '13 at 18:48
show 5 more comments

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.