CPU : PII ++
NICs: 2 or more( depends on your needs)
We using the Ubuntu 5.10 as the PC router configuration platform,Iptables as those NAT and routing configuration.
Check for iptables installed or updated: apt-get install iptables.
Before edit the iptables rules, configure the IP address on the NICs.
In my case, eth0 as the external NIC, connected to DHCP server in LAB.
eth1 as the internal NIC, connect to internal LAN.
#iptables -F –flush all the rules in the filter and nat tables.
IP masquerading:
#iptables –table nat –append POSTROUTING –out-interface eth0 -j MASQUERADE
IP forwarding:
#iptables –append FORWARD –in-interface eth1 -j ACCEPT
Forward packets by kernel:
#echo 1 > /proc/sys/net/ipv4/ip_forward
On client site, connect the PC to the PC router using cross-cable.The gateway point to eth1 address on Pc router.
Test connection : #ping <gateway address>
#ping google.com
Done!If you get response!
Check the routing tables on each site:
#netstat -rn
Some iptables command:
#iptables-save > <file directory> –export the iptables.
#iptables-restore > <file directory> –import iptables.
All the rules created with the iptables cammand are save in memory,when the system reboot,all the rules will be lost.
#/sbin/service iptables save
This executes the iptables init script, which runs the /sbin/iptables-save program and writes the current iptables configuration to /etc/sysconfig/iptables. The existing /etc/sysconfig/iptables file is saved as /etc/sysconfig/iptables.save.The next time the system boots, the iptables init script reapplies the rules saved in /etc/sysconfig/iptables by using the /sbin/iptables-restore command.For ubuntu,iptables configuration was saved as /etc/iptables.up.rules.
March 10, 2007 at 10:53 pm |
Thanks guy,it work!