echo 1 > /proc/sys/net/ipv4/ip_forward
/etc/sysctl.conf:
net.ipv4.ip_forward = 1
configure A for NAT
Now that we have a connection from A to B, we can tell A to share internet connection with B.
- Go to computer A and share its internet connection with B by typing the two commands :
modprobe iptable_nat
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -A FORWARD -i eth1 -j ACCEPT
Now you do a ping test from remote systemping 8.8.8.8 [ should be working ]
then check ping www.google.com [ if not working then check for /etc/resolve.conf ]
- Run this script on the host A :
#!/usr/bin/env bash
modprobe iptable_nat
echo 1 > /proc/sys/net/ipv4/ip_forward
ifconfig eth1 192.168.0.1 netmask 255.255.255.0
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -A FORWARD -i eth1 -j ACCEPT
- Run this script on the host B where xx.xx.xx.xx is your dns server :
#!/usr/bin/env bash
ifconfig eth0 down
ifconfig eth0 192.168.0.2 netmask 255.255.255.0
route del -net default 2>/dev/null
route add default gw 192.168.0.1 2>/dev/null
echo "nameserver xx.xx.xx.xx" > /etc/resolv.conf
few more links:
http://how-to.wikia.com/wiki/ How_to_set_up_a_NAT_router_on_ a_Linux-based_computer
http://martybugs.net/wireless/ router.cgi
http://gohgarry.wordpress.com/ 2010/04/16/how-to-setup-linux- os-as-router/
http://forum.codecall.net/ topic/48438-configuring-your- linux-server-as-a-router/# axzz2J0AHaM3O
http://glonek.co.uk/linux- router/basic-linux-router/
http://martybugs.net/wireless/
http://gohgarry.wordpress.com/
http://forum.codecall.net/
http://glonek.co.uk/linux-
No comments:
Post a Comment