2

I'm fairly new to Linux networking, so excuse me if this is a trivial question. I'm trying to setup a local network with a (WiFi) router that is connected via an USB-Ethernet adapter. Simultaneously I want to use the inbuild-ethernet interface for normal internet activity. The setup is something like this:

+------------+       +-----------+          +------------+
|            |       |           |          | Router/    |
| Office-DHCP+<----->+   Local   +<-------->+ Local DHCP |
|            |       |           |          |            |
+------------+       +-----------+          +-----+------+
                     |           |                ^
                     |   Apache  |                |
                     |   Ser^er  |                ^
                     |           |          +-----+------+
                     +-----------+          |            |
                                            | Smartphone |
                                            |            |
                                            +------------+

My idea is, that the local network (everything connected to the Router, either Wifi or ethernet) can connect to an apache webserver running on my local machine. Yet the normal internet traffic of my local machine should be routed via the inbuild ethernet interface. My problem is, that most tutorials that I found for a similar setup all use static IPs for their interfaces [e.g. this( in german)] I did manage to follow this tutorial and configure the routing table accordingly. ip route list gives the following output:

default via 10.xxx.xxx.1 dev enp1s0 
10.xxx.xxx.0/22 dev enp1s0 proto kernel scope link src 10.xxx.xxx.83 
192.168.0.0/24 via 192.168.0.1 dev enx00116b664965 
192.168.0.0/24 dev enx00116b664965 proto kernel scope link src 192.168.0.100 metric 100 

And while ping 8.8.8.8 and ping 192.168.0.101 (IP of a Wifi connected smartphone to the local router) as well as ip route get 192.168.0.101/ip route get 8.8.8.8 worked with the correct interface, i cannot establish a connection to the internet via firefox. When checked with wireshark on which interface the http request is send, I could see that it used the local interface, instead of the inbuild one.

Also, route -n shows this information:

name@host:~/$ sudo route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         10.xxx.xxx.1    0.0.0.0         UG    0      0        0 enp1s0
10.xxx.xxx.0    0.0.0.0         255.255.252.0   U     0      0        0 enp1s0
192.168.0.0     0.0.0.0         255.255.255.0   U     100    0        0 enx00116b664965

Can anybody point me in the right direction, how to configure my setup correctly, so that both, the local and the internet work properly. I would highly appreciate any help to setup the routing in this setup. Thanks in advance!

  • 1
    What's the DNS server being used? ;) – Tom Yan Oct 22 '19 at 10:16
  • Thanks! that was the problem... No idea how to set your comment as the answer, but its solved! – MajorasKid Oct 22 '19 at 10:46
1

@Tom Yan had the answer. The problem was the DNS server which was taken from the local router instead of keeping the office DNS server. Found via cat /etc/resolv.conf which stated

# Generated by NetworkManager
nameserver 192.168.0.1

I just copied the old DNS info into this file and everything worked flawlessly

| improve this answer | |
  • 2
    Note that /etc/resolv.conf will be re-generated the next time you receive a DHCP offer, so your changes will again be lost ... Try to make the DHCP client ignore the "nameserver" field(s) from one of the DHCP servers. I know how to do this for dhclient, but not for NetworkManager. – dirkt Oct 22 '19 at 11:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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