Rating (2)

Thanks 3

4 Entries

I try to set static ip address eth0, eth1 and wlan0 (usb-wifiStick) so i try to set eth1 to dhcp and wlan0 to dhcp internet connection will work (tested ping www.google.com) but when i set wlan0 to dhcp and eth1 to static ip internet connection don't work anymore beacuse eth1 need to set static ip used for read data form another plc.

Give wlan0 and eth1 different IP subnets! I assume both interfaces are connected to different broadcast domains / layer2 networks.

Explanation:

First law of networking: never give a station two addresses in the same layer3 subnet on different layer2 networks or interfaces. Maybe your interfaces eth1 and wlan0 are connected to the same layer2 network, that should work. On the otherhand the station will only use one of the two interfaces. And if both interfaces are on the same layer2 network why not use some form of link aggregation?

In any case. You have two interfaces (eth1, wlan0) on the same layer3 network (192.168.1.0/24). As soon as you try to ping a machine in that layer3 network , i.e. 192.168.1.100, the OS has to decide which source interface to use. It will take the one with higher priority inside the routing table (check "netstat -r"), unless you somehow manually specify the interface. Let us assume that eth1 has the higher priority according to the routing table, which is probably the case.

If the target, 192.168.1.100, is also connected to the layer2 network eth1 is connected to, everything works fine.

If the gateway, 192.168.1.1, is reachable only via the layer2 network wlan0 is connected to, you will not be able to access it. All your packets (in this stage actually only the ARP request for the mac address of 192.168.1.1), are sent via eth1. You will naturally not be able to access your gateway.

Solution:

Always give different Layer 2 networks different Layer 3 Subnets.

Never put multiple Layer 3 Subnets onto the same Layer 2 network.

Subnets (layer3) and their physical broadcast domains (layer2) should have a 1:1 relationship! If you do not obey this rule, believe me bad things will happen. Maybe not today, maybe not this month, but some time in your future, when it is dark, raining, cold, and you least expect it, it will crash your customers million dollar production! I saw this more than once ;)