Problem :
I am preparing ubuntu router with 2 interfaces
enp2s0 (Connected to ISP WAN)
enp2s8 (internal LAN network and DHCP server and DNS server)
my interface configuration (/etc/network/interfaces) is :
auto enp2s8
iface enp2s8 inet static
address 192.168.5.1
netmask 255.255.255.0
broadcast 192.168.5.255
allow-hotplug enp2s0
auto enp2s0
iface enp2s0 inet static
address 192.168.5.111
netmask 255.255.255.0
gateway 192.168.5.5
dns-nameserver 8.8.8.8 8.8.4.4
route
gives:
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 192.168.5.5 0.0.0.0 UG 0 0 0 enp2s0
192.168.5.0 * 255.255.255.0 U 0 0 0 enp2s0
192.168.5.0 * 255.255.255.0 U 0 0 0 enp2s8
ip route
gives:
default via 192.168.5.5 dev enp2s0 onlink
192.168.5.0/24 dev enp2s0 proto kernel scope link src 192.168.5.111
192.168.5.0/24 dev enp2s8 proto kernel scope link src 192.168.5.1 linkdown
I can’t access Internet from interface enp2s8.ping -I enp2s8 google.com
gives:
PING google.com (202.51.65.52) from 192.168.5.1 enp2s8: 56(84) bytes of data.
From olerouter.olenepal.local (192.168.5.1) icmp_seq=1 Destination Host Unreachable
From olerouter.olenepal.local (192.168.5.1) icmp_seq=2 Destination Host Unreachable
From olerouter.olenepal.local (192.168.5.1) icmp_seq=3 Destination Host Unreachable
From olerouter.olenepal.local (192.168.5.1) icmp_seq=4 Destination Host Unreachable
From olerouter.olenepal.local (192.168.5.1) icmp_seq=5 Destination Host Unreachable
From olerouter.olenepal.local (192.168.5.1) icmp_seq=6 Destination Host Unreachable
From olerouter.olenepal.local (192.168.5.1) icmp_seq=7 Destination Host Unreachable
but ping -I enp2s0 google.com
outputs:
PING google.com (202.51.67.32) from 192.168.5.111 enp2s0: 56(84) bytes of data.
64 bytes from cache.google.com (202.51.67.32): icmp_seq=1 ttl=59 time=1.45 ms
64 bytes from cache.google.com (202.51.67.32): icmp_seq=2 ttl=59 time=1.32 ms
I am new to UFW and not being able to Forward the IP between interfaces. Thanks in advance
Solution :
By obfuscating the real IP addresses and using the same 192.168.5.0/24
network both on enp2s8
and enp2s0
makes your question bit confusing. However, once you configure correct network on enp2s0
, enable IPv4 forwarding(sysctl -w net.ipv4.ip_forward=1
) and configure SNAT(source IP on packets from your 192.168.5.0/24
network needs to be changed to publicly routable IP address configured on enp2s0
) with iptables
, then you are ready to go.