# udhcpd conf=> NAT conf => kern conf=> headache

## Stefan Pantiru

OK, it is said that udhcpd is (allmost) the smallest dhcp server  that you can get, ergo the most easily configurable. Still...

I have three network cards as follows:

eth0      Link encap:Ethernet  HWaddr 00:00:00:00:00:00

          inet addr:192.168.0.1  Bcast:192.168.0.255  Mask:255.255.255.0

          inet6 addr: fe80::200:ff:fe00:0/64 Scope:Link

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:0 errors:0 dropped:0 overruns:0 frame:0

          TX packets:0 errors:17 dropped:0 overruns:0 carrier:34

          collisions:289 txqueuelen:1000

          RX bytes:0 (0.0 b)  TX bytes:1098 (1.0 Kb)

          Interrupt:18 Base address:0xc400

eth1      Link encap:Ethernet  HWaddr 00:02:44:6F:0F:56

          inet addr:10.0.14.120  Bcast:10.0.15.255  Mask:255.255.240.0

          inet6 addr: fe80::202:44ff:fe6f:f56/64 Scope:Link

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:475618 errors:0 dropped:0 overruns:0 frame:0

          TX packets:1416 errors:2 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000

          RX bytes:52238329 (49.8 Mb)  TX bytes:165200 (161.3 Kb)

          Interrupt:17 Base address:0xc000

eth2      Link encap:Ethernet  HWaddr 00:50:8D:57:0D:CA

          inet addr:192.168.0.2  Bcast:192.168.0.255  Mask:255.255.255.0

          inet6 addr: fe80::250:8dff:fe57:dca/64 Scope:Link

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:1 errors:0 dropped:0 overruns:0 frame:0

          TX packets:5 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000

          RX bytes:60 (60.0 b)  TX bytes:378 (378.0 b)

          Interrupt:20

Through eth1 I acces the Internet with a fixed IP. All I want is to share my connection to a laptop using Mandrake via eth2 and to an WindowsXP computer (I tried to convince the owner to (at least) TRY Linux - but his stubbornness is like reinforced concrete  :Mad:  ) via eth0.

By the way, why is the mac of my eth0 card 00:00:00:00:00:00? Just because it is integrated in my mainboard?

I looked for documentation but still haven't found answer to these VERY simple questions:

1)How exactely should my udhcpd.conf look like? I mean what "# The interface that udhcpd will use" shold be exactely, the one it uses to access the net or the one accessed by the others?

2)What IP should be set to "opt wins"?

3)What about "option lease"?

4)And especially, how do you STOP  :Smile:  the udhcpd server other way than by killing it?

I hope the answare to these questions will be useful for others too... A quick search for udhcp on this forum only returned four results or so, from which only one was somewhat related to my so-called problem... I'd be glad to receive even a RTFM but only if i'd receive the "M" for it...  :Very Happy: 

----------

## NeddySeagoon

Stefan Pantiru,

You cant do this 

 *Quote:*   

> eth0 Link encap:Ethernet HWaddr 00:00:00:00:00:00
> 
> inet addr:192.168.0.1 Bcast:192.168.0.255 Mask:255.255.255.0

  and this 

 *Quote:*   

> eth2 Link encap:Ethernet HWaddr 00:50:8D:57:0D:CA
> 
> inet addr:192.168.0.2 Bcast:192.168.0.255 Mask:255.255.255.0

 because having two interfaces on the same subnet won't work except in the case where one interface has a PPP link and packet forwarding is being used. 

Your MAC address of 00:00:00:00:00:00 for eth0 is a bit strange

You need Network Address Translation to share a single public IP address amonst several PCs. Try IPTables, which will do ypu a firewall too. Allocating IP addresses is the least of your problems just now.

----------

## Stefan Pantiru

I changed the netmask of my eth2 to 255.255.0.0 Now what?

And... my IP isn't so "public" since it is not visible from the internet. Now.. I couldn't tell you why is it not dynamically allocated by the ISP...

In this case... do I REALLY need NAT?

My friend (the one using XP) succeeded sharing this very same internet connection and I could connect to the Internet from both the laptop and THIS computer through HIS computer  :Smile: . But now we're trying to switch places... I got his network card (my current eth1) because iit's MAC is required for connection, and now I'm trying to start this DHCP server... 

Should I understand that this is  not the case to use a DHCP server? If this is true, then what exactely should I try? Recommend me a manual for IPTables for example.

If, on the other hand, udhcpd could be used, what should I put in that udhcpd.config file?

----------

## NeddySeagoon

Stefan Pantirum,

You need to look into MAC Spoofing, rather than move network cards around all the time. My ISP does not tie me to a fixed MAC address so I don't use it. I would be surprised if Liux doesn't offer it somehow though.

Choose two IP addresses for eth0  and eth2 in the form 192.168.M .1 with netmask 255.255.255.0 then we don't have to worry about one being a subnet of the the other and the confusion that causes. As long as M for eth0 <> Mfor eth2, nothining should break.

I don't see how you can make it work without NAT. Routing packets with source addresses in the 192.168 range to the world is not a good idea. They must all appear to come from 10.0.14.120. Also, any reply packets you may get need to be returned to the originating PC.

I copped out when I set up my home network. I put SmoothWall on an old PC (a high end 486 or later will do) so I can't help with reference material.

----------

## DaveArb

 *Stefan Pantiru wrote:*   

> OK, it is said that udhcpd is (allmost) the smallest dhcp server  that you can get, ergo the most easely configurable. Still...

 

I would like to object that "smallest" doesn't have anything to do with "most easily configurable"...   :Wink: 

If I understand correctly, you have a Gentoo box that you want to serve as a router and a hub to a laptop running Mandrake and an XP machine?

eth1 -> ISP. This already works?

eth0 -> XP

eth2 -> Mandrake

I'll assume for the moment that "XP" and "Mandrake" have no desire to speak to each other.

Configure eth0 with IP 192.168.0.1. Configure XP with IP 192.168.0.2. 

Configure eth2 with IP 198.168.1.1. Configure Mandrake with IP 192.168.1.2.

All netmasks are 255.255.255.0 . Broadcast addresses for eth0 and eth2 are xx.xx.xx.255, xx.xx.xx being the first three numbers of the IP for that interface. Set the DNS address for XP and Mandrake to 10.0.14.120 or your ISPs nameservers. If you use 10.0.14.120, Gentoo has to have its DNS address set to your ISPs nameservers.

With that accomplished, ensure that:

XP can ping 198.168.0.1

Mandrake can ping 198.168.1.1

Gentoo can ping 198.168.0.1 and can ping 198.168.1.1

When that all works, make sure Gentoo has iptables support compiled in kernel, and iptables is emerged.

In the file /etc/conf.d/iptables, ensure this line exists:

```
ENABLE_FORWARDING_IPv4="no"

```

Using your favorite editor, create a file named /var/lib/iptables/rules-save . This file needs to contain the following:

```
*nat

:PREROUTING DROP [0:0]

:POSTROUTING DROP [0:0]

:OUTPUT DROP [0:0]

-A POSTROUTING -o eth1 -j MASQUERADE

COMMIT

*filter

:INPUT DROP [0:0]

:FORWARD DROP [0:0]

:OUTPUT DROP [0:0]

COMMIT
```

Then run

```
rc-update add iptables default

/etc/init.d/iptables start
```

This should get the network up and running connected to the internet. The only part I'm not positive on is the default policy settings "DROP". This is copied from my production firewall that is a bit more complex.

There are a million ways to set this up, and this is but one of them. I've expressed everything as a directive because it's easier to follow that way, not because it is the only way the setup can work.

Dave

[edit]/me ruminates... The filter table needs to allow some things in and out. A minimal iptables setup needs to be bigger than that, unfortunately.

