[Primipassi] ifconfig

Gianni Bianchini giannibi@firenze.linux.it
Mer 15 Maggio 2002 23:36:49 CEST


On Wed, May 15, 2002 at 09:11:35PM +0200, Fabio Nigi wrote:

> ora ci ho messo una slack, volevo iniziare a usare
> ifconfig(sarebbe l ora!!)
> ma sul manuale per le reti che ho comprato fa i peggio rigiri e alla fine
> non dice niente,
> quali sono i comandi classici per inserire :
> indirizzo ip, gateway, netmask...e  ....manca qualcosa??

Modificare il file /etc/rc.d/inet1, c'e' gia' qualcosa di predisposto
e non dovrebbe essere difficile. Allego il mio, non e' lungo, due
schede di rete, senza gateway, studiatelo. :)

Ciao.
Gianni.
-------------- parte successiva --------------
#!/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="192.168.0.1"	# REPLACE with YOUR IP address!
NETMASK="255.255.255.0"	# REPLACE with YOUR netmask!
NETWORK="192.168.0.0"	# REPLACE with YOUR network address!
BROADCAST="192.168.0.255"	# REPLACE with YOUR broadcast address, if you
			# have one. If not, leave blank and edit below.

IPADDR1="10.0.0.1"	# REPLACE with YOUR IP address!
NETMASK1="255.0.0.0"	# REPLACE with YOUR netmask!
NETWORK1="10.0.0.0"	# REPLACE with YOUR network address!
BROADCAST1="10.255.255.255"	# REPLACE with YOUR broadcast address, if you

GATEWAY=""	# REPLACE with YOUR gateway address!

# To use DHCP instead of a static IP, set this value to "yes":
DHCP="no"            # 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
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}

  echo "Configuring eth1 as ${IPADDR1}..."
  /sbin/ifconfig eth1 ${IPADDR1} broadcast ${BROADCAST1} netmask ${NETMASK1}


  # 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

    /sbin/route add -net ${NETWORK1} netmask ${NETMASK1} eth1

  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

. /etc/rc.d/rc.iptables

# End of rc.inet1


Maggiori informazioni sulla lista primipassi