I got stuck with one problem I cant find solution. I have linux pc with two NIC. first nic (eth1) is connected to public ip (probably switch or whatever, doesnt really mater) so eth1 is connected to wan and another eth0 that I connected to switch and make it a lan nic.
configuration:
eth1 ip address 88.200.1xx.xxx //xxx's are cuz of security reasons
eth0 ip address 192.168.1.1
wan ——> [eth1 (linux PC) eth0]<—->[switch]<—-> [eth1 (PC1)]
Now I want to connect this two networks, so PC1 can access linux PC and wan. I think I know how to do it but I cant confiugre it right. This is what I tried:
- I turend on ip forwarding (for sure)
- I set eth1 default gw to the right ip on the wan
- I tried to set eth0 default gw to the same ip (but i couldnt)
What or how can I do this, I was trying with linux route command, but I got stuck.
Please help.
Best Answer
If you have 2 NICs on a Linux box, both configured with IP's you don't have to add a route from one network to another. That will be done automatically.
Add a default gateway address on the WAN NIC. Do not do this in the configuration of the LAN NIC.
Then enable forwarding in the kernel:
To make it auto-set this value on boot uncomment this line in
/etc/sysctl.conf
Then set up some rules in iptables to perform the natting and forwarding:
that should do it.