Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

At the moment I have a router on 192.168.0.1, a Linux box on 192.168.0.2 and desktop clients from 192.168.0.3.

Everything works with 192.168.0.1 as the default gateway.

I'd like to send the traffic from the desktop clients via the Linux box before it goes out through the router so I can sniff the traffic (some of these are wireless connections).

Can I set the default gateway to 192.168.0.2 on the desktop clients and then perhaps add some iptables rules to forward this traffic through 192.168.0.1?

Quite happy to change the client desktops to another subnet if that makes it easier. Thanks in advance.

share|improve this question

1 Answer 1

Yes. No iptables rules are needed. Normal routing will send the packets to their destination. Just make sure IP forwarding is enabled. Just remember, you won't see the packets going in the other direction unless you make a similar configuration in the router. Turn off ICMP redirects.

share|improve this answer
    
Thanks. cat /proc/sys/net/ipv4/ip_forward returns 1, but setting the default gateway on a client desktop to 192.168.0.2 results in browser requests timing out. –  rich Sep 1 '12 at 11:13
    
Turn off the firewall on the machine. –  David Schwartz Sep 1 '12 at 11:14
    
Same behaviour. –  rich Sep 1 '12 at 11:51
1  
if its all traffic I would find it easier to add a 2nd ip to the linux box and have the router and linux box on a different network ip ie linux/router 10.1.1.x and every one else/linux 2nd ip on 192.168.1.x the masquerade lines arent to hard in iptables since you want to allow every thing. its 4? iptables lines with 2 nics may be a tad more if its just 1 nic and 2 ip's. also the monitoring app may make you have 2 nics just to be able to attach to 1 device and monitor every thing logically. –  Kendrick Sep 1 '12 at 17: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.