# Manual Question

## Centinul

Can someone please explain to me why this code works and how you would go about creating the configuration for eth1? Thanks.

"If you have several network interfaces, you need to create the appropriate net.eth1, net.eth2 etc. initscripts for those. You can use ln to do this: 

Code Listing 16: Creating extra initscripts"

```
# cd /etc/init.d

# ln -s net.eth0 net.eth1

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

Does it create a link in the net.eth0 file that points to the net.eth1 file where the eth1 configuration is stored?

----------

## sypher

All you are doing is changing to the /etc/init.d directory, then creating a symbolic link called net.eth1 that points to net.eth0 (i.e. using the same configuration for both, so net.eth1 knows whether you have DHCP, static ip, etc.), then adding net.eth1 to the default runlevel. Note that you only need to perform this step if you have to network cards installed and you want to use them both.

----------

## Ariem

You set up your network interfaces in 

```
/etc/conf.d/net
```

 and for each one you have you need a symlink from 

```
/etc/init.d/net.lo
```

 in 

```
/etc/init.d/
```

 that you can manually create as you mentioned. If you make the symlink from eth0 is the same.

It just means that your init script is based in net.lo and the device specification is in /etc/conf.d/net, by 

```
iface_ethX="dhcp"

...

```

----------

## Centinul

What do you do in the case that you have two cards that are configured differently? i.e. one that gets IP through DHCP and the other is specified manually.

----------

## sypher

Wouldn't that only happen if you had two ISPs, like if you had a cable and dsl modem and used one with one network card and the other with the other network card? I don't think you could have both DHCP and static ip from the same isp.

----------

## borfig

using the new baselayout net syntax, your /etc/conf.d/net should look like:

```
config_eth0=( "dhcp" )

config_eth1=( "x.y.z.t metmask X.Y.Z.T" )

# this is optional if your eth1 connects to outer networks

routes_eth1=( "default gw x'.y'.z',t'" )
```

the new syntax is awesome! if for example dhcp fails, then I can fall-back to static ip easily.

note that if you omit config_eth0, eth0 will use dhcp by default

----------

## Ariem

 *Centinul wrote:*   

> What do you do in the case that you have two cards that are configured differently? i.e. one that gets IP through DHCP and the other is specified manually.

 

Just set them up in 

```
/etc/conf.d/net
```

For example:

```
iface_wlan0="dhcp"

dhcpcd_wlan0="-HD"

iface_eth0="123.123.123.123 broadcast 123.123.123.255 netmask 255.255.255.0"
```

This is all explained in 

```
/etc/conf.d/net.example
```

 You should check it.

 *sypher wrote:*   

> Wouldn't that only happen if you had two ISPs

 

Not only. For example, you can have one card connected to you ISP and another for your home network. Then you want to set the first one with dhcp and the second in a static way.

----------

## sypher

 *Ariem wrote:*   

>  *sypher wrote:*   Wouldn't that only happen if you had two ISPs 
> 
> Not only. For example, you can have one card connected to you ISP and another for your home network. Then you want to set the first one with dhcp and the second in a static way.

 

Ahh, I didn't think of localnetworks (Ariem: I'm going to start PMing my responses to you before I post them so you can read them over for me so I don't look like such an idiot  :Laughing:  lol). Still, why would you have network card just for your homenetwork and another one for the internet?

----------

## Ariem

 *sypher wrote:*   

> 
> 
> Ahh, I didn't think of localnetworks (Ariem: I'm going to start PMing my responses to you before I post them so you can read them over for me so I don't look like such an idiot  lol). Still, why would you have network card just for your homenetwork and another one for the internet?

 

ahahahah...  :Laughing:   :Laughing:   :Laughing:   :Laughing: 

Well, using one card for internet and another for homenetwork is a tipical situation for gateways. If you set up a box with firewall/routing purposes, this is probably the configuration you'd use. I use that for allowing other pcs to access internet (thought mine).

```
INTERNET -- | (eth0)-PC-(eth1)| -- other pcs (homenetwork)
```

(what a nice draw:D) eth1 can be wireless, and you have wireless-net at home for your folks!

----------

## borfig

sypher, if you have 2 network cards such that one connects to the internet while the other to the local network, your computer can be a nice router (don't forget iptables and such...)

----------

## sypher

 *Ariem wrote:*   

>  *sypher wrote:*   
> 
> Ahh, I didn't think of localnetworks (Ariem: I'm going to start PMing my responses to you before I post them so you can read them over for me so I don't look like such an idiot  lol). Still, why would you have network card just for your homenetwork and another one for the internet? 
> 
> ahahahah...    
> ...

 

Oh, I've never set up a router box so I wouldn't know lol, anyway thanks for the clarification Ariem and borfig.

----------

## nixnut

Moved from Installing Gentoo to Networking & Security.

Since this is all about networking and not really about installing I'm moving it here.

----------

