Adding a network card to Linux

I said yesterday I didn’t remember exactly how to add a network card to Linux machines. I found instructions today. They weren’t entirely correct. So here are instructions (hopefully more correct–I have access to exactly one Linux box right now) for adding a NIC in Linux.
First, determine which module your NIC uses, then install it temporarily with the following:

insmod [module name]

For example:

insmod rtl8139

In RPM-based distributions (Red Hat, Mandrake, Caldera, TurboLinux, UnitedLinux), edit the file /etc/modules.conf or /etc/conf.modules to add an alias for the module. In Debian-based distributions, edit the file /etc/modutils/aliases and then run the command update-modules. In any case, the format of the line to add is the same:

alias eth0 rtl8139

More likely, you’re adding a second NIC, in which case the line would look more like this:

alias eth1 rtl8139

In RPM distros, next you create an interface config file in /etc/sysconfig/network-scripts. The file is called ifcfg-[interface]. Here are a couple of example ifcfg-eth0 files:

# Static IP
DEVICE=eth0
IPADDR=192.168.0.33
NETMASK=255.255.255.0
BROADCAST=255.255.255.255
ONBOOT=yes

# DHCP
DEVICE=eth0
BOOTPROT=dhcp
ONBOOT=yes

In Debian, all network configuration info is kept in /etc/network/interfaces. Here’s a sample configuration:

iface eth0 inet dhcp

iface eth1 inet static
address 192.168.1.1
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255

SuSE is likely to be a bit different. Slackware is virtually guaranteed to be different. I haven’t looked at SuSE in three years and Slackware in five. Hopefully they’re similar enough that this can give you a start.

I’m sure there’s a graphical way to do this in some, if not all distributions, but I prefer to hit the configuration files directly. It’s much easier to explain, and the knowledge is much more portable.

4 thoughts on “Adding a network card to Linux

  • October 20, 2002 at 9:35 pm
    Permalink

    Nice timing, bud!

  • October 21, 2002 at 4:49 am
    Permalink

    This is is a keeper.

  • October 21, 2002 at 9:20 am
    Permalink

    I had no idea this posted. Sweet. (DSL problems last night.)

    One final thing: To enable the IP settings, issue this command:

    ifup eth1

    Of course, substitute your interface’s name. Or you can reboot, but why do you want to look like an NT sysadmin?

  • January 17, 2003 at 10:12 am
    Permalink

    Thanks

Comments are closed.

%d bloggers like this:
WordPress Appliance - Powered by TurnKey Linux