0

I have the following setup:

  • One notebook with Debian Jessie with a static IP 192.168.1.2 for its Ethernet interface (set the connection profile through the GNOME network manager)
  • One PC with Xubuntu 16.04 two network interfaces (set the connection profiles through the GNOME network manager):
    • Static IP 192.168.1.4 - for connecting with my notebook OR the Raspberry Pi 2 (see next entry)
    • Automatic (DHCP) - for connecting to the Internet through the bridge on the Raspberry Pi 3
  • Raspberry Pi 2 with the latest Rasbian and static IP 192.168.1.3

    /etc/network/interfaces

    allow-hotplug eth0  
    iface eth0 inet static  
    address 192.168.1.3
    netmask 255.255.255.0
    network 192.168.1.0
    broadcast 192.168.1.255
    
  • Raspberry Pi 3 the latest Rasbian and static IP address 192.168.1.2. There is a bridge between its WiFi interface and its Ethernet interface so that my PC can connect the Ethernet port (the interface of the PC is set to Automatic (DHCP)) and be able to access the Internet. I used this tutorial for the setup.

    **/etc/wpa_supplicant/wpa_supplicant.conf*

    network={
      ... // SSID, encrypted password key etc.
    }
    

    /etc/network/interfaces

    allow-hotplug eth0  
    iface eth0 inet static  
    address 192.168.1.2
    netmask 255.255.255.0
    network 192.168.1.0
    broadcast 192.168.1.255
    

    /etc/dnsmasq.conf

    interface=eth0
    listen-address=192.168.1.2
    bind-interfaces
    server=8.8.8.8
    domain-needed
    bogus-priv  
    dhcp-range=192.168.1.100,192.168.1.254, 12h
    

    /etc/sysctl.conf

    Uncommented the line with net.ipv4.ip_forward=1

    Iptables configuration

    iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE  
    iptables -A FORWARD -i wlan0 -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT  
    iptables -A FORWARD -i eth0 -o wlan0 -j ACCEPT 
    

The problem I'm having is that I seem to be unable to use both the Pis connected to the PC even though they are attached to different network cards and their IP addresses are different but part of the same network. The automatic DCHP on the Pi 3 currently has given my PC (the interface it is connected to) the IP address 192.168.1.119.

I've noticed that whichever Pi I connect first to the PC works. The second connected doesn't (simple pinging provides me with the information). Next I have no problem connecting either of my Pi-s to my notebook - one provides me with Internet access (as expected; I turn off the WiFi adapter on the notebook for this) and the other with a "normal" Ethernet connection. I can also SSH from one machine to the other if connected (except for the case when the problem described above occurs).

I'm not that network savvy so some hints on what I'm doing wrong would be appreciated. If I can provide more information please do tell.

2 Answers 2

3

You shouldn't use the same network on two different interfaces. The most simple setup would be using different nets (even a small /30 net) for both Pis.

If you really want one network, you have two options:

  • bridging: you can create a bridge device on the PC and add both interfaces to the bridge. Now you have to add your IP to the bridge (dhcp or static) instead of the original interfaces. This IP will be accessible for both physical wire. You can have multiple IP addresses on single interface if you like. The whole network will be united, every device can reach every other devices.

  • subnetting: Instead of a link layer bridge, you can solve the problem at routing level. You can create two subnets under 192.168.1.0/24. for example: 192.168.1.0/25 + 192.168.1.128/25 . Both having 126 routable addresses. You can use an IP from the first range for pi2 (192.168.1.3) and an another from the second range for pi3 (eg. 192.168.1.130). Your PC will be able to reach both (routing will work), and from the PC's perspective it will be almost the same as one /24 network. However, the two pi's won't be able to reach each other (unless you specifically allow ip forwarding on the PC).

In case I misunderstood your goal, please clarify. It would be very helpful to share your PC's routing table and network config both Pi's connected. (ip route show and ip addr show). (I can not comment unfortunately).

0

@"Gote Guru"

Duplicate network cards on the same net has an abundance of uses!

For those that find this now (2021):

I also observed the mutual-exclusion behavior in Debian Buster and it's simply wrong! Yes, there are potential pitfalls when adding more than one NIC on the same network, but the same pitfalls apply to bridged or aliased NIC's.

This is one of these things where generation-shifts in SW-communities introduce really problematic assumptions and it's killing an hour of income for me right now.

I will be setting up networking in the old /etc/network/... style. This should override the behavior that I think is in the desktop-gui.

I added the following to the interfaces - file:

auto enp0s3
iface enp0s3 inet dhcp

auto enp0s8
iface enp0s8 inet dhcp

... and did a #> service networking restart

Et voila, it's up and working! After reboot as well!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .