3

I need to connect my Raspberry Pi 3B to two local area networks:

1) First is a closed (secured) network that does not have an internet access (it has a web server that is accessible from that network)

2) Second is a public network with internet access Both networks do not have Wi-Fi so the only way to connect to them is through two ethernet cables.

Now what I want is to have my Raspberry Pi connected to two of these networks, and be able to access the web server from the first LAN and internet from the second LAN.

Since Raspberry Pi 3B has only one ethernet port, the solution that comes to my head to my head is to use a USB-Ethernet adapter to be able to connect to two networks. Provided the adapter is set up and working, will Raspberry be able to distinguish between webserverhost and google.com and know through which network to access each host? Or will I need to do any additional configurations, like for example network routing?

6
  • Why don’t you try it.
    – Milliways
    Jan 28, 2019 at 21:08
  • When you are done, you will want to see something like the following. # ip route show 192.168.0.0/24 dev eth1 proto static metric 100 default via <ISP gateway> dev eth0 Jan 31, 2019 at 20:11
  • 1
    You can use "ip route show" to see the default routes. When it is working, you should have the two interfaces (dev eth0 and dev eth1) with two different IP subnet addresses. You should also have a default route with the internet dev and a "via ipaddress" where ipaddress is your internet gateway/router. Jan 31, 2019 at 20:26
  • 1
    @ChadFarmer Thank you, do you know if it will be possible to resolve host names from both networks provided that both networks have their own DNS servers? Because my understanding so far is that only one DNS server can be used, so if I configure RPI to use DNS server from the first, public network, I will not be able to resolve host names from the second closed network. Feb 1, 2019 at 13:03
  • @Mykhialo Seniutovych DNS protocol supports multiple servers but assumes the servers can talk to each other. Your networks are separate without a router to interconnect them. You can still use private network names on the RPi if you configure them statically in /etc/hosts. A different approach is to run a DNS server on the RPi since it has access to both networks. I've never tried that, so can't help with details. Feb 18, 2019 at 22:07

1 Answer 1

2

If you attach an USB/ethernet dongle to the RasPi with default Raspbian you will get a second interface eth1 out of the box. You should be able to connect to webserverhost and you should also be able to connect to google.com. The only problem is that the operating system does not know what interface it should use to get to the internet. You have to tell it what ip address your internet router on the public network has. This is done with an entry static routers= in /etc/dhcpcd.conf. You will find an example in that file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.