```
*filter

:INPUT DROP [0:0]

:FORWARD DROP [0:0]

:OUTPUT DROP [0:0]

-A OUTPUT -o eth1 -p udp --dport 53 -j ACCEPT

-A INPUT -i eth1 -p udp --port 53 -j ACCEPT

-A INPUT -i eth1 -p tcp --port 53 -j ACCEPT

-A FORWARD -o eth1 -p tcp -j ACCEPT

-A FORWARD -i eth1 -p tcp -m state --state ESTABLISHED,RELATED -j ACCEPT

COMMIT
```

The port 53 stuff is DNS. Receiving a tcp packet in return is unusual, but possible. The forward table allows anything to leave the network, and allows in packets that have a connection. This might still be too small, but it's a better approximation.

----------

## Stefan Pantiru

eth1 -> ISP already works, indeed.

Ill' just try that, it looks "doable".

Another small thing: how can I get Gentoo to remember my network cards' setings after reboot?

Found somewhere sometrhing like 

```
rc-update add net.eth1 default
```

but command fails saying there is no net.eth1 in /etc/init.d. So I tryed to manually create those net.eth0, net.eth1, net.eth2 files inspired by net.lo which was already there. This seemed to work only that it returned a dozen errors at startup saying something like: 

"Cannot get dependency of net.eth0" 

"Cannot get dependency of net.eth1" 

and so forth. And I also previously configured /etc/conf.d/net but where does this configuration help since rc-update searches some unexisting net.ethX files?

Now about the solution that DaveArb suggested: i'll try it of course... but I just can't stop thinking: 3 or 4 click in XP vs. half a day of configuring, failing, configuring again, failing again, searching docs, posting in forums, configuring and failing...  and still no hope i'll finish this supposely simple thing today... I'm getting a glimplse of the reasons Linux is quite unpopular among beginners... I think I'm having a headache.

----------

## DaveArb

[quote="Stefan Pantiru"]eth1 -> ISP already works, indeed.

Ill' just try that, it looks "doable".

Another small thing: how can I get Gentoo to remember my network cards' setings after reboot?

Found somewhere sometrhing like 

```
rc-update add net.eth1 default
```

but command fails saying there is no net.eth1 in /etc/init.d. So I tryed to manually create those net.eth0, net.eth1, net.eth2 files inspired by net.lo which was already there. This seemed to work only that it returned a dozen errors at startup saying something like:

 *Quote:*   

