Needed program:
Iptables

PC 1

system gateway = 192.168.2.1 (eth1)

Eth1: (connected to internet with configuration) 192.168.2.2 netmask 255.255.255.0

Eth0: (other PC connected to this port) 192.168.1.1 netmask 255.255.255.0  (with cross cable maybe)

other PC configuration : 192.168.1.2 netmask 255.255.255.0 gateway 192.168.1.1 dns 192.168.1.1

If system is configured to start with defined script below then second PC can be access to internet if it’s network address equals to 192.168.1.x and gateway is 192.168.1.1 and dns is 192.168.1.1

iptables -A FORWARD –in-interface eth0 –out-interface eth1 –source 192.168.1.0/255.255.255.0 -m state –state NEW -j ACCEPT

iptables -A FORWARD -m state –state ESTABLISHED,RELATED -j ACCEPT

iptables -A POSTROUTING -t nat -j MASQUERADE

echo 1 > /proc/sys/net/ipv4/ip_forward

hope this helps people who want to connect two pc and give internet access to both of them.

Buy me a beer

Related posts:

  1. how to assign multiple ip address on one ethernet (For linux) Assign new ip =   ifconfig eth0 192.168.1.10 Assign IP/Subnet...
  2. TI’S NEWEST VOIP GATEWAY SOLUTIONS OFFER MANUFACTURERS INCREASED PERFORMANCE, SCALABILITY AND SUPPORT FOR VIDEO CAPABILITIES OVER ENTERPRISE NETWORKS Texas Instruments Incorporated (TI) today announced the newest members of...
  3. ata 2.01 action 0×2 frozen (soft reset problem) ata2.01: qc timeout (cmd 0xa0) ata2.01: exception Emask 0×0 SAct...
  4. How to find active local computers on a LAN with Linux machine This entry gives a way to find active computers on...
  5. linux watch command & example usage you can use watch command directly like this watch –interval=1...