Hjælp til opsætning af 2 netkort

Få hjælp til at sætte programmer eller funktioner op.
michaeldk
Indlæg: 53
Tilmeldt: 16. okt 2009, 11:30
IRC nickname: Michael Andersen

Hjælp til opsætning af 2 netkort

Indlæg af michaeldk »

Hej ubuntu venner :)

Jeg står i den situation, at jeg skal opsætte en fildelings server - før brugte jeg freenas, men vil gerne konvertere over til Debian (ubuntu)

'Min udfordring ligger i, at jeg gerne vil konfigurer de to netkort, der sidder i maskinen, således at netkort A kun sender data og netkort B kun modtager.

Det var utroligt let i freenas, grundet web gui'en, men i Debian ubuntu står jeg altså og mangler lidt viden om dette emne.

Da maskinen køre headless, kræver det at det bliver opsat via CLI.

Håber der er nogle gæve netværks gutter, der kan hjælpe mig med problemet :)
michaeldk
Indlæg: 53
Tilmeldt: 16. okt 2009, 11:30
IRC nickname: Michael Andersen

Re: Hjælp til opsætning af 2 netkort

Indlæg af michaeldk »

Jeg er kommet så langt at jeg nu har fundet en guide til at bonde (redundans) af 2 netkort - men det løser stadig ikke mit problem :(

Måske der nogle der har lidt tips og tricks oppe i ærmet?

Til de interesserede :

vi /etc/modutils/aliases and add/edit the following:

alias bond0 bonding
alias eth0 e100
alias eth1 e100
options bonding mode=0 miimon=100


vi /etc/modutils/actions and add/edit the following:

probeall bond0 eth0 eth1 bonding


After editing the modprobe config files you need to run the command:

testbox# update-modules



vi /etc/network/interfaces and add/edit the following:

auto bond0
iface bond0 inet static
address 10.1.100.63
netmask 255.255.255.0
hwaddress ether 00:02:B3:48:50:2C
gateway 10.1.100.1
up ifenslave bond0 eth0 eth1
down ifenslave -d bond0 eth0 eth1



You do NOT set up entries for 'eth0' or 'eth1' outside of whats listed above under the 'bond0' entry. Bond0 will now be the interface that the kernel works with. running an 'ifconfig' will show all three interface (bond0,eth0,eth1), all with the same MAC and IP addresses.


And thats basically it. Now, all you should need to do is load the 'bonding' module and stop/start networking... and the apropriate modules should load automagically:

testbox:/# modprobe bonding
testbox:/# /etc/init.d/networking stoptestbox:/# /etc/init.d/networking start

You might have to play around with this part for a bit. For me I had to manually ifconfig up the bond0 device:

testbox:/# ifconfig bond0 10.1.15.63 netmask 255.255.255.0 up


Assuming that there were no errors, you should be able to test this out. Try and ping your IP address from another box. You'll notice both NICs responding to the ping requests back and forth (round robin). If you unplug eth0, you'll get an error the console the "eth0 has failed, eth1 becoming primary" or something like that (and visa versa if you unplug eth1). But you shouldn't drop any of the ping requests (or no more than a few), as it now has a redundant network connection.

In a higher end environment, you could plug each NIC into a separate switch (staying on the same VLAN) and further improve your high availability config... and so on and so forth.
michaeldk
Indlæg: 53
Tilmeldt: 16. okt 2009, 11:30
IRC nickname: Michael Andersen

Re: Hjælp til opsætning af 2 netkort

Indlæg af michaeldk »

perfekt - tror dælme jeg har fundet en løsning

Balance TLB
Adaptive Transmit Load Balancing. Incoming traffic is received on the active slave only, outgoing traffic is distributed according to the current load on each slave. Doesn't require special switch support


The one Debian package you will need to install is ifenslave, specifically ifenslace-2.6.

There is also an option for specifying a mode. This controls how the bonding driver decides which interface to transmit packets on. There are also options for handling received packets. Each of your two network cards will have a different physical (MAC) address and on an ethernet network, the machine transmitting a packet has to specify the physical address corresponding to the packet destination. To use both network interfaces for received packets you therefore need to either have a clever enough network switch that understands link aggregation or you need to subvert ARP: the system by which machines convert IP addresses into MAC addresses. The mode I use is balance-alb which uses ARP. If you're unsure, the documentation that I referred to earlier explains all the modes in detail.

Once you have the bonding driver installed, you need to ensure that it is loaded when your computer boots up. For this, you need to add an alias in the module-init-tools setup. This alias associates the kernel module with the network interface name (typically bond0). It is also necessary to specify the options. I added the following lines to /etc/modprobe.d/arch/i386:

Kode: Vælg alt

alias bond0 bonding
options bond0 mode=balance-alb miimon=100


That uses bond0 as the name for the network interface, balance-alb as the mode and MII based monitoring every 100 milliseconds.

The bond0, interface is then configured, using ifconfig, in the same way as you would previously configure your eth0 interface. For example:

Kode: Vælg alt

ifconfig bond0 123.123.123.4 netmask 255.255.255.0 up


Once you have configured the IP address, you just need to add the slave devices:

Kode: Vælg alt

ifenslave bond0 eth0 eth1


That should have leave you with the bond0 interface working. If it works, you'll want to ensure that ifenslave is run at the next reboot. From /etc/network/interfaces you can run ifenslave by using the "up" keyword. The following is what I have except that I've replaced real IP addresses with 'x's.

Kode: Vælg alt

auto bond0
iface bond0 inet static
        address xxx.xxx.xxx.xxx
        netmask 255.255.255.0
        network xxx.xxx.xxx.0
        broadcast xxx.xxx.xxx.255
        gateway xxx.xxx.xxx.1
        up /sbin/ifenslave bond0 eth0 eth1


With everything up, you'll want to test it out. Running /sbin/ifconfig -a will give you some idea. I also use bwm-ng to monitor bandwidth usage. And to really test it, try running a ping and then pull the network cables out in turn.


Link til guide : http://www.debian-administration.org/article/Aggregating_network_interfaces

Link til forklaringer : http://www.debianhelp.co.uk/bonding.htm


Nå jeg har haft mulighed for at afprøve dette, samt det fungere, vil jeg lukke tråden :)
AJenbo
Admin
Indlæg: 20884
Tilmeldt: 15. nov 2009, 15:04
IRC nickname: AJenbo
Geografisk sted: Vanløse, København

Re: Hjælp til opsætning af 2 netkort

Indlæg af AJenbo »

Hvis du vil gøre det grafisk kan du tilslutte ssh med -X for at forward X og så køre de grafiske programmer direkte.