Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

migrated from stackoverflow.com Jul 10 '12 at 4:33

This question came from our site for professional and enthusiast programmers.

    
Please provide the output of iptables -nvL. Can you ping the server's IP in the same subnet as the laptop (i.e. 192.168.0.200)? –  mgorven Jul 10 '12 at 4:41
    
Chain INPUT (policy ACCEPT 339 packets, 55782 bytes) Chain FORWARD (policy ACCEPT 185 packets, 12382 bytes) Chain OUTPUT (policy ACCEPT 276 packets, 25481 bytes) I cannot figure out this mini-Markdown formatting -.-" –  GMX750 Jul 10 '12 at 18:18
    
Rather edit your question when adding additional information. –  mgorven Jul 10 '12 at 18:50
    
Can you ping the server's IP in the same subnet as the laptop (i.e. 192.168.0.200)? What's the default gateway on the laptop? –  mgorven Jul 12 '12 at 0:49
    
Yes i can ping 192.168.0.200 and 192.168.1.200 as well. my laptop's default gateway is 192.168.0.200. –  GMX750 Jul 12 '12 at 8:28

2 Answers 2

up vote 1 down vote accepted

The problem is that the router you are trying to contact doesn't know how to route the packets back to the laptop, since it doesn't know about the 192.168.0.0/24 subnet. The packets from the laptop arrive at the router, but the response packets either get sent to the wrong place (the Internet), or don't get sent at all.

You need to configure the router with a static route for 192.168.0.0/24 via 192.168.0.200. Doing this depends on the specific router you have, but look through the web interface for a section about routing.

share|improve this answer
    
Thanks for the repply. I have been thinking about the problem and yes you are right. my router does not know about the two networks reachable from the same interface. It's a Speedtouc Thomson TG787. I will have a look at the CLI reference guide. Thanks again –  GMX750 Jul 15 '12 at 21:34

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
share|improve this answer
    
thanks for the reply, but, I already did that. "I have also activated net.ipv4.ip_forward=1 in sysctl.conf" –  GMX750 Jul 10 '12 at 9:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.