2

I have been trying for weeks now to get my Ubuntu 16.04 server to route traffic between the two network interfaces on it. I know this question has been asked a hundred times on the forums before, but nothing that I have read has helped me.

So I have the following set up in /etc/network/interfaces

# The loopback network interface
auto lo enp2s0
iface lo inet loopback

# The external interface (router)
iface enp2s0 inet static
    address 192.168.0.20
    netmask 255.255.255.0
    network 192.168.0.0
    broadcast 192.168.0.255
    gateway 192.168.0.1 

# This internal interface
auto enp3s0
iface enp3s0 inet static
    address 192.168.1.254
    netmask 255.255.255.0
    network 192.168.1.0
#   gateway 192.168.1.254

I have set net.ipv4.ip_forward = 1

I've set my UFW to pass traffic between interfaces

Status: active

To                         Action      From
--                         ------      ----
22                         ALLOW       Anywhere                  
22/tcp                     ALLOW       Anywhere                  
22/udp                     ALLOW       Anywhere                  
10000                      ALLOW       Anywhere                  
22 (v6)                    ALLOW       Anywhere (v6)             
22/tcp (v6)                ALLOW       Anywhere (v6)             
22/udp (v6)                ALLOW       Anywhere (v6)             
10000 (v6)                 ALLOW       Anywhere (v6)             

Anywhere on enp3s0         ALLOW FWD   Anywhere on enp2s0        
Anywhere on enp2s0         ALLOW FWD   Anywhere on enp3s0        
Anywhere (v6) on enp3s0    ALLOW FWD   Anywhere (v6) on enp2s0   
Anywhere (v6) on enp2s0    ALLOW FWD   Anywhere (v6) on enp3s0   

I've change the routing tables to route traffic between the interfaces but now success.

There is the routing table.

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.0.1     0.0.0.0         UG    0      0        0 enp2s0
192.168.0.0     *               255.255.255.0   U     0      0        0 enp2s0
192.168.1.0     192.168.0.20    255.255.255.0   UG    0      0        0 enp2s0
192.168.1.0     *               255.255.255.0   U     0      0        0 enp3s0

When I ping between the two interfaces I the following reply

:~$ ping -I enp3s0 192.168.0.20
PING 192.168.0.20 (192.168.0.20) from 192.168.1.254 enp3s0: 56(84) bytes of data.
From 192.168.1.254 icmp_seq=1 Destination Host Unreachable
From 192.168.1.254 icmp_seq=2 Destination Host Unreachable
From 192.168.1.254 icmp_seq=3 Destination Host Unreachable

:~$ ping -I enp2s0 192.168.1.254
PING 192.168.1.254 (192.168.1.254) from 192.168.0.20 enp2s0: 56(84) bytes of data.
From 192.168.0.20 icmp_seq=1 Destination Host Unreachable
From 192.168.0.20 icmp_seq=2 Destination Host Unreachable
From 192.168.0.20 icmp_seq=3 Destination Host Unreachable

Please could somebody help me to solve this problem.

0

Everything looks good. 192.168.0.20 is on your enp2s0 interface and 192.168.1.254 is on your enp3s0 interface. But you're telling your computer to go OUT of enp3s0 to reach 192.168.0.20 which it tries but fails as it's suppose to since it cannot get to 192.168.0.x from enp3s0.

You need to try the ping from another machine on the LAN. i.e. configure a box on you internal 192.168.1.0 network to go through gateway 192.168.1.254 and try to ping 192.168.0.20

Update: Oh and this route makes no sense remove it:

192.168.1.0     192.168.0.20    255.255.255.0   UG    0      0        0 enp2s0
  • Thank you for your reply. Removed that rooting as you suggested. I updated my interfaces file and removed the gateway on the internal network as the Ubuntu machine will be its gateway. I'm now sitting with the problem of setting up iptables. Ran this script and for the first time I can ping out from the internal network, but I still can't connect to the internet with the browser. – Juan-Emil Saayman Oct 15 '16 at 19:31

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.