April 14, 201115 yr To make a connection between two NIC's (one being local intranet and the other being on the internet), you need to setup NAT by using iptables (linux firewall) Run these commands to achieve NAT eth0 is internet eth1 is local yum install iptablesiptables --flushiptables --table nat --flushiptables --delete-chainiptables --table nat --delete-chainiptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADEiptables --append FORWARD --in-interface eth1 -j ACCEPTecho 1 > /proc/sys/net/ipv4/ip_forwardservice iptables restart
April 14, 201115 yr Moderators For some reason I had to type the path in front of iptables in CentOS 5.5 yum install iptables/sbin/iptables --flush/sbin/iptables --table nat --flush/sbin/iptables --delete-chain/sbin/iptables --table nat --delete-chain/sbin/iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE/sbin/iptables --append FORWARD --in-interface eth1 -j ACCEPTecho 1 > /proc/sys/net/ipv4/ip_forwardservice iptables restart/etc/init.d/iptables restart
April 14, 201115 yr Author Here is a better explanation To accept all packets incoming on a particular interface, in this case the localhost interface: iptables -A INPUT -i lo -j ACCEPT Suppose we have 2 separate interfaces, eth1 which is our internal LAN connection and eth0 which is our external internet connection. We may want to allow all incoming packets on our internal LAN but still filter incoming packets on our external internet connection. We could do this as follows: iptables -A INPUT -i lo -j ACCEPTiptables -A INPUT -i eth1 -j ACCEPT But be very careful - if we were to allow all packets for our external internet interface (for example, eth0 internet connection): iptables -A INPUT -i eth0 -j ACCEPT we would have effectively just disabled our firewall!
Create an account or sign in to comment