1

I have 2 computer in local network which have CentOS both. One has wireless card which can use internet connection. Other computer does not have internet connection. I want to route ip addresses in order to connect internet with other computer too.

Here is what I tried.

Pc :
eth0
Ip address : 22.150.16.100
Netmask : 255.255.255.0

Laptop :
eth0
Ip address : 22.150.16.200
Netmask : 255.255.255.0

wlan0 
Ip address : 192.168.2.88
netmask : 255.255.255.0

With this network connection I typed in PC :

route add default gw 22.150.16.200

and also ip_forwarding is enable in Laptop. However when I ping google with PC it says unknown host. I think I missed something which I do not know how to solve it.. Could you plase help me ?

  • unknown host means it can't resolve names to IP address. Check your routing by pinging an IP address: Ping Google DNS with ping 8.8.8.8. If that works, then your configuration above is fine - all you need to do now is to fix name resolution on the PC. – garethTheRed Aug 9 '14 at 10:44
  • @garethTheRed I see, is there any option that google does not know 22.150.16.100 ip address? Maybe I should change some other option? – goGud Aug 9 '14 at 11:56
  • 1
    You need to make sure that everything is working by IP address first, before you investigate why things aren't working by name. From your PC, ping the laptop by IP, if that works, ping your WiFi router by IP address, if that works, ping any internet IP address you know that responds to ping request - Google (ping 8.8.8.8) is one I always use. If you're using the 22.x.x.x address range as your private network, then Google (or any other DNS server) will not, and shouldn't, know about it. Only when you're 100% confident that you can ping by IP should you start pinging by name. – garethTheRed Aug 9 '14 at 12:26
  • Not much too add. as internal IP you sould use 192.168.16.X rather than 22.150.16.X, juste in case. – Archemar Aug 9 '14 at 14:04
  • But my laptop which has wlan0 can access internet.. So I want to access internet from PC using Laptop router.. – goGud Aug 10 '14 at 11:55
0

You forgot to NAT wlan0:

$ iptables -A FORWARD -i wlan0 -o eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT
$ iptables -A FORWARD -i eth0 -o wlan0 -j ACCEPT
$ iptables -t nat -A POSTROUTING -s 22.150.16.0/24 -o eth0 -j MASQUERADE
$ iptables-save > /etc/sysconfig/iptables

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.