Listing 1. NIC Configuration for Slackware with a Static IP Address
(/etc/rc.d/rc.inet1)
#! /bin/sh
# rc.inet1 This shell script boots up the base
# INET system.
Version: @(#)/etc/rc.d/rc.inet1 1.01 05/27/93
#
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 the
# lines below to configure the eth0 interface.
# If you're only using loopback or SLIP, don't
# include the rest of the lines in this file.
# Edit for your setup.
IPADDR="192.168.0.1" # REPLACE with YOURS
NETMASK="255.255.255.0" # REPLACE with YOURS
NETWORK="192.168.0.0" # REPLACE with YOURS
BROADCAST="192.168.0.255" # REPLACE with YOURS,
# if you have one. If not, leave
# BLANK and edit below.
GATEWAY="" # REPLACE with YOUR gateway
# ADDED TO SUPPORT SECOND ETHERNET CARD
# Edit for your setup.
# ONLY USE NEXT 5 LINES FOR STATIC IP
IPADDRB="193.181.132.24" # REPLACE with YOURS
NETMASKB="255.255.255.0" # REPLACE with YOURS
NETWORKB="193.181.132.0" # REPLACE with YOURS
BROADCASTB="193.181.132.255" # REPLACE with YOURS
# if you have one. If not, leave
# BLANK and edit below.
GATEWAYB="193.181.132.1" # REPLACE with YOURS
# Config Eth Card 0
/sbin/ifconfig eth0 ${IPADDR} broadcast ${BROADCAST} netmask ${NETMASK}
# NOTE ONLY ONE OF FOLLOWING IS USED AT A TIME:
# ADDED TO SUPPORT SECOND ETHERNET - STATIC IP
# Config Eth Card 1
/sbin/ifconfig eth1 ${IPADDRB} broadcast ${BROADCASTB} netmask ${NETMASKB}
# ADDED TO SUPPORT SECOND ETHERNET - FOR DHCP IP<\n>
/sbin/dhcpcd eth1
# If the line above is uncommented, the code below
# can also be uncommented.
# It sees if the ethernet was properly
# initialized, and gives the admin some
# hints about what to do if it wasn't.
if [ ! $? = 0 ]; then
cat << END
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 boot
time, 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...)
END
fi
# Uncomment these to set up your IP routing table.
echo Setting Route to local LAN
/sbin/route add -net ${NETWORK} netmask ${NETMASK} eth0
# ADDED TO SUPPORT SECOND ETHERNET CARD FOR
# STATIC ADDRESS ONLY
# NOT REQUIRED FOR DHCP ACCESS (DHCP
# CREATES DEFAULT ROUTE)
echo Setting Route to Internet
/sbin/route add -net ${NETWORKB} netmask ${NETMASKB} eth1
# Setting default gateway to the Internet
echo Setting far end gateway
/sbin/route add default gw ${GATEWAYB} netmask 0.0.0.0 metric 1
# End of rc.inet1
Copyright © 1994 - 2019 Linux Journal. All rights reserved.