# Where is my network !?

## Dominique_71

[Moderator note: This post was attached to the 4 year old topic Where is my network !?.  I split it out because the problems appear to be unrelated, and because the other thread was from 2015. -Hu]

I have 2 network interfaces, net.eth0 and net.wlan0. Both are working fine, but wlan0 is the only with internet access, and when I start eth0 (openrc system), the internet access get down. If I stop eth0, internet is up again.

It must be some simple to do configuration in order to tell net.eth0 than it must not take over the internet traffic when both are on, but I just cannot find it. Do you have any clue?

EDIT: Finally, I found it. In /etc/conf.d/net add 1 line per interface like:

```
metric_wlan0="90"

metric_eth0="100"
```

and the kernel will use the one with the lower metric value as default internet interface when both are up.

----------

## mike155

Most probably, a second default route is added when you start eth0. 

Make sure that no default route is added when you start eth0. And remove the 'metric' workaround - it's not the right solution.

Please post:

the output of 'netstat -rn' and of 'ifconfig -a' after you started both wlan0 and eth0.

your file /etc/conf.d/net.

----------

## NeddySeagoon

Dominique_71,

Its probably worse than mike155 says.

If both interfaces are in the same subnet, like they would be with a domestic router, chaos is ensured.

----------

## Dominique_71

Sorry for the delay.

 *mike155 wrote:*   

> 
> 
> the output of 'netstat -rn' and of 'ifconfig -a' after you started both wlan0 and eth0

 

```
# netstat -rn

Kernel IP routing table

Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface

0.0.0.0         192.168.1.1     0.0.0.0         UG        0 0          0 wlan0

0.0.0.0         192.168.188.1   0.0.0.0         UG        0 0          0 eth0

127.0.0.0       127.0.0.1       255.0.0.0       UG        0 0          0 lo

192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 wlan0

192.168.188.0   0.0.0.0         255.255.255.0   U         0 0          0 eth0

# ifconfig -a

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

        inet 192.168.188.20  netmask 255.255.255.0  broadcast 192.168.188.255

        inet6 fe80::b2e1:20e:fb74:2924  prefixlen 64  scopeid 0x20<link>

        ether e8:40:f2:11:7c:42  txqueuelen 1000  (Ethernet)

        RX packets 6825  bytes 462180 (451.3 KiB)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 19443  bytes 27492441 (26.2 MiB)

        TX errors 0  dropped 0 overruns 0  carrier 1  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536

        inet 127.0.0.1  netmask 255.0.0.0

        inet6 ::1  prefixlen 128  scopeid 0x10<host>

        loop  txqueuelen 1000  (Local Loopback)

        RX packets 10377  bytes 732400 (715.2 KiB)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 10377  bytes 732400 (715.2 KiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

sit0: flags=128<NOARP>  mtu 1480

        sit  txqueuelen 1000  (IPv6-in-IPv4)

        RX packets 0  bytes 0 (0.0 B)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 0  bytes 0 (0.0 B)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

        inet 192.168.1.100  netmask 255.255.255.0  broadcast 192.168.1.255

        inet6 fe80::76de:2bff:fef7:ae8  prefixlen 64  scopeid 0x20<link>

        ether 74:de:2b:f7:0a:e8  txqueuelen 1000  (Ethernet)

        RX packets 9359666  bytes 12031956152 (11.2 GiB)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 3005518  bytes 811890646 (774.2 MiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

```

 *Quote:*   

> * your file /etc/conf.d/net.
> 
> 

 

```
# cat /etc/conf.d/net

modules_wlan0="!plug wpa_supplicant dhcpd"

wpa_supplicant_wlan0="-Dnl80211 -qq"

config_wlan0="dhcp"

config_eth0="dhcp"

dhcpcd_eth0="-t 10" # 10 seconds time out

mode_wlan0="master"

#mode_wlan0="managed"

channel_wlan0="3"

#routes_wlan0="default via 192.168.1.1"

metric_wlan0="90"

metric_eth0="100"

```

EDIT: This is when both are up and running and internet is working fine on wlan0.

----------

## NeddySeagoon

Dominique_71,

You have two default routes, that mostly won't work. 

```
Kernel IP routing table

Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface

0.0.0.0         192.168.1.1     0.0.0.0         UG        0 0          0 wlan0

0.0.0.0         192.168.188.1   0.0.0.0         UG        0 0          0 eth0 
```

but they are in different subnets which is a good thing.

Entries is the routing table are applied from the bottom up, so anything to 192.168.188.0/24 is sent over eth0.

Anything to 192.168.1.0/24 is sent over wlan0.

Anything to 127.0.0.0/8 is sent over lo.

All the rest is sent over eth0 as Destination 0.0.0.0 matches everything.

The Destination 0.0.0.0 over wlan0 can never be used.

If you remove that route, it will probably work but maybe not the way you intended.

----------

## mike155

 *Dominique_71 wrote:*   