> 
> 
> ...
> 
> You should have already had a net.eth0 in /etc/init.d, it is installed by default (at least every time I've done an install). It is a little long to list here (287 lines), if you cannot come up with it somewhere else I'll do it though. Once you have a working net.eth0, you can either copy or link it to net.eth1. There are no interface-specific setting in these files, the interface specs go in /etc/conf.c/net.
> ...

 

I've set up more than a couple of Windows boxen in my career (a couple thousand, maybe?  :Wink: ). If you can set up a triple-homed XP box to perform NAT and port filtering for two downstream attached machines with "3 or 4 clicks", my hat is off to you!   :Very Happy: 

If one is hoping to set up a bare minimal working GUI machine that will connect to the internet, there is no doubt that startup is MUCH easier with Windows. Until the damn thing gets taken out by virus, malware, spyware, adware, Windows genetic drift, etc........

Dave

----------

## Stefan Pantiru

I think I've led you in confusion with that 'fixed' IP, so you supposed I need NAT. But I have the feeling is much more easier than that. 

In XP I hit "Share my internet connection"  choose the network cards connected to the machines to which I deliver Internet, on the other machine I set as gateway the local IP of the first PC and that was it!

So, where is NAT in all of this?

P.S. What about network card settings' saving problem?

P.P.S. Sorry for bothering you with such uninteresting problems (for you) but I just can't seem to get to an end with this...  :Crying or Very sad: 

----------

## DaveArb

 *Stefan Pantiru wrote:*   

> I think I've led you in confusion with that 'fixed' IP, so you supposed I need NAT. But I have the feeling is much more easier than that. 
> 
> In XP I hit "Share my internet connection"  choose the network cards connected to the machines to which I deliver Internet, on the other machine I set as gateway the local IP of the first PC and that was it!
> 
> So, where is NAT in all of this?

 

I think Windows Internet Connection Sharing does the NAT invisibly. NAT is a requirement because the IPs you are using (on Mandrake and XP) are private allocation, no router on the Internet is going to return packets to you that are in the netblock 192.168.0.0/16. NAT does two things, it converts all outgoing packets to your public IP so other routers can return them to you, and it keeps track of which of your machines the packets actually belong to.

To accomplish similar setup in Linux, change all your iptables' default policies to ACCEPT and leave the one POSTROUTING line in. You will have no security, just like a Windows computer. Not so good, look at all the 0wn3d Windows computers out there...

 *Stefan Pantiru wrote:*   

> P.S. What about network card settings' saving problem?

 

I need to know if your eth0 port comes up correctly on startup.

 *Stefan Pantiru wrote:*   

> P.P.S. Sorry for bothering you with such uninteresting problems (for you) but I just can't seem to get to an end with this... 

 

Nonsense, if it were uninteresting I wouldn't respond. I used to be a teacher and I miss it, this is how I get my "fix".  :Smile: 

Dave

----------

## davidblewett

I would highly recommend the firewall called Shorewall. It can be configured to perform NAT (or IP Masquerading, which is what you want). It's website is www.shorewall.net. They have a section describing setting up different types of networks. I found it much easier, and more secure than doing a home-brewed IPTables script. If you decided to emerge it, I would recommend emerging the ~x86 version.  You can do this by adding 

```
net-firewall/shorewall ~x86
```

 to the file 

```
/etc/portage/package.keywords
```

----------

## Stefan Pantiru

My eth0 used to came up correctly before I deleted unintentionatelly the net.eth0 file. Nou it obviously doesn't anymore... As I said previously, I tried to reconstruct this file, and somewhat succeded, except those errors I mentioned... 

So, once again what is /etc/conf.d/net used for? Since an aditional net.ethX is required, and it mainly contains the same information...

----------

## DaveArb

/etc/conf.d/net is where the information is stored, the IPs, netmasks, things like that, for all interfaces.

/etc/init.d/net.eth# is just the script to bring them on-line. I can't promise this is proper for your exact config, but here's the script from one of my machines:

```
#!/sbin/runscript

# Copyright 1999-2003 Gentoo Technologies, Inc.

# Distributed under the terms of the GNU General Public License v2

# $Header: /home/cvsroot/gentoo-src/rc-scripts/init.d/net.eth0,v 1.37 2004/04/14 17:27:34 agriffis Exp $

#NB: Config is in /etc/conf.d/net

if [[ -n $NET_DEBUG ]]; then

   set -x

   devnull=/dev/stderr

else

   devnull=/dev/null

fi

# For pcmcia users. note that pcmcia must be added to the same

# runlevel as the net.* script that needs it.

depend() {

   use hotplug pcmcia

}

checkconfig() {

   if [[ -z "${ifconfig_IFACE}" ]]; then

      eerror "Please make sure that /etc/conf.d/net has \$ifconfig_$IFACE set"

      eerror "(or \$iface_$IFACE for old-style configuration)"

      return 1

   fi

   if [[ -n "${vlans_IFACE}" && ! -x /sbin/vconfig ]]; then

      eerror "For VLAN (802.1q) support, emerge net-misc/vconfig"

      return 1

   fi

}

# setup_vars: setup variables based on $1 and content of /etc/conf.d/net

# The following variables are set, which should be declared local by

# the calling routine.

#   status_IFACE   (up or '')

#   vlans_IFACE      (space-separated list)

#   ifconfig_IFACE   (array of ifconfig lines, replaces iface_IFACE)

#   dhcpcd_IFACE   (command-line args for dhcpcd)

#   routes_IFACE   (array of route lines)

#   inet6_IFACE      (array of inet6 lines)

setup_vars() {

   local i iface="${1//\./_}"

   status_IFACE="$(ifconfig ${1} 2>${devnull} | gawk '$1 == "UP" {print "up"}')"

   eval vlans_IFACE=\"\$\{iface_${iface}_vlans\}\"

   eval ifconfig_IFACE=( \"\$\{ifconfig_$iface\[@\]\}\" )

   eval dhcpcd_IFACE=\"\$\{dhcpcd_$iface\}\"

   eval routes_IFACE=( \"\$\{routes_$iface\[@\]\}\" )

   eval inet6_IFACE=( \"\$\{inet6_$iface\[@\]\}\" )

   # BACKWARD COMPATIBILITY: populate the ifconfig_IFACE array

   # if iface_IFACE is set (fex. iface_eth0 instead of ifconfig_eth0)

   eval local iface_IFACE=\"\$\{iface_$iface\}\"

   if [[ -n ${iface_IFACE} && -z ${ifconfig_IFACE} ]]; then

      # Make sure these get evaluated as arrays

      local -a aliases broadcasts netmasks

      # Start with the primary interface

      ifconfig_IFACE=( "${iface_IFACE}" )

      # ..then add aliases

      eval aliases=( \$\{alias_$iface\} )

      eval broadcasts=( \$\{broadcast_$iface\} )

      eval netmasks=( \$\{netmask_$iface\} )

      for ((i = 0; i < ${#aliases[@]}; i = i + 1)); do

         ifconfig_IFACE[i+1]="${aliases[i]} ${broadcasts[i]:+broadcast ${broadcasts[i]}} ${netmasks[i]:+netmask ${netmasks[i]}}"

      done

   fi

   # BACKWARD COMPATIBILITY: check for space-separated inet6 addresses

   if [[ ${#inet6_IFACE[@]} == 1 && ${inet6_IFACE} == *' '* ]]; then

      inet6_IFACE=( ${inet6_IFACE} )

   fi

}

iface_start() {

   local IFACE=${1} i x

   checkconfig || return 1

   if [[ ${ifconfig_IFACE} != dhcp ]]; then

      # Show the address, but catch if this interface will be inet6 only

      i=${ifconfig_IFACE%% *}

      if [[ ${i} == *.*.*.* ]]; then

         ebegin "Bringing ${IFACE} up (${i})"

      else

         ebegin "Bringing ${IFACE} up"

      fi

      # ifconfig does not always return failure ..

      /sbin/ifconfig ${IFACE} ${ifconfig_IFACE} >${devnull} && \

      /sbin/ifconfig ${IFACE} &>${devnull}

      eend $? || return $?

   else

      # Check that eth0 was not brought up by the kernel ...

      if [[ ${status_IFACE} == up ]]; then

         einfo "Keeping kernel configuration for ${IFACE}"

      else

         ebegin "Bringing ${IFACE} up via DHCP"

         /sbin/dhcpcd ${dhcpcd_IFACE} ${IFACE}

         eend $? || return $?

      fi

      # Show address retrieved

      i=$(ifconfig ${IFACE} | grep -m1 -o 'inet addr:[^ ]*' | cut -d: -f2)

      [[ -n ${i} ]] && einfo "  ${IFACE} received address ${i}"

   fi

   if [[ ${#ifconfig_IFACE[@]} -gt 1 ]]; then

      einfo "  Adding aliases"

      for ((i = 1; i < ${#ifconfig_IFACE[@]}; i = i + 1)); do

         ebegin "    ${IFACE}:${i} (${ifconfig_IFACE[i]%% *})"

         /sbin/ifconfig ${IFACE}:${i} ${ifconfig_IFACE[i]}

         eend $?

      done

   fi

   if [[ -n ${inet6_IFACE} ]]; then

      einfo "  Adding inet6 addresses"

      for ((i = 0; i < ${#inet6_IFACE[@]}; i = i + 1)); do

         ebegin "    ${IFACE} inet6 add ${inet6_IFACE[i]}"

         /sbin/ifconfig ${IFACE} inet6 add ${inet6_IFACE[i]} >${devnull}

         eend $?

      done

   fi

   # Set static routes

   if [[ -n ${routes_IFACE} ]]; then

      einfo "  Adding routes"

      for ((i = 0; i < ${#routes_IFACE[@]}; i = i + 1)); do

         ebegin "    ${routes_IFACE[i]}"

         /sbin/route add ${routes_IFACE[i]}

         eend $?

      done

   fi

   # Set default route if applicable to this interface

   if [[ ${gateway} == ${IFACE}/* ]]; then

      local ogw=$(/bin/netstat -rn | awk '$1 == "0.0.0.0" {print $2}')

      local gw=${gateway#*/}

      if [[ ${ogw} != ${gw} ]]; then

         ebegin "  Setting default gateway ($gw)"

         # First delete any existing route if it was setup by kernel...

         /sbin/route del default dev ${IFACE} &>${devnull}

         # Second delete old gateway if it was set...

         /sbin/route del default gw ${ogw} &>${devnull}

         # Third add our new default gateway

         /sbin/route add default gw ${gw} >${devnull}

         eend $? || {

            true # need to have some command in here

            # Note: This originally called stop, which is obviously

            # wrong since it's calling with a local version of IFACE.

            # The below code works correctly to abort configuration of

            # the interface, but is commented because we're assuming

            # that default route failure should not cause the interface

            # to be unconfigured.

            #local error=$?

            #ewarn "Aborting configuration of ${IFACE}"

            #iface_stop ${IFACE}

            #return ${error}

         }

      fi

   fi

   # Enabling rp_filter causes wacky packets to be auto-dropped by

   # the kernel.  Note that we only do this if it is not set via

   # /etc/sysctl.conf ...

   if [[ -e /proc/sys/net/ipv4/conf/${IFACE}/rp_filter && \

         -z "$(grep -s '^[^#]*rp_filter' /etc/sysctl.conf)" ]]; then

      echo -n 1 > /proc/sys/net/ipv4/conf/${IFACE}/rp_filter

   fi

}

# iface_stop: bring down an interface.  Don't trust information in

# /etc/conf.d/net since the configuration might have changed since

# iface_start ran.  Instead query for current configuration and bring

# down the interface.

iface_stop() {

   local IFACE=${1} i x aliases inet6 count

   # Try to do a simple down (no aliases, no inet6, no dhcp)

   aliases="$(/sbin/ifconfig | grep -o "^$IFACE:[0-9]*" | tac)"

   inet6="$(ifconfig ${IFACE} | awk '$1 == "inet6" {print $2}')"

   if [[ -z ${aliases} && -z ${inet6} && ! -e /var/run/dhcpcd-${IFACE}.pid ]]; then

      ebegin "Bringing ${IFACE} down"

      /sbin/ifconfig ${IFACE} down &>/dev/null

      eend 0

      return 0

   fi

   einfo "Bringing ${IFACE} down"

   # Stop aliases before primary interface.

   # Note this must be done in reverse order, since ifconfig eth0:1 

   # will remove eth0:2, etc.  It might be sufficient to simply remove 

   # the base interface but we're being safe here.

   for i in ${aliases} ${IFACE}; do

      # Delete all the inet6 addresses for this interface

      inet6="$(ifconfig ${i} | awk '$1 == "inet6" {print $3}')"

      if [[ -n ${inet6} ]]; then

         einfo "  Removing inet6 addresses"

         for x in ${inet6}; do 

            ebegin "    ${IFACE} inet6 del ${x}"

            /sbin/ifconfig ${i} inet6 del ${x}

            eend $?

         done

      fi

      # Stop DHCP (should be N/A for aliases)

      # Don't trust current configuration... investigate ourselves

      if /sbin/dhcpcd -z ${i} &>${devnull}; then

         ebegin "  Releasing DHCP lease for ${IFACE}"

         for ((count = 0; count < 9; count = count + 1)); do

            /sbin/dhcpcd -z ${i} &>${devnull} || break

            sleep 1

         done

         [[ ${count} -lt 9 ]]

         eend $? "Timed out"

      fi

      ebegin "  Stopping ${i}"

      /sbin/ifconfig ${i} down &>${devnull}

      eend 0

   done

   return 0

}

start() {

   # These variables are set by setup_vars

   local status_IFACE vlans_IFACE dhcpcd_IFACE 

   local -a ifconfig_IFACE routes_IFACE inet6_IFACE

   # Call user-defined preup function if it exists

   if [[ $(type -t preup) == function ]]; then

      einfo "Running preup function"

      preup ${IFACE} || {

         eerror "preup ${IFACE} failed"

         return 1

      }

   fi

   # Start the primary interface and aliases

   setup_vars ${IFACE}

   iface_start ${IFACE} || return 1

   # Start vlans

   local vlan

   for vlan in ${vlans_IFACE}; do

      /sbin/vconfig add ${IFACE} ${vlan} >${devnull}

      setup_vars ${IFACE}.${vlan}

      iface_start ${IFACE}.${vlan}

   done

   # Call user-defined postup function if it exists

   if [[ $(type -t postup) == function ]]; then

      einfo "Running postup function"

      postup ${IFACE}

   fi

}

stop() {

   # Call user-defined predown function if it exists

   if [[ $(type -t predown) == function ]]; then

      einfo "Running predown function"

      predown ${IFACE}

   fi

   # Don't depend on setup_vars since configuration might have changed.

   # Investigate current configuration instead.

   local vlan

   for vlan in $(ifconfig | grep -o "^${IFACE}\.[^ ]*"); do

      iface_stop ${vlan}

      /sbin/vconfig rem ${vlan} >${devnull}

   done

   iface_stop ${IFACE} || return 1  # always succeeds, btw

   # Call user-defined postdown function if it exists

   if [[ $(type -t postdown) == function ]]; then

      einfo "Running postdown function"

      postdown ${IFACE}

   fi

}

# vim:ts=4
```

This exact same file becomes /etc/init.d/net.eth0, /etc/init.d/net.eth1, and so forth. The settings are read from /etc/conf.d/net .

Dave

(Note to crowd: If there is a better way to handle this on this forum than posting a multi-hundred line code block, please let me know...)

----------

## NeddySeagoon

DaveArb,

A better way is to put it on the web and include a link in the post or even PM the file but then the thread loses its usefulness to others who may have deleted their /etc/init.d/net.ethN file.

Many users here either don't have webspace or don't know how to use it.

----------

## Stefan Pantiru

I tried the configuration from DaveArb and (as it was to good to be true), the command 

```
rc-update add net.eth0 default
```

 says that net.eth0 can not be executed.

Now why would a nice command like that return such an error on such a cute conf file?

----------

## NeddySeagoon

Stefan Pantiru,

...because you didn't set the eXecute bit on the file.

Its permissions, owner and group should be

 *Quote:*   

> -rwxr-xr-x  1 root root 8823 May  8 13:37 net.eth0

 

You man need to do

```
chmod 755 net.eth0

chgrp root net.eth0

chown root net.eth0
```

to set it all to rights.

----------

## Stefan Pantiru

Thanks for the hint, NeddySeagoon... silly me! Didn't cross my mind...

But now, guess what? It sais the file has an 

Problem #1: syntax error, so it still doesn't work. I wonder what's wrong, I used the script from DaveArb... Of course, it is a chance it isn't fit for my sistem, but still, a syntax error?? Hm...

 And another thing:

Problem #2: the intel8x0 module for my integrated nvidia nforce-audio chip can't be found at boot time, which results in not loading the alsa driver... where should be this module located, and where can I get it from?

----------

## DaveArb

 *Stefan Pantiru wrote:*   

> Thanks for the hint, NeddySeagoon... silly me! Didn't cross my mind...
> 
> But now, guess what? It sais the file has an 
> 
> Problem #1: syntax error, so it still doesn't work. I wonder what's wrong, I used the script from DaveArb... Of course, it is a chance it isn't fit for my sistem, but still, a syntax error?? Hm...
> ...

 

There are a couple places in the script I posted where it appears there is some wordwrap, at least on the browser I'm using right now. It seems like if I cut and paste it, it comes out OK though.

The fourth line of the script, that starts "# $Header:", the $ that appears to be on the next line, should be at the end of line 4.

Way further down, look for:

```
         ifconfig_IFACE[i+1]="${aliases[i]} ${broadcasts[i]:+broadcast ${broadcasts[i]}} ${netmasks[i]:+netmask ${netmasks[i]}}"
```

Make sure that's all one line. Those are the only two problems I notice. Posting the exact syntax error produced might help.

Dave

P.S. for NeddySeagoon: Thanks for the posting advice. I had lost track of this thread.

----------

## Stefan Pantiru

I've observed some laws governing gentoo setup (Murphy style) which I must share with you...

 1 ) There is no such a thing as a perfect installation of gentoo. One who would think such a thing has missed something... Even if it's just about a workaround done by kernel at startup or 10 useless modules for which unnecessary support is enabled... But optimum is not tangible.

