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 have configured Ubuntu 12.04 as Gateway machine.its having two interfaces

 eth0 with ip  192.168.122.39(Static) and 

 eth1 connected to modem with ip address 192.168.2.3(through DHCP).

ip-forwarding is enabled in router box.

Client machine is configured as:

ip address 192.168.122.5 and gateway 192.168.122.39

Client machines can ping router box(192.168.122.39).but when pinged 8.8.8.8 reply is not reaching Client machines but in the tcpdump output on gateway i can see echo request for 8.8.8.8 but never echo reply.Is this because of 122.5 not forwarding request to 2.0 network.Can u please help me in fixing this.

edit:STEPS FOLLOWED

This machine is running as XEN HVM.

Router machine:two interfaces eth0:192.168.122.39(static ip) eth1:192.168.2.3 on router

  iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE 

 iptables -A FORWARD -i eth0 -j ACCEPT

 iptables -A FORWARD -i eth1 -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT

ptables -A FORWARD -i eth0 -o eth1 -j ACCEPT

On the client machine

 ping 8.8.8.8

on the gateway tcpdump result

tcpdump -v -i eth0

192.168.122.1 is the virtual bridge

tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes

14:17:26.352383 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto ICMP (1), length 84) 192.168.122.1 > google-public-dns-a.google.com: ICMP echo request, id 1541, seq 8395, length 64

14:17:26.938156 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto ICMP (1), length 84) 192.168.122.1 > google-public-dns-a.google.com: ICMP echo request, id 1513, seq 10735, length 64

tracepath 8.8.8.8. from Client machine:

tracepath 8.8.8.8

1: 192.168.122.39 0.046ms pmtu 1500

1: 192.168.122.5 0.259ms

1: 192.168.122.5 0.188ms

2: no reply

3: no reply

share|improve this question
1  
What is the source IP address of the echo request coming out of the gateway? If it's not 192.168.2.3, that's your problem. NAT/masquerading is not set up correctly. The replies will never get back to the machine since only the gateway machine knows to send them there. –  David Schwartz Oct 10 '12 at 11:21

1 Answer 1

up vote 2 down vote accepted

Your modem doesn't know how to reach 192.168.122.0/24 network. You have to do NAT on your router or you have to tell your modem that 192.168.122.0/24 should be routed through 192.168.2.3.

For NAT try with these rules:

iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE   
iptables -A FORWARD -i eth0 -j ACCEPT
iptables -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT

Restart your firewall to flush old rules.

share|improve this answer
    
Actually i am not able to ping 8.8.8.8.whenever i make a rqst to 8.8.8.8 in the tcpdump out of gateway machine i can see echo request but no reply.So doesnt that mean 122 network is not forwarding request to 2.0 network? can u help me please guide me :) –  Kevin Parker Oct 10 '12 at 9:20
1  
Your gateway forwards requests from 122. The problem is with replies. Your modem does not know where 192.168.122 network is. So if it got a reply from 8.8.8.8 when trying to sent it to 192.168.122 network it will forward it to its gateway and not to your gateway. If you can set a static route in your modem you could set it to route 192.168.122.0/24 network via 192.168.2.3. –  Laurentiu Roescu Oct 10 '12 at 12:25
    
I did this on router route add -net 192.168.122.0 netmask 255.255.255.0 gw 192.168.2.3 dev eth1>but still the same.. :( –  Kevin Parker Oct 10 '12 at 12:35
1  
This route should be applied on modem, not on router. NAT is a solution too. But the last line has '-i eth1 -o eth1' which is not correct. I suggest you to remove this part or to correct it to -o eth0. –  Laurentiu Roescu Oct 10 '12 at 13:20
    
If NAT ing is an option,then why am i not able to ping public networks. Is anything wrong with the NATing... –  Kevin Parker Oct 10 '12 at 13:40

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.