Richard's Diary

Saturday, January 3, 2009

Created Subnet With Internet Connectivity Using NAT I am very happy
  1. To statically setup ip and subnet of interface on (this creates the network of 2 computers)
    1. Linux host #1 (which will function as a Linux router since it has a second interface connected to another network - the internet)
      ifconfig eth0 netmask up
    2. Linux host #2
      ifconfig eth0 netmask up
    3. when i pinged each machine they recognized and responded to each other (because iptables -L --verbose showed that each machine accepted ICMP echo-request input and accepted all output. iptables also shows the number and size of packets that matched for each rule)
  2. to forward all packets in and out on internet interface (this establishes internet connectivity for the newly created network, namely host #2 since the router already has internet)
    1. echo 1 > /proc/sys/net/ipv4/ip_forward
    2. iptables -A POSTROUTING -t nat -o ath0 -s -d 0/0 -j MASQUERADE
    3. iptables -A FORWARD -o ath0 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
    4. iptables -A FORWARD -i ath0 -m state --state ESTABLISHED,RELATED -j ACCEPT
    5. added the following to /etc/resolv.conf so that host #2 could resolve domains, leveraging the name server assigned to router
      search (this could be anything)

© 2010 Picky Ricky, Inc. originalblog