> 
> 
> ```
> # netstat -rn
> 
> ...

 

There are two default routes. That's like a traffic sign, saying both 'go left' and 'go right' at the same time.

A router or host should not have more than one default route (there are exceptions, of course). You tried to fix that with interface metrics, but that's not the right solution. The right solution is: make sure that no default route is added when eth0 is started:

Can you configure eth0 with a static ip address?

If you configure eth0 using DHCP, make sure that DHCP initializes only the IP address, the netmask and the broadcast address of that interface. DHCP must NOT set default routes, DNS configuration, NTP configuration, etc.   

You could try to add the parameter "--nogateway" in /etc/conf.d/net:

```
dhcpcd_eth0="--nogateway -t 10" # 10 seconds time out
```

Does that help?

----------

## krinn

He sure have two default routes, but not the same default routes, one for each interface.

So it's like having the traffic sign with "cycle go left" and "car go right" ; that's different.

----------

## NeddySeagoon

krinn,

Not quite. The idea of a default route is that's its a catch all.

Anything that gets here go that way -->

That's why on the first reached default route will be used.

Problems actually occur when a packet goes out of one interface and the reply tries to use the other.

----------

## krinn

 *NeddySeagoon wrote:*   

> Anything that gets here go that way -->

 

I understand it more as "Anything that goes thru 'this' and goes somewhere we have no idea where, go that way -->"

The reply itself "should" never a problem, it fall under the rules of "mac address is in packet to reach destination", or no mac address and fall under DMZ rule.

The reply problem may comes from having a mac that you cannot reach it yourself (like getting answer thru eth that need to reach wlan and no bridge allow you to reach wlan from eth on your host).

The real issue people have is not the routing itself, is howto reach other interface, and a simple "ping -c1 vlanip" make it fail as only the wlan_router is able to reach wlan interface without proper bridging.

But maybe he have a value in not using internet with eth interface, else the simplest solve would be either bridging both together, or disable eth if really it's of no use.

----------

## Dominique_71

It is a laptop. It have internet access only on wlan0. The printer is on eth0, which is up and running on the PC only when I use the printer.

----------

## Jaglover

In that case just give your eth0 a static address in same subnet with printer and it will work. Printer needs a static address, too.

----------

## Dominique_71

 *Jaglover wrote:*   

> In that case just give your eth0 a static address in same subnet with printer and it will work. Printer needs a static address, too.

 

OK, I will try. The printer already have a static address. I cannot do that on the wifi router, it is why I use 2 routers. Dynamic ip address work out of the box only with OSX and some windows versions. As we have other laptops, it was much simpler to just use that second router with a static address for the printer.

----------

## Jaglover

Dominique_71,

routing and routers are needed to get out from your LAN, as long as your computer and printer are in the same subnet there is nothing to route.

----------

## Tony0945

 *Jaglover wrote:*   

> Dominique_71,
> 
> routing and routers are needed to get out from your LAN, as long as your computer and printer are in the same subnet there is nothing to route.

 

Yes, all the OP needs is a cheap four or five port unmanaged switch to plug both the printer and computer into. A third cable would go to the router for internet. This is the setup I had on my old printer. the new printer has only wireless and USB, a definite step backwards,

I no longer even use the switch built into my router. I have a sixteen port switch that every cable in the house connects to. One cable from the switch plugs into a single LAN port on the router.

----------

## NeddySeagoon

Dominique_71,

On routers that will not provide a static IP you can often cheat by binding the MAC address of the network card to a fixed IP in the router.

The IP address is not static in the traditional sense but it never changes as the router always hands out the same IP, so it has the same effect.

----------

## Tony0945

 *NeddySeagoon wrote:*   

> Dominique_71,
> 
> On routers that will not provide a static IP you can often cheat by binding the MAC address of the network card to a fixed IP in the router.
> 
> The IP address is not static in the traditional sense but it never changes as the router always hands out the same IP, so it has the same effect.

 

I verify that this works on a DLINK DIR-655.

----------

## Jaglover

SOHO routers can do nothing to stop you from grabbing an IP address and communicating with other hosts in the same subnet. Of course, if you are careless you may create an IP conflict.

----------

## Dominique_71

 *Jaglover wrote:*   

> Dominique_71,
> 
> routing and routers are needed to get out from your LAN, as long as your computer and printer are in the same subnet there is nothing to route.

 

The wifi router is needed to get internet access, but it is not possible to mix static and dynamic ip on the LAN with it. As many of our friends want to use the wifi, it will be of no use for them if it is set to use static ip (I am not always here, and I just have other things to do than to manage static ip on this wifi). The other router is used only for the printer, and the 2 LANs are not even connected to each other.

----------

## Jaglover

Why you need a router to connect printer? And technically speaking there is no such thing as wifi router. There is router and there is access point, even if they are built into same case they are still functionally separate units. Often there is also switch built into same box.

----------

## genbort

Wireless routers are available in the market.

And you could connect a printer with a bluetooth which is enough to printing.

----------

## NeddySeagoon

genbort,

There are things misnamed as wireless routers for sale, yes.

As Jaglover  said  they are usually a switch, a router, which is a piece of software and a wireless access point built into the same box.

Domestic 'wireless routers' are mostly only safe to use if the wireless access point is disabled.

Well, you wouldn't want wired and wireless on the same network would you?

----------

## UberLord

 *NeddySeagoon wrote:*   

> Well, you wouldn't want wired and wireless on the same network would you?

 

Why not?

I even assign the same IP to wired and wireless interfaces via DHCP.

dhcpcd will announce the "preferred" address via ARP to notify hosts which hardware address to send to.

This allows me to have one hostname for the laptop, regardless of which interface is actually live.

----------

## alamahant

You can have as many interfaces as you like.

However ONLY ONE should be assigned a default gateway.

If more than one have default-gateways in their definition files then network connectivity freezes for some reason.

You will not even be able to ping your router...

 :Very Happy: 

----------

## UberLord

 *alamahant wrote:*   

> You can have as many interfaces as you like.
> 
> However ONLY ONE should be assigned a default gateway.
> 
> If more than one have default-gateways in their definition files then network connectivity freezes for some reason.
> ...

 

On Linux this is not true. You can have many default gateways, split by metric. Lowest metric is the default default route.

The same logic applies to subnets.

----------

