I have a question.
I have a ubuntu server(GW0). It has 2 interfaces.
eth0: 10.20.26.10 - connected to router
eth1: 192.168.1.20 - connected to switch
eth0: 10.20.26.0/24, gw: 10.20.26.1
eth1: 192.168.1.0/24, gw: 192.168.1.254 (192.168.1.254 server placed in my network it has internet access)
I want to use this server(GW0) as my gateway for my 192.168.1.0/24 network to access 10.20.x.x subnets via 10.20.26.1 router and internet access from 192.168.1.254.
What i did.
- echo 1 > /proc/sys/net/ipv4/ip_forward
- route add default gw 192.168.1.254
if i do like this internet works fine from my network, but can't access 10.20.x.x.
update 1: if i use default gw 10.20.26.1.
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -A FORWARD -i eth0 -j ACCEPT
i can access 10.20.x.x, but not internet.
Than i try to use iproute.
echo 1 corp >> /etc/iproute2/rt_tables
ip route add default via 10.20.26.1 dev eth0 table corp
ip rule add from 10.20.0.0/16 table corp
How to make to this work to reach 10.20.x.x and internet. Thanks beforehand.