2 ) One single, simple, error may cauze dozens of unsolvable errors when trying to fix it in the lack of necessary knowledge.

3 ) There is no such a thing as sufficient knowledge, either...

4 ) There are problems that do not have solution at all...

5 ) One that realizes 4), has already spent his entire weekend trying to find this phantasmagoric solution instead of spending it with his girlfriend or doing something usefull...

6 ) No matter how many previous problems one has solved (or think he has solved), that will not, I repeat will not help him solve the newly rised problem.

7 ) The more one think he knows, the more damage he will cause when cotrary has proven itself...

8 ) If one plans to copy a file to his home directory, or just to surf the net he should NOT do it unless he has previously made a back-up of all his data, preferably on more than one device and gathered all the required manuals, hardware info, disks and to be prepared to reinstall everything from scratch... just in case..

9 ) Trying to solve something using the forums has very little chance of success. In most cases it will generate literature (just like in this case) and after tens of posts everyone will eventually get bored and leave... even the one with the problem...

10 ) Booting Windows after trying to install gentoo (and fail of course) is like getting home from Vietnam.

I could keep on going but I might creaty angry and I hate that.... Actually this could be considered self-irony, becauze me myself shall keep on trying. Who knows maybe in a month or two... my gentoo will work at reasonable parameters... meaning: ALSA will work, my network cards will work.. I'll be able to share the Internet connection with the other two computers... No error messges, no warnings at startup. 

What a beautiful dream... But i'll probably wake-up and install Mandrake.

This should be probably somewhere in "Off the wall"... I'm sorry for that too.

----------

## Stefan Pantiru

But still, I'll give it one more try...

Things present themselves like this:

- No succes in detecting the syntax error in that net.ethX file (the word wrap was not it)

    - If someone else would be so kind to send me another one to compare them or something...

    - And also to remind me what was the command to identify the differences between two files...

- No succes in loading the Intel8x0 driver either...

- I tryed to upgrade the kernel to 6.6-rc1 and succeded.

- No more Intel8x0 problem, but now my X doesn't start...

- The X doesn't start because nvidia drivers are not loaded

- The nvidia drivers are not loaded but I can't even emerge them... I get that stupid "incorrect /usr/src/linux link" error... I corrected the link, I'm sure...  but "#emerge nvidia-kernel" doesn't fall for that...

- I tryed to emerge e newer version of nvidia-kernel... but I noticed my fealnx driver for my Surecom network card isn't loaded...

- modprobe fealnx fails saying there is no such driver...

