linux 2 nics

Joined
Apr 4, 2003
Messages
836
what's up, people?

i'm totally new to the linux and unix world, but i am learning. while i am nt new to computers in general, i posess only a basic knowledge of them, so please realize that i can edit scrits, etc...but can not write them (unless instructions are provided)

okay, so here's the deal.

i want to set up a router/firewall/nat box. i know enough about networking to be able to follow the howtos and get it done (i am also CCNA), so this is not my current problem.

right now, i have 2 nics in my linux box (i am actually writing this from my linux box, so it does work!). i am using vector linux, based on slackware and the 2.4 kernel. upon bootup, the kernel locates my eth0 (which has no cable in it right now) and tries to DHCP it. it finds nothing because there is no cable, no problem with me...

but it does not find the 2nd nic. i edited my modules.conf file and told the kernel what module to use. so after it boots, i can use dhclient and eth1 configures properly, in fact i am writing this on it as i mentioned earlier.

i looked at another howto and it says this:

By default, the Linux kernel only probes for one Ethernet device. You need to pass command line arguments to the kernel in order to force detection of furter board

can i edit the netdevice script or something to bring eth1 up at boot after eth0 is brought up?

thanks for the help.
 
You need to realize that identifying and providing drivers for a NIC is completely separate from running DHCP and/or giving it an IP altering the route table and bringing the interface up.

If you look at your boot mesages (or maybe just run dmesg), you should be able to see that the drivers for the card have come up and recognized the card.

