# USB connected router

## creaker

I using D-Link DSL-2520U router with 2 output ports (the first for ethernet cable, the second - for usb cable)

I want to establish usb connection. So what I did:

Kernel was rebuilt with module cdc_ether and networkmanager was installed.

In networkmanager I added new wired connection eth1 and configured this connection manually: 

```
IP Address: 192.168.1.4

Subnet Mask: 255.255.255.0

Gateway: 192.168.1.1

DNS Server: 192.168.1.1

IPv6: disabled

Restrict to Interface: eth1
```

All the settings the same as for eth0 except IP (192.168.1.2)

When I connecting to Connection eth1 networkmanager shows that connection established and shows connection parameters that exactly matches my settings for eth1.

But I can't connect neither to internet nor router (ping 192.168.1.1 says: destination unreachable)

Here ifconfig output for eth1:

```
Link encap: Ethernet HWaddr 1c:af:f7:31:c1:dc

inet addr: 192.168.1.4 Bcast: 192.168.1.255 Mask: 255.255.255.0

UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

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

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

collision: 0 txqueuelen: 1000

RX bytes: 0 (0.0 B) TX bytes: 0 (0.0 B)
```

Can anyone explain what is incorrect with eth1 settings?

Thanks in advance for any help.

----------

## NeddySeagoon

creaker,

Please post the output of route when eth1 has an IP address.

Do you connect both eth0 and eth1 to the router at the same time od is eth0 unplugged?

----------

## creaker

Thanks for reply, Neddy

route output here:

```
gentoo ~ # route

Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

default         192.168.1.1     0.0.0.0         UG    0      0        0 eth1

default         192.168.1.1     0.0.0.0         UG    3      0        0 eth0

loopback        gentoo.homenetw 255.0.0.0       UG    0      0        0 lo

192.168.1.0     *               255.255.255.0   U     0      0        0 eth0

192.168.1.0     *               255.255.255.0   U     1      0        0 eth1

```

Only usb cable plugged in (eth1).

Also networkmanager shows that eth0 interface cable unplugged

.

P.S.

Also I see a strange ping output:

```
gentoo ~ # ping 192.168.1.1

PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data

From 192.168.1.2: icmp_seq=1 Destination Host Unreachable

From 192.168.1.2: icmp_seq=2 Destination Host Unreachable
```

Why ping outcoming from 192.168.1.2 ?

----------

## creaker

I assumed that the net.eth0 interface is on and interferes with net.eth1 and stopped him: /etc/init.d/net.eth0 stop.

Also I removed both eth0 and eth1 from default runlevel. Now when I booting eth0 is off but eth1 is on and I can access internet via eth1. I'm not pretty sure but I think eth1 activated by networkmanager. Also if I connecting both cables, networkmanager shows that both interfaces are activated. I can disconnect either of the two cables and working with one cable plugged in.

It is exactly the same behavior as at my Debian desktop.

----------

## NeddySeagoon

creaker,

Routing rules are applied from from the bottom of the routing table up. So packets to 192.168.1.0/24, your local network, are routed using 

```
192.168.1.0     *               255.255.255.0   U     1      0        0 eth1 
```

Thats your USB ethernet, so all is good.

Packets to the internet are routed using

```
 default         192.168.1.1     0.0.0.0         UG    3      0        0 eth0
```

which is not so good, as thats your normal wired network, which you say is unplugged.

There are a few issues with your setup.  You may not have two interfaces in the same subnet as you do here and you may have at most, a single defualt route, since only the first one encountered in the routing table will ever be used.

For testing, get the system into the same state as it was when you made ran the route command.

Now run 

```
/etc/init.d/net.eth0 stop
```

This will stop your eth0 and remove all of its routes from the routing table.

Your internet over USB should now work.  This is not yet a fix.  I need to understand what you want from your two network interfaces to decide how to provide the network functionality you want.

----------

## creaker

Yes I run route at my Debian and noticed the count of interfaces less that at Gentoo.

What exactly I want from my network interfaces? I have a router with two ports only, lan and usb.

I need ability to connect to my router two PCs simultaneously. One of them is my desktop PC. The second PC (casual PC from clients) may have or may not have USB network interface established (usually have not).

So for my PC I should to have at least USB connection established, in order to keep lan connection for other PCc that (may be) can not connect to router via usb.

Since I removed eth0 from autostart, I can choose any connection type that I need: via usb or lan cable. Both working fine.

Now I thinking what to do: let my Gentoo to work with both interfaces, even if networking configured not very good or reinstall my networking in "true way"?

----------

