Recently i had to configure my squid server as NAS server on a temporary basis, which is my backup squid server so no load on it, i configured NAS attached new HDD everything is fine, i have around 3 networks in my lan with a linux server as gateway for all the networks, my squid server has two network cards one is attached to wifi router with its ip as gateway, rest of the nic configured ip in network A of the 3 networks.
GATEWAY0=192.168.60.254
NETMASK0=255.255.255.0
ADDRESS0=192.168.70.0
GATEWAY1=192.168.60.254
NETMASK1=255.255.255.0
ADDRESS1=192.168.80.0
at the end of every entry number changes as your network entries go on 0 , 1 , 2 ... so on.
After that try restart and check routes.
[root@gw~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.60.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
192.168.70.0 192.168.60.254 255.255.255.0 UG 0 0 0 eth0
192.168.80.0 192.168.60.254 255.255.255.0 UG 0 0 0 eth0
192.168.30.0 192.168.20.254 255.255.255.0 UG 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 1003 0 0 eth1
0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 eth1
My networks
192.168.60.x A network
192.168.70.x B network
192.168.80.x C network
Linux gateway server with three nics.
192.168.60.254
192.168.70.254
192.168.80.254
Squid / NAS server
eth0 192.168.60.10
eth1 192.168.1.3 wifi router (192.168.1.1 gateway)
But main problem is i'm unable to reach B and C networks since im using wifi router's ip as gateway. If change gateway 192.168.1.1 to 192.168.60.254, i can reach BC networks, but i can't connect to internet via wifi router, so in order to get internet my gateway should be 10.10.1.1 and also i should reach B and C networks via 192.168.1.254
It took me little time but i did it, all we have to do it leave the wifi routers ip as default gateway and just added static routes of the B and C networks,
[root@gw]# route add -net 192.168.70.0 netmask 255.255.255.0 gw 192.168.60.254 dev eth0
[root@gw]# route add -net 192.168.80.0 netmask 255.255.255.0 gw 192.168.60.254 dev eth0
Great it's working but they are getting flushed away on restart of network, so i created a file called route-eth0 since my lan is connected to eth0 interface. and added entries for rest of 2 networks Lets see how
[root@gw]# route add -net 192.168.70.0 netmask 255.255.255.0 gw 192.168.60.254 dev eth0
[root@gw]# route add -net 192.168.80.0 netmask 255.255.255.0 gw 192.168.60.254 dev eth0
Great it's working but they are getting flushed away on restart of network, so i created a file called route-eth0 since my lan is connected to eth0 interface. and added entries for rest of 2 networks Lets see how
On my NAS / SQUID server
[root@gw]# vim /etc/sysconfig/network-scripts/route-eth0
GATEWAY0=192.168.60.254
NETMASK0=255.255.255.0
ADDRESS0=192.168.70.0
GATEWAY1=192.168.60.254
NETMASK1=255.255.255.0
ADDRESS1=192.168.80.0
at the end of every entry number changes as your network entries go on 0 , 1 , 2 ... so on.
After that try restart and check routes.
[root@gw~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.60.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
192.168.70.0 192.168.60.254 255.255.255.0 UG 0 0 0 eth0
192.168.80.0 192.168.60.254 255.255.255.0 UG 0 0 0 eth0
192.168.30.0 192.168.20.254 255.255.255.0 UG 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 1003 0 0 eth1
0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 eth1
Done. Now you can ping all the networks.
As if now everything is fine, but if i wan to monitor wi-fi traffic by accessing wifi route 192.168.1.1 i have to add route for 192.168.1.0 in my windows pc.
Open command prompt
C:\>route add 192.168.1.0 mask 255.255.255.0 192.168.60.10 -P
in the above route we are using SQUID/NAS server's IP (192.168.60.128) as a gateway to reach 192.168.1.0 network.
You'll get an idea of above set up , take a look at my network setup in picture.
0 Comments