HostOnNet Blog

Internet on linux virtual machine

Looking for Linux Server Admin or WordPress Expert? We can help.

I am running Apache on VMWare virtual machine running Fedora. Host machine is Windows 2003. On Fedora, i installed samba, so i can share files between Linux and Windows Host machine.

Network is ok, but i could not get internet in the virtual machine. Today i spend some time with Google and found solution for this.

The reason i was not able to connect to net was becaue of the routing table.

[root@fedora root]# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.174.0 * 255.255.255.0 U 0 0 0 eth0
169.254.0.0 * 255.255.0.0 U 0 0 0 eth0
127.0.0.0 * 255.0.0.0 U 0 0 0 lo
default fwhwin 0.0.0.0 UG 0 0 0 eth0

As per network settings of VMWare, Gateway IP is 192.168.174.2

So i added it to the routing table by

[root@fedora root]# route add -net default gw 192.168.174.2

Now the routing table is

[root@fedora root]# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.174.0 * 255.255.255.0 U 0 0 0 eth0
169.254.0.0 * 255.255.0.0 U 0 0 0 eth0
127.0.0.0 * 255.0.0.0 U 0 0 0 lo
default 192.168.174.2 0.0.0.0 UG 0 0 0 eth0
default fwhwin 0.0.0.0 UG 0 0 0 eth0

There is two default gateways, don’t know its a problem, anyway i removed it with following command

[root@fedora root]# route del -net default gw fwhwin
[root@fedora root]# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.174.0 * 255.255.255.0 U 0 0 0 eth0
169.254.0.0 * 255.255.0.0 U 0 0 0 eth0
127.0.0.0 * 255.0.0.0 U 0 0 0 lo
default 192.168.174.2 0.0.0.0 UG 0 0 0 eth0

I am able to ping to IP address of Google.

[root@fedora root]# ping 216.239.37.99
PING 216.239.37.99 (216.239.37.99) 56(84) bytes of data.
64 bytes from 216.239.37.99: icmp_seq=0 ttl=128 time=1764 ms
64 bytes from 216.239.37.99: icmp_seq=1 ttl=128 time=868 ms
64 bytes from 216.239.37.99: icmp_seq=2 ttl=128 time=737 ms
64 bytes from 216.239.37.99: icmp_seq=3 ttl=128 time=587 ms
64 bytes from 216.239.37.99: icmp_seq=4 ttl=128 time=597 ms
64 bytes from 216.239.37.99: icmp_seq=5 ttl=128 time=927 ms
64 bytes from 216.239.37.99: icmp_seq=6 ttl=128 time=617 ms

But i can’t ping to google.com

[root@fedora root]# ping google.com
ping: unknown host google.com

Solved it by adding

nameservers 192.168.174.2

in /etc/resolv.conf

# cat /etc/resolv.conf
nameserver 192.168.174.2

on restarting service network, i found rote table getting resetted, so i edited

vi /etc/sysconfig/network-scripts/ifcfg-eth0

and added GATEWAY in that

[root@fedora network-scripts]# cat /etc/resolv.conf
nameserver 192.168.174.2
[root@fedora network-scripts]# cat ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.174.129
NETMASK=255.255.255.0
GATEWAY=192.168.174.2
[root@fedora network-scripts]#

Now i can access web sites from Fedora.

Posted in Linux

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.