Ubuntu server acting as a two interface router

GMX750 asked:

I’m trying to set up a squid proxy server using Ubuntu server 12.04

I’m very new to Ubuntu but I have managed to get some simple things done.

I bought a second PCI interface and have managed to install it on the server.

My goal is to forward all packets from one interface (or subnet) to another. I think this is one of the first steps before configuring squid itself.

From my Ubuntu server I can ping devices in both subnets. but from my laptop, which is in subnet 192.168.0.0 /24, I cannot ping my router, which is in the other subnet 192.168.1.0/24.

Both router and laptop respond to ICMP requests when sent from my Ubuntu server.

I have also activated net.ipv4.ip_forward=1 in sysctl.conf

output of sudo ip route :

default via 192.168.1.254 dev eth1 metric 100
192.168.0.0/24 dev eth0 proto kernel scope link src 192.168.0.200
192.168.1.0/24 dev eth1 proto kernel scope link src 192.168.1.200

output of sudo iptables -nvL :

Chain INPUT (policy ACCEPT 339 packets, 55782 bytes) 

Chain FORWARD (policy ACCEPT 185 packets, 12382 bytes) 

Chain OUTPUT (policy ACCEPT 276 packets, 25481 bytes) 

Do you have any idea why this setup won’t work? I’m sure I’m missing something.

My answer:


To enable Linux to route packets between interfaces, turn on IPv4 routing by running this command:

sysctl -w net.ipv4.ip_forward=1

To make it a permanent change, add it to /etc/sysctl.conf:

net.ipv4.ip_forward = 1

View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.