Submitted by nXtGen on Mon, 23/01/2006 - 13:51.
( categories: )

im using RHL9 and i created squid server as a memeber in the network as 192.168.1.1 now i want to make the server as gateway for internet connection so i put another NIC as 192.168.1.100 and i put the source in the first NIC then connect the second to the switch how can i forward all reqests from the first NIC to the other one ?


edit and run

Conceptor's picture
iptables -A FORWARD -i routerip -o gatewayip -m state --state  ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -i gatewayip -o routerip -j ACCEPT
iptables -t nat -A POSTROUTING -o routerip -j MASQUERADE

note routerip:is the ip address in which connected to router

gatwayip = is the ip address of your network ip first or second nic :-)


Diaa Radwan

bridge the connections

Pronco's picture

This command enables ip forwarding in the kernel

echo 1 > /proc/net/ipv4/ip_forward

but it's not secure if you haven't set up your iptables firewall correctly.

or if you are just forwarding web traffic, just use squid and set the default gateway on the server to the gateway for the wan

IMO, You shouldn't have to forward them. The proxy will automatically connect using the most correct interface


- I'm a code junkie security enthusiast

- http://pronco.manalaa.net

sorry I forgot

Conceptor's picture

enable ip forwarding is essential to have gateway with masq.


Diaa Radwan

i did but

nXtGen's picture

when i connect cables no user was connected (not even ping )

DSL router "ip1" ==== ||serverNIC1 "ip2" ||serverNIC2 "ip3" ======||switch ||user1 "ip4"

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.