The slackware scripts (as of 9.0, IIRC - I'm running -current on my machine) are written to do 4 cards (and could trivially be altered to do more). Look in your /etc/rc.d/rc.inet1.conf if Vector's startup files are close enough; otherwise read through /etc/rc.d/rc.inet1 and see where it reads the configurations from (hint, it'll be the line that says something about ifconfig)

On that same note, rc.ip_forward starts up ip-forwarding (routing), if you've got one of them, you might want to just toy with the settings for that.
 
If all else fails you could add the following into your rc.local file:

'dhclient eth1'
 
thanks for the help guys. actually, eth1 will be statically addressed once i get everything up and running, but i want DHCP on both interfaces now so i can learn how linux works (i.e. i must play with it to get it to work)

i edited rc.inet1 and here are the changes. i have not employed them yet, rc.inet1 is still intact as the original file. will the changes do what i expect them to?

Code:
#! /bin/sh
#
# rc.inet1      This shell script boots up the base INET system.
#
# Version:      @(#)/etc/rc.d/rc.inet1  2.00    10/06/1999
#

HOSTNAME=`cat /etc/HOSTNAME`

# Attach the loopback device.
/sbin/ifconfig lo 127.0.0.1
/sbin/route add -net 127.0.0.0 netmask 255.0.0.0 lo

# IF YOU HAVE AN ETHERNET CONNECTION, use these lines below to configure the 
# eth0 interface.

# Edit these values to set up a static IP address:
IPADDR="127.0.0.1"      # REPLACE with YOUR IP address!
NETMASK="255.255.255.0" # REPLACE with YOUR netmask!
NETWORK="127.0.0.0"     # REPLACE with YOUR network address!
BROADCAST=""    # REPLACE with YOUR broadcast address, if you
			# have one. If not, leave blank and edit below.
GATEWAY=""      # REPLACE with YOUR gateway address!

# To use DHCP instead of a static IP, set this value to "yes":
DHCP="yes"            # Use DHCP ("yes" or "no")

# OK, time to set up the interface:
if [ "$DHCP" = "yes" ]; then # use DHCP to set everything up:
  echo "Attempting to configure eth0 by contacting a DHCP server..."
  /sbin/dhcpcd eth0
elif [ ! "$IPADDR" = "127.0.0.1" ]; then # set up IP statically:
  # Set up the ethernet card:
  echo "Configuring eth0 as ${IPADDR}..."
  /sbin/ifconfig eth0 ${IPADDR} broadcast ${BROADCAST} netmask ${NETMASK}

  # If that didn't succeed, give the system administrator some hints:
  if [ ! $? = 0 ]; then
    cat << EOF
Your ethernet card was not initialized properly.  Here are some reasons why this
may have happened, and the solutions:
1. Your kernel does not contain support for your card.  Including all the 
   network drivers in a Linux kernel can make it too large to even boot, and
   sometimes including extra drivers can cause system hangs.  To support your
   ethernet, either edit /etc/rc.d/rc.modules to load the support at boottime,
   or compile and install a kernel that contains support.
2. You don't have an ethernet card, in which case you should comment out this
   section of /etc/rc.d/rc.inet1.  (Unless you don't mind seeing this error...)
EOF
  fi

  # Older kernel versions need this to set up the eth0 routing table:
  KVERSION=`uname -r | cut -f 1,2 -d .`
  if [ "$KVERSION" = "1.0" -o "$KVERSION" = "1.1" \
   -o "$KVERSION" = "1.2" -o "$KVERSION" = "2.0" -o "$KVERSION" = "" ]; then
    /sbin/route add -net ${NETWORK} netmask ${NETMASK} eth0
  fi

  # If there is a gateway defined, then set it up:
  if [ ! "$GATEWAY" = "" ]; then
    /sbin/route add default gw ${GATEWAY} netmask 0.0.0.0 metric 1
  fi
fi




#the rest has been modified, save for the end rc.inet1  declaration



# Edit these values to set up a static IP address:
IPADDR="127.0.0.1"      # REPLACE with YOUR IP address!
NETMASK="255.255.255.0" # REPLACE with YOUR netmask!
NETWORK="127.0.0.0"     # REPLACE with YOUR network address!
BROADCAST=""    # REPLACE with YOUR broadcast address, if you
			# have one. If not, leave blank and edit below.
GATEWAY=""      # REPLACE with YOUR gateway address!

# To use DHCP instead of a static IP, set this value to "yes":
DHCP="yes"            # Use DHCP ("yes" or "no")

# OK, time to set up the interface:
if [ "$DHCP" = "yes" ]; then # use DHCP to set everything up:
  echo "Attempting to configure eth1 by contacting a DHCP server..."
  /sbin/dhcpcd eth1
elif [ ! "$IPADDR" = "127.0.0.1" ]; then # set up IP statically:
  # Set up the ethernet card:
  echo "Configuring eth1 as ${IPADDR}..."
  /sbin/ifconfig eth1 ${IPADDR} broadcast ${BROADCAST} netmask ${NETMASK}

  # If that didn't succeed, give the system administrator some hints:
  if [ ! $? = 0 ]; then
    cat << EOF
Your ethernet card was not initialized properly.  Here are some reasons why this
may have happened, and the solutions:
1. Your kernel does not contain support for your card.  Including all the 
   network drivers in a Linux kernel can make it too large to even boot, and
   sometimes including extra drivers can cause system hangs.  To support your
   ethernet, either edit /etc/rc.d/rc.modules to load the support at boottime,
   or compile and install a kernel that contains support.
2. You don't have an ethernet card, in which case you should comment out this
   section of /etc/rc.d/rc.inet1.  (Unless you don't mind seeing this error...)
EOF
  fi


  # Older kernel versions need this to set up the eth1 routing table:
  KVERSION=`uname -r | cut -f 1,2 -d .`
  if [ "$KVERSION" = "1.0" -o "$KVERSION" = "1.1" \
   -o "$KVERSION" = "1.2" -o "$KVERSION" = "2.0" -o "$KVERSION" = "" ]; then
    /sbin/route add -net ${NETWORK} netmask ${NETMASK} eth1
  fi

  # If there is a gateway defined, then set it up:(i turned it off)
# if [ ! "$GATEWAY" = "" ]; then
 #  /sbin/route add default gw ${GATEWAY} netmask 0.0.0.0 metric 1
 #fi
fi

# End of rc.inet1
 
Should work, from what I can see (assuming you didn't mess anything up in the copy/paste job)
 
Back
Top