Centos 7 forward traffic across two interfaces
Client1
Windows 10 PC 192.168.1.5
Centos 7 Router
enp1s0 is WAN facing 192.168.10.0/24 using IP 192.168.10.15
enp2s0 is LAN facing 192.168.1.0/24 using IP 192.168.1.15
Client2
Centos 7 NAS 192.168.10.100
[PC] [ Centos 7 Router ] [NAS]
client1 -> switch -> enp2s0 -> enp1s0 -> switch -> client2
From my Centos 7 Router i can ping both client1 and client2. I am unable to ping client2 from client1, or client1 from client2.
On my Centos 7 router I did the following:
# yum -y install traceroute.x86_64 net-tools.x86_64 iptables-services.x86_64 iptables-utils.x86_64
# ip route show
default via 192.168.10.1 dev enp1s0 proto static metric 100
192.168.1.0/24 dev enp2s0 proto kernel scope link src 192.168.1.15 metric 100
192.168.10.0/24 dev enp1s0 proto kernel scope link src 192.168.10.15 metric 100
# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.10.1 0.0.0.0 UG 100 0 0 enp1s0
192.168.1.0 0.0.0.0 255.255.255.0 U 100 0 0 enp2s0
192.168.10.0 0.0.0.0 255.255.255.0 U 100 0 0 enp1s0
# netstat -rn
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
0.0.0.0 192.168.10.1 0.0.0.0 UG 0 0 0 enp1s0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 enp2s0
192.168.10.0 0.0.0.0 255.255.255.0 U 0 0 0 enp1s0
Turn in IP forwarding
# echo 1 > /proc/sys/net/ipv4/ip_forward
Make IP forwarding perminent
# vi /etc/sysctl.conf
net.ipv4.ip_forward = 1
On client2 Centos 7 NAS set route on my 192.168.10.100 interface for 192.168.1.0/24 traffic using the 192.168.10.15 interface of the Centos 7 router
# ip route add 192.168.1.0/24 via 192.168.10.15 dev br0
On client1 windows 10 machine run as elevated
(Win key; type cmd; press Ctrl+Shift+Enter; and then hit Alt+C to confirm the elevation prompt.)
on client1 Windows 10 PC set route on my 192.168.1.5 interface for 192.168.10.0/24 traffic using the 192.168.1.15 interface of the Centos 7 router
C:\> route add 192.168.10.0 MASK 255.255.255.0 192.168.1.15
The route add change will only stick across reboots if you add it with the -p flag, as in the following:
C:\> route -p add 192.168.10.0 MASK 255.255.255.0 192.168.1.15
I can now reach each client machine from the other
No comments:
Post a Comment