- I follwed some of the possible sollutions I found on this forum... like uninstalling... deleting fealnx.o.. reemerging.. naaaah.. doesn't work...

- Anyone knows a solution for my fealnx driver? I mean it worked perfectly before (with the 2.4 kernel...) and now it is nowhere to find... please provide me at least with control comands (like to find out where the problem occured) and please be very specific...

Basically my main problem now is to setup networkin again... the irony is that of all the 3 network card I have in my sistem, the one for which I have no driver is EXACTELY the one connected to the Internet...

I realize the difficulty of getting answers to all this problems... I'm really trying you know... but as in those 10 laws (more or less) I seem to get it worse every time... I'm sorry for my incapacity of solving myself theese problems... and for my lack of knowledge in the field (which is, ultimatelly the mother of "cannot-do-it"'s).

----------

## NeddySeagoon

Stefan Pantiru,

You can get my net.eth0 script here http://62.3.120.141/linux_stuff/net.eth0 copy it to /etc/init.d/net.eth0 or look through it for word wraps.

For emerging the nVidia drivers, the /usr/src/linux link needs to point to the kernel source tree you want to emerge against and you need to be running that kernel too because the nVida driver gets installed in /lib/modules/<uname -r>/video/

Either /usr/src/linux points to the wrong kernel, or you didn't install the kernel - maybe forgot to mount /boot before the copy?

Didn't fix grub.conf to point to the new kernel as well as the old one? 

Does uname -a tell you the right kernel version and compile date?

Under 2.6 kernels module names changed. They all end in .ko now. Did you emerge modutils when you switched to 2.6?

It needs a later modutils that 2.4 (you may have it already as part of an emerge world -u).

How did you configure you first 2.6 kernel? From scrach or by copying the 2.4 .config file over, then running make oldconfig?

Moving from 2.4 to 2.6 is a big step, best done piecemeal. Have two (or more) kernels in /boot and two (or more) startup blocks in grub.conf so that you can choose at boot which kernel to use. That way, when your new kernel breaks on you, you can go back to the old one, because its still there.

----------

## Stefan Pantiru

Tnank you, NeddySeagoon for your net.eth0 file. It works perfectly know (I returned to my old 2.4.25-gentoo-r2 kernel and postponed the configuration of the new one.

But still, yes, "uname -a" was returning the correct output and /usr/src/linux was pointing to kernel-2.6.6-rc1...

But now I'm back in 2.4.25 and I have this (hopefully) final problem to solve: my snd-intel8x0 module doesn't load...

```
# modprobe snd-intel8x0

/lib/modules/2.4.25-gentoo-r2/kernel/sound/pci/snd-intel8x0.o: init_module: No such device

Hint: insmod errors can be caused by incorrect module parameters, including invalid IO or IRQ parameters.

      You may find more information in syslog or the output from dmesg

/lib/modules/2.4.25-gentoo-r2/kernel/sound/pci/snd-intel8x0.o: insmod /lib/modules/2.4.25-gentoo-r2/kernel/sound/pci/snd-intel8x0.o failed

/lib/modules/2.4.25-gentoo-r2/kernel/sound/pci/snd-intel8x0.o: insmod snd-intel8x0 failed
```

I searched the forum... but did not find anything helpful...

----------

## Stefan Pantiru

For DaveArb: I'm sorry, but the solution you suggested few days ago encountered an error:

```
#/etc/init.d/iptables start
```

says

```
* Loading iptables state and starting firewall...

 * Restoring iptables ruleset

Bad argument `:PREROUTING'

Error occurred at line: 2

Try `iptables-restore -h' or 'iptables-restore --help' for more information.
```

Bad argument "PREROUTING"? Hm...

----------

## NeddySeagoon

Stefan Pantiru,

I'll stick with your sound problem although I used OSS until I moved to a 2.6 kernel.

The error message implies that you either did not make the snd-intel8x0 or its not installed in your 2.4.x kernel. Very possibly because installing ALSA (thats an ALSA module) is a PIA with 2.4.

You could try emerging the nVidia sound module.

There are several scripts to set up a firewall/NAT. Shorewall and Firestarter come to mind. I'm a SmoothWall user, so I've not used any of them.

----------

## Stefan Pantiru

The problem with 

```
* Loading iptables state and starting firewall...

* Restoring iptables ruleset 

Bad argument `:PREROUTING' 

Error occurred at line: 2 

Try `iptables-restore -h' or 'iptables-restore --help' for more information.
```

has been solved. The cause? A blank space at the beginning of the line, just before ":PREROUTING". Sorry for the inconvenience.

----------

## Stefan Pantiru

For NeddySeagoon: I reemerged nforce-audio. So what?

----------

## Stefan Pantiru

BIG CRY FOR HELP... DaveArb or anyone around... I can't get the laptop (now using Windows2000, not Mandrake) OR the XP to ping me...

[cry]WHYY??[/cry]

And I'm also on the presure of time here...

I have 3 NIC's as I said before... on my eth2 I have:

IP 192.168.1.1

bcast 192.168.1.255

netmask 255.255.255.0

On Windows 2000 (connected to my eth2, of course) I have

IP 192.168.1.2

netmask 255.255.255.0

gateway 192.168.1.1

And 2000 can't ping me. WHY?

My eth1 is connected to Internet. But for now i have not started ipdables yet.. What's the point, since they can't access my Gentoo box?

P.S. I thank to NeddySeagoon and DaveArb for keeping an eye on this thread...

----------

## NeddySeagoon

Stefan Pantiru,

On the audio front you should have a new sound driver. Use that under 2.4, not the intel one.

Windows XP comes with a firewall. The default used to be disabled but a recent Service Pack set up some more sensible security defaults throughout. Turn off the XP firewall if its on.

You do have all the drivers loaded for all three NICs?

If not, you won't have an eth2 in your linux box to connect to.

If you have does any changes to the NIC module load order, that will have rearranged the numbering too.

============== edit ======================

The routing tables on both boxes would be helpful to see.

HTH

----------

## Stefan Pantiru

Ok, there is that nvaudio driver but what should I have in /etc/make.conf instead of

```
ALSA_CARDS="intel8x0"
```

 and what should I have in /etc/modules.d/alsa, instead of 

```
alias snd-card-0 intel8x0
```

I do have all ther drivers loaded and functioning, and all hardware connections are properly made. And I'm talking about 2000 now, not necesarily XP... They can't seem to see me for some reason. I can't ping them, they can't ping me on neither of the NICs. The same connections work when I boot my WindowsXP and I can even deliver net to both of them with "Share your internet connection". Weird... I mean... they can't even ping me?

----------

## Stefan Pantiru

What exactly are the routing tables? Where do I find them? And why both? Are the routing tables associated with the NICs, or with the kernel or something?

----------

## NeddySeagoon

Stefan Pantiru,

The routing tables are the output of 

```
/sbin/route -n
```

 The -n is to use IP addresses, not names.

I don't know the Windows command, it may be 

```
route print
```

 in a console window.

The routing tables are a kernel data structure that tells the PCs how to route Ethrnet packets. Ping is a two way communication and both ends have to be right for it to work.

For example from my SmoothWall firewall (part of my public IP obscured) 

```
route -n

Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

xxx.xxx.xxx.136 0.0.0.0         255.255.255.248 U     0      0        0 eth2

192.168.100.0   0.0.0.0         255.255.255.0   U     0      0        0 eth0

192.168.0.0     192.168.100.6   255.255.255.0   UG    0      0        0 eth0

192.168.10.0    0.0.0.0         255.255.255.0   U     0      0        0 eth1

0.0.0.0         xxx.xxx.xxx.142 0.0.0.0         UG    0      0        0 eth2
```

You need to know that I have 8 static IP addresses.

This reads to reach my public subnet, send things to eth2.

To send things to 192.168.100.xxx, send them to eth0

To send things to 192.168.0.xxx send them to eth0 but address them to 192.168.100.6. (its a router and will send them on)

To reach 192.168.10.xxx, send packets to eth1.

The last rule says anything left over, send to my ADSL router on eth2.

----------

## DaveArb

Sorry for delay, yesterday was a holiday here...

 *Stefan Pantiru wrote:*   

> My eth0 is connected to Internet

 

You listed that eth1 was connected to Internet at the beginning of the thread. Have you reconfigured this? It can be easy to mix up which adapter is which.

If there is any possibility that you aren't sure which adapter is which (this happened to me when changing kernels, the adapters became renumbered), I recommend disconnecting everything and manually taking all the adapters down. Then, manually configure one adapter as 192.168.1.1 and configure the Windows 2000 machine (or whichever one is most reliable) to 192.168.1.2 and try pinging that address on each physical connection. If none of the ports respond, try ping to the Windows machine from the Gentoo also on each physical connection. If you aren't positive which port is which on a tri-homed machine, you will go insane...   :Wink: 

When you discover which physical port is which logical name, label them on the machine. Then will be time for the next step.

Dave

----------

## Stefan Pantiru

I stand correctly: my eth1 is connected to the Internet. 

I made a mistake when I wrote the post, but I asure you, I have not mixed up the NIC's. There are only three of them....

I'll post the routing tables soon... but not sooner than tomorrow.

Thank you, DaveArb, I hope you enjoyed the holiday...

----------

## Stefan Pantiru

OK, here it is...

```

root@endymion spantiru # route -n

Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 eth2

192.168.0.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0

10.0.0.0        0.0.0.0         255.255.240.0   U     0      0        0 eth1

127.0.0.0       127.0.0.1       255.0.0.0       UG    0      0        0 lo

0.0.0.0         10.0.0.1        0.0.0.0         UG    0      0        0 eth1

```

and also

```

root@endymion spantiru # ifconfig

eth0      Link encap:Ethernet  HWaddr 00:00:00:00:00:00  

          inet addr:192.168.0.1  Bcast:192.168.0.255  Mask:255.255.255.0

          inet6 addr: fe80::200:ff:fe00:0/64 Scope:Link

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:165 errors:0 dropped:0 overruns:0 frame:0

          TX packets:3 errors:5 dropped:0 overruns:0 carrier:10

          collisions:85 txqueuelen:1000 

          RX bytes:19070 (18.6 Kb)  TX bytes:558 (558.0 b)

          Interrupt:18 Base address:0xc400 

                                

eth1      Link encap:Ethernet  HWaddr 00:02:44:6F:0F:56  

          inet addr:10.0.14.120  Bcast:10.0.15.255  Mask:255.255.240.0

          inet6 addr: fe80::202:44ff:fe6f:f56/64 Scope:Link

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:100665 errors:0 dropped:0 overruns:0 frame:0

          TX packets:520 errors:2 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:11788250 (11.2 Mb)  TX bytes:56744 (55.4 Kb)

          Interrupt:17 Base address:0xc000 

                                

eth2      Link encap:Ethernet  HWaddr 00:50:8D:57:0D:CA  

          inet addr:192.168.1.1  Bcast:192.168.1.255  Mask:255.255.255.0

          inet6 addr: fe80::250:8dff:fe57:dca/64 Scope:Link

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:0 errors:0 dropped:0 overruns:0 frame:0

          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:0 (0.0 b)  TX bytes:504 (504.0 b)

          Interrupt:20 Base address:0x5000 

lo        Link encap:Local Loopback  

          inet addr:127.0.0.1  Mask:255.0.0.0

          inet6 addr: ::1/128 Scope:Host

          UP LOOPBACK RUNNING  MTU:16436  Metric:1

          RX packets:11 errors:0 dropped:0 overruns:0 frame:0

          TX packets:11 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0 

          RX bytes:671 (671.0 b)  TX bytes:671 (671.0 b)

```

Now, eth2 is connected to the Win2000 laptop.

On the laptop we have:

```

C:\>ipconfig

Windows 2000 IP Configuration

Ethernet Adapter Local Area Connection

   Connection-specific DNS suffix..... ::infoiasi.ro

        IP Adress.......................................: 192.168.1.2

   Subnet Mask..................................: 255.255.255.0

   Default Gateway............................:  10.0.14.120

```

and

```

C:\>route print

Interface List

0x1................................................MS TCP Loopback interface

0x1000003 ...00 50 fc b9 81 72 ...... Realtek 8139-series PCI NIC

Active Routes:

Network Destination           Netmask         Gateway             Interface          Metric

0.0.0.0                        0.0.0.0         10.0.14.120      192168.1.2         1

127.0.0.0                   255.0.0.0         127.0.0.1          127.0.0.1            1

192.168.1.0          255.255.255.0      192.168.1.2      192.168.1.2        1

192.168.1.2              255.255.255.255   127.0.0.1          127.0.0.1            1

192.168.1.255           255.255.255.255     192.168.1.2     192.168.1.2         1

224.0.0.0                      224.0.0.0                192.168.1.2     192.168.1.2         1

255.255.255.255          255.255.255.255      192.168.1.2     192.168.1.2         1

Default Gateway:          10.0.14.120

Persistent routes:

None

```

And when Win2000 pings me like this:

```

C:\>ping 192.168.1.1

```

I get only "Request timed out."

Any ideas? And the cables are set correctly. Believe me!

P.S. Sorry for the text formatting...

----------

## DaveArb

What can endymion ping? For example, can it ping the Internet, can it ping the Win2000 box?

 *Quote:*   

> And the cables are set correctly. Believe me!

 

Please forgive a bit of humor, but around here that phrase is classified as "famous last words".   :Wink:  How are you positive?

Dave

----------

## Stefan Pantiru

It can ping the Internet, but cannot ping Win2000. 

I also have WinXP installed. And with "Share my internet connection" I indeed shared my Internet in 2 minutes. In Gentoo I'm trying to do the same thing for over a week now and couldn't. Maybe that's why I wrote those 10 "Murphy-like laws"... Anyhow I checked and rechecked and rechecked the cables... I mean it's really hard to mix-up 3 NICs... I even learned by heart their MACs... It's not about the cables for God's sake... Plus.. one is a 100M NIC, the other is a 10M NIC and the third is integrated... You really could't make a confusion even if you tried... And it's working perfectly under XP... 

That's how I'm positive... No offense take anyway... 

I just wanna make this Gentoo box work!!! Otherwise I can't work under Linux 'cause my friends need Net (you can imagine!) and 'till now I could share only in XP... And I wanna go home in Linux!!!....  :Sad: ( I'm working in XP for two weeks or more and already got full of addware and BOREDOM... I really worked hard on this Gentoo but if I can't get it to work i'll go back to Mandrake with regret...

----------

## DaveArb

 *Stefan Pantiru wrote:*   

> It can ping the Internet, but cannot ping Win2000. 
> 
> <snip>
> 
> That's how I'm positive... No offence take anyway... 
> ...

 

Pull the cable from eth1 and place it into eth2. Take eth1 down (/etc/init.d/net.eth1 stop). Take eth2 down (/etc/init.d/net.eth1 stop). Bring eth2 up with the settings from eth1 using ifconfig. See if endymion can still see the Internet. This will determine if Gentoo is just having a fatal error working with the eth2 NIC for some reason.

Because, you are correct, this should not be anywhere near this hard. I think we need to fall back to checking first principles, like "is that card actually working?"

Thanks for not taking offense.

Dave

[edit afterthought]Also, please reconfirm that eth0 and eth2 are assigned addresses on different networks. The example I gave previously put one on 192.168.0/24 and the other on 192.168.1/24. If they are on the same network, or the netmask is still 255.255.0.0 as you once listed, Gentoo may be transmitting on the wrong NIC.

----------

## NeddySeagoon

Stefan Pantiru,

Your routing tables look good, so its something subtle. Time for a summary of what we know, a coffe and a beer (or two)

When you dual boot your 3 NIC box it can connect to the internet on eth1, regardless of the OS you use. No swapping of cables required so we know that both OS see eth1 as the same NIC.

When you boot your 3 NIC box under Windows, its internet sharing works with a Win 2000 box. We don't know that linux and windows both see this NIC as eth2. It could be eth0 to one OS and eth2 to the other.

Can you boot windows on your 3 NIC box and ask for the routing tables when internet sharing works?

You also need the MAC addresses associated with the NICs to be able to determine if thats the problem, since you need to tie up MAC addresses to logical names.

Can you det a packet sniffer (tcpdump) on the Win 2000 box to see if its getting any packets at all. I think there are free versions to download. 

Try it plugged into both eth0 and eth2

I presume you are using the same static IPs on the other two boxes regardless of which OS runs to share the internet?

----------

## Stefan Pantiru

On Win2000 I have

```

C:\>route PRINT

===========================================================================

Interface List

0x1 ........................... MS TCP Loopback interface

0x2000003 ...00 50 fc b9 81 72 ...... Realtek 8139-series PCI NIC

Active Routes:

Network Destination        Netmask          Gateway       Interface  Metric

          0.0.0.0          0.0.0.0      192.168.0.1   192.168.0.220       1

        127.0.0.0        255.0.0.0        127.0.0.1       127.0.0.1       1

      192.168.0.0    255.255.255.0    192.168.0.220   192.168.0.220       1

    192.168.0.220  255.255.255.255        127.0.0.1       127.0.0.1       1

    192.168.0.255  255.255.255.255    192.168.0.220   192.168.0.220       1

        224.0.0.0        224.0.0.0    192.168.0.220   192.168.0.220       1

  255.255.255.255  255.255.255.255    192.168.0.220   192.168.0.220     1

Default Gateway:       192.168.0.1

```

On my WinXP I have:

```

C:\Documents and Settings\Stefan Pantiru>route print

===========================================================================

Interface List

0x1 ........................... MS TCP Loopback interface

0x10003 ...02 50 8d 57 0d ca ...... MAC Bridge Miniport

0x10004 ...00 02 44 6f 0f 56 ...... SURECOM EP-320X-S 100/10M Ethernet PCI Adapter

=====

Active Routes:

Network Destination        Netmask          Gateway       Interface  Metric

          0.0.0.0          0.0.0.0         10.0.0.1     10.0.14.120       20

         10.0.0.0    255.255.240.0      10.0.14.120     10.0.14.120       20

      10.0.14.120  255.255.255.255        127.0.0.1       127.0.0.1       20

   10.255.255.255  255.255.255.255      10.0.14.120     10.0.14.120       20

        127.0.0.0        255.0.0.0        127.0.0.1       127.0.0.1       1

      192.168.0.0    255.255.255.0      192.168.0.1     192.168.0.1       20

      192.168.0.1  255.255.255.255        127.0.0.1       127.0.0.1       20

    192.168.0.255  255.255.255.255      192.168.0.1     192.168.0.1       20

        224.0.0.0        240.0.0.0      10.0.14.120     10.0.14.120       20

        224.0.0.0        240.0.0.0      192.168.0.1     192.168.0.1       20

  255.255.255.255  255.255.255.255      10.0.14.120     10.0.14.120       1

  255.255.255.255  255.255.255.255      192.168.0.1     192.168.0.1       1

Default Gateway:          10.0.0.1

===========================================================================

Persistent Routes:

  None

```

But here, the situation is different... Windows automatically created this so-called MAC Bridge Miniport... And also automatically assigns IP's to the other computers...

I do know that 

*all three NICs are really working... 

*eth1 comes up correctly connected to the net in both OSs

----------

## NeddySeagoon

Stefan Pantiru,

I have some good news and some bad news.

It looks like windows assignes addresses dynamically as PCs come and go. In your most recent post, only two NICs have IP addresses allocated out of the 3 we know you have. Its likely that the third interfcae will be brought up when something tries to connect. This means that windows will keep swapping the IP addesses assigned to these NICs depending on the order in which the other PCs get powered up. Nobody cares because its running a DHCP server on each NIC too, so the windows boxes get their network set up allocated automatically. Linux can do this too.

Now, linux assigns the logical identifierer eth0, eth1 ... in the order in which the drivers for the NICS are encountered. This is a problem because when you run linux, the IP addresses are attached to the logical identifiers.

If you only have two boxes on under windows, the second one will always be on the 192.168.0.x network regardless of which NIC it is attached to.

You can test this by only useing two boxes. Your 3 NIC one and the Win 2000 one.

Boot Windows on both and verify that the Win 2000 box gets an IP in the 192.168.0.x range. Repeat the expriment with the Win 2000 box plugged into the other NIC on the 3 NIC box.

There are three ways out:-

1. Buy a switch and attach it to eth0 in the 2 NIC box. Eth2 is no longer required. Plug the other boxes into the switch. You now only have a single local subnet and its always the same.

2. Make Windows more like Linux or Linux more like Windows so you can run either OS in the middle and everyone is happy.

Lets go for the latter, because thats less grief for your friends.

You need to install and run a dhcp server on eth0 and an eth2. When this works linux will provide the network setups dynamically like windows does. Your eth0 and eth2 will still have fixed IPs but dhcp will serve compatble addresses to anything that asks. 

Making windows use static IPs on your 3 NIC box is probably doable too but I don't know how that will fit in with its dhcp server. Give that a try if you want. You need to statically allocate the same IP address to each NIC under windows as it gets under Linux.

From a few of your recent posts. 

```
On my WinXP I have

Active Routes:

Network Destination        Netmask          Gateway       Interface  Metric

          0.0.0.0          0.0.0.0         10.0.0.1     10.0.14.120       20

         10.0.0.0    255.255.240.0      10.0.14.120     10.0.14.120       20

      10.0.14.120  255.255.255.255        127.0.0.1       127.0.0.1       20

   10.255.255.255  255.255.255.255      10.0.14.120     10.0.14.120       20

        127.0.0.0        255.0.0.0        127.0.0.1       127.0.0.1       1

============================================================================

      192.168.0.0    255.255.255.0      192.168.0.1    192.168.0.1        20

============================================================================

      192.168.0.1  255.255.255.255        127.0.0.1       127.0.0.1       20

    192.168.0.255  255.255.255.255      192.168.0.1     192.168.0.1       20

        224.0.0.0        240.0.0.0      10.0.14.120     10.0.14.120       20

        224.0.0.0        240.0.0.0      192.168.0.1     192.168.0.1       20

  255.255.255.255  255.255.255.255      10.0.14.120     10.0.14.120       1 
```

shows what Windows was allocating to the NIC in the 3 NC box going to Win 2000. Yet when you were attempting pings from linux you were pinging in the 192.168.1.x net, which wouldn't have worked unless the Win 2000 box had a static address in that range. This is what makes me think that IPs are allocated to your three NICs dynamically by windows and statically by linux. This means thay are only right when things get switched on in the right order.

----------

## Stefan Pantiru

...which brings me to my very first question of this thread: how do you set up the udhcpd to do that?

Were we going in a circle here?

----------

## NeddySeagoon

Stefan Pantiru,

From the man page udhcpd can't do that. It can only serve a single interface. You need DHCP on two intefaces.

----------

## Stefan Pantiru

Thanks for the observation, NeddySeagoon... I'll continue the IP war tomorrow...

Hm.. a quick 

```
#emerge search dhcp
```

 shows that there is no serious dhcp server to emerge... Or...what is dhcpv6? 

Anyway I'll probably look for something on the net. I remember something pretending to be the most widely used dhcp server around...  I also noticed it's very popular on this forums too... I'll go for that even if it's not available for emerge... But first I have to convince this NICs to work properly...

Once again, thanks NeddySeagoon and DaveArb... wish me luck!

----------

## DaveArb

net-misc/dhcp is what is in use on my network.

Dave

----------

## Stefan Pantiru

Thanks for the tip. But I must solve this PING problem first... And I'm trying... and trying... It's like both Win and Gentoo boxes are blindfolded... or categorically refuse to see each other... And it' so simple... I'm probably missing something obvious... But don't know what...

----------

## DaveArb

 *Stefan Pantiru wrote:*   

> Thanks for the tip. But I must solve this PING problem first... And I'm trying... and trying... It's like both Win and Gentoo boxes are blindfolded... or categorically refuse to see each other... And it' so simple... I'm probably missing something obvious... But don't know what...

 

At 3:59 pm yesterday, NeddySeagoon assumed/concluded that your Windows machines are using dynamic IPs, ie. DHCP. Can you refute this?

If the machines are set up for DHCP and cannot find a DHCP server, something strange happens that I don't recall at the moment, and everything pretty much goes badly from there.

If the Windows machines are statically assigned the IPs you have listed above, I renew my request to move the Internet cable and verify that the eth2 port is for sure actually working in Gentoo. You can verify the IP assigned to a Windows computer by using `ipconfig` in a command line box.

Dave

----------

## Stefan Pantiru

 *Quote:*   

> At 3:59 pm yesterday, NeddySeagoon assumed/concluded that your Windows machines are using dynamic IPs, ie. DHCP. Can you refute this? 

 

Well the situation is like this: when I boot WindowsXP, the OTHER two windows boxes receive dynamicaly allocated IPs (allocated by my WinXP).

But MY IP is static (not public) meaning that in my ISP's dabase my eth1's MAC is associated with a SPECIFIC IP (10.0.14.120 to be more specific). This is NOT public, only static. So, I'm connected to the net through eth1 using a static IP and share my connection using "Share my internet connection" in WindowsXP, dynamicaly allocating IP's to the other two Windows computers.

In Gentoo, I manually set statical IPs to the other two NICs (eth0 and eth2) and manually set static IP's to the other Windows boxes, but still cannot connect to neither of the other two computers.. only the net connection is working...

 *Quote:*   

> I renew my request to move the Internet cable and verify that the eth2 port is for sure actually working in Gentoo.

 

Why would they not work? eth1 is OBVIOUSLY working... And I had no trouble with it... Now let's asume that I don't have the right driver installed for one of the other two NIC's... But both of them? What are the odds? And I'm pretty sure they are set up correctly... I know what drivers to load.. I have configured them before in Mandrake... The NICs do work... It's a waste of time to assume the problem is driver or hardware related... At least that's for sure... (As sure as I can be...)

With the risc of being redundant I hope I clearly explained the DHCP thing...

----------

## NeddySeagoon

Stefan Pantiru,

Good - some progress.

We now know that your 3 NIC box runs DHCP servers under windows on eth0 and eth2.

Your static IP on eth 1 works in both Win and Linux.

You do not (yet) run a DHPC server in Linux.

We know your three NICs are 'up' under Linux because they appear in /ifconfig and have IP addresses  

When your 3 NIC box is in Linux and your Win 2000 box comes up, it broadcasts for a DHCP server and gets no response, so does nothing with its ethernet - its not allowed to.

Ping won't work because your Windows box does not get an IP address. To make ping work either Linux must serve IP addresses or Windows (and Linux) must be made to use static addresses.

You will go insane trying to sort out static IPs on three subnets at the same time, so will we, trying to help. Remove the card that is eth2 from the 3 NIC box meanwhile.

Bring up windows and assign the eth0 card a static IP of 192.168.0.1, netmask 255.255.255.0 and broadcast 192.168.0.255. These numbers are traditional. Now bring up the windows box on the end of eth0 and assign it a static IP of 192.168.0.2, netmask 255.255.255.0 and broadcast 192.168.0.255. Ping should now work in Windows. Internet sharing may still work too.

Bring up your 2 NIC box (you have removed one NIC) in Linux and assign the same setup to eth0. Ping should work to the windows box after you have restarted eth0. Connection sharing won't work yet. NAT is not running.

With one subnet set up. Put the 3rd NIC back in the box. Repeat the above using IP addresses in 192.168.2.0 subnet. (I've named the subnets 0 and 2 after the ethernet interfaces they connect to). Now ping from both windows boxes to your 3 NIC box should work under either OS. The windows boxes will not be able to ping each other until you add some static routes.

----------

## Stefan Pantiru

 *Quote:*   

> When your 3 NIC box is in Linux and your Win 2000 box comes up, it broadcasts for a DHCP server and gets no response, so does nothing with its ethernet - its not allowed to. 

 

...nope. That's not it...  in my previous post I specificaly said that

 *Quote:*   

> In Gentoo, I manually set statical IPs to the other two NICs (eth0 and eth2) and manually set static IP's to the other Windows boxes, but still cannot connect to neither of the other two computers.. only the net connection is working... 

 

So I did NOT  let the other two computers (amont which is the Win2000 one) to wait for an unexisting DHCP server to assign them an IP... I manually set IPs from the same subnet class as the NIC they were connected to. I set to eth2 the IP 192.168.0.1 and then, to the Win2000 box which is connected to my eth2 I manually assigned the static IP 192.168.0.2 with the common subnet mask 255.255.255.0 etc. as you may see in one of my previous posts.

Ok... I'll try to configure them one by one... But why? I mean why would they work if set up une by one, rather than simultaneously?

----------

## DaveArb

[meta/option=philosophical]

What NeddySeagoon and I both have been doing is going through standard troubleshooting procedure, eliminating distracting processes and products in an attempt to solve one part of a puzzle. When one part is solved, you then move on to the next part. When you've solved all the parts, the puzzle is finished.

In about 22 years of employment as a computer professional, I've had a lot of people work for me. Many of them referred at one time or another to my troubleshooting procedure as "slow" or "plodding" or "a waste of time". Yet time and time again, I was able to solve problems, and actually know what had been wrong so I could fix it the next time, when they couldn't. The technique works.

[/meta]

 *Stefan Pantiru wrote:*   

> Why would they not work? eth1 is OBVIOUSLY working... And I had no trouble with it...

 

eth1 is obviously _not_ the problem in this puzzle.

 *Stefan Pantiru wrote:*   

> Now let's asume that I don't have the right driver installed for one of the other two NIC's... But both of them? What are the odds?

 

To be frank, I don't know you well enough to even guess. To pull a number out of the air, given only this thread, I would guess the odds are somewhere in the 65-90% range.

 *Stefan Pantiru wrote:*   

> And I'm pretty sure they are set up correctly... I know what drivers to load.. I have configured them before in Mandrake... The NICs do work... It's a waste of time to assume the problem is driver or hardware related...

 

You've been working on this since May 25, and it still doesn't work. I honestly think that at this point, making any assumption at all is a waste of time.

 *Stefan Pantiru wrote:*   

> At least that's for sure... (As sure as I can be...)

 

Here's the thing. I have a network here with about 45 computers on it, made up of Windows 95, 2000, XP, RedHat Linux, Gentoo Linux, and even a 1992 version of Data General Unix on it, and it all works, through a gateway triple-homed Gentoo Linux machine much like you're trying to set up. Your network doesn't. My apologies for being direct...

In conclusion of a long post that likely will not help you in the least, I think NeddySeagoon outlined an _excellent_ next step for identifying and resolving this issue.

Dave

I'm particularly impressed by the clever choice of IP ranges to reflect the device name. I shall get good use of this in the future, I believe.   :Smile: 

----------

