Click to See Complete Forum and Search --> : Adding a second NIC
cs02rm0
12-12-2003, 11:10 AM
This is what my network looks like:
+---------+ +-----------+ +---------+
| LAN | ---- | Desktop |----| Laptop |
+---------+ +-----------+ +---------+
I haven't done art in a long time for good reasons.
The desktop has two network cards, eth0 goes off to a switch on the LAN which is in turn connected to an ADSL router. This is all fine on 192.168.7.x.
eth1 I want to work with the laptop so the laptop can access the internet - I don't want to recompile my kernel (I've tried far too many times unsuccessfully). Both machines run Debian. The desktop has been known to have Windows so I know all hardware works and I've bridged the connections in that before.
How do I accomplish this... please anyone? :)
why wouldn't you just connect the laptop to the switch?
cs02rm0
12-12-2003, 11:30 AM
Because the switch is on the wrong floor and I don't fancy a new cable, all the ports are full, etc.
Windows can do it in a couple of clicks, whilst I'm not looking for that, I can't believe it can be that hard?
Satanic Atheist
12-12-2003, 12:01 PM
It's dead easy. At least, in RedHat, Mandrake and Slackware (I've done it).
You may get away without recompiling the kernel... But more on that later.
First off, are you using two identical network cards? If so, the driver is compiled into the kernel, you need the following in /etc/lilo.conf or /etc/grub.conf:
append="ether=eth0, ether=eth1"
This forces the kernel to look for more than one network card on boot up.
If you have the drivers as modules, you need to add alias lines to /etc/modules.conf as documented here (http://www.tldp.org/HOWTO/Ethernet-HOWTO-2.html#ss2.4).
If the cards are different, you may get away with simply compiling the new drivers (make sure your kernel source code is installed) by downloading the driver to somewhere and issuing a make and a make install on it.
Lastly, why do you have so much trouble with the kernel? Once you've got it (and go through the options sensibly), build most stuff as modules and only compile in the real stuff that you need (like e2fs and e3fs) into the kernel. It's not that hard. Once you have a working .config file, keep a hold of it as it's an excelleny template for whatever you do in the future.
James
cs02rm0
12-12-2003, 01:40 PM
Thanks for that reply.
Both cards are different (one's a realtek, one a netgear I think). They both startup when the system does, but I then have to put eth1 down as eth0 doesn't work when eth1's up.
I'm not entirely sure what IP addresses I should be assigning - it's a bad idea for both cards to be 192.168.7.x isn't it? But having the laptop and eth1 as 192.168.6.x still doesn't stop it screwing up the desktop connection thru eth0.
I presume I need to add a route, or something like that perhaps... I have no clue really how these are supposed to be configured.
For some reason no tutorial on building a linux kernel has ever got me to the stage where I'm able to boot the new kernel. Beats me why, I've followed the tutorials word for word, there's always been unexpected bits they've not covered and things like that so I usually have go guess chunks which isn't such a great idea.
tecknophreak
12-12-2003, 04:14 PM
NICs: Try this
netconfig for eth0
ip: 192.168.0.5
netmask: 255.255.255.0
gateway: 192.168.0.1
Then, copy /etc/sysconfig/network-scripts/ifcfg-eth0 to /etc/sysconfig/network-scripts/ifcfg-eth1
Edit /etc/sysconfig/network-scripts/ifcfg-eth1 for
ip: 192.168.1.1
netmask: 255.255.255.0
gateway: 192.168.1.1
Next, type /sbin/service network restart
Both NIC cards should come up.
Run /sbin/ifconfig to check the settings for the NICs. Finally configure the ip/netmask/gateway for eth0 cards so that it will work on your lan.
Here's a little script I wrote for startup of one of my test machines. I have eth0 assigned to 192.168.0.1 and eth1 assigned to 192.168.1.1. Basically what you're looking for.
#! /bin/sh
echo 1 > /proc/sys/net/ipv4/ip_forward
/sbin/ipchains -F
/sbin/ipchains -P forward DENY
/sbin/ipchains -A forward -j MASQ -s 192.168.0.0/24 -d 0.0.0.0/0
/sbin/ipchains -A forward -j MASQ -s 192.168.1.0/24 -d 0.0.0.0/0
/sbin/route del -net 192.168.0.0 netmask 255.255.255.0
/sbin/route del -net 192.168.0.0 netmask 255.255.255.0
/sbin/route del -net 192.168.1.0 netmask 255.255.255.0
/sbin/route del -net 192.168.1.0 netmask 255.255.255.0
/sbin/route add -net 192.168.0.0 netmask 255.255.255.0 gw 192.168.0.1
/sbin/route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.1.1
You'll have to change a few things, because I'm guessing you're desktop won't be the gateway for the LAN. So just change the *.*.*.1 to *.*.*.n where n is your addy on the LAN.
Any help?
cs02rm0
12-13-2003, 07:01 AM
Thanks
I don't have /sbin/service (that's a RH program isn't it?) but setting IPs and getting the interfaces up with the IPs isn't a problem.
I don't have ipchains though - iptables and my conversion attempts didn't go so well!
My desktop's not the gateway, but the gateway is *.*.*.1 so I guess that's ok? (I'll just have to change the 3rd star as appropriate because the router comes with a default IP of *.*.7.1)
tecknophreak
12-13-2003, 11:47 AM
well, hell of a lot of good that did ya. Your desktop will be the gateway for your laptop though. The packets will go through your desktop to your lan, then through the router to the wan.