I have a problem in my Kali Linux.

I cannot connect to the Internet after changing my IP address using this command:

ifconfig eth0 netmask up

After this, when I open my iceweasel browser, it shows

cannot connect to server 
check your internet connection

How can I solve it (and I have forgotten my old IP address)?

  • 2
    Why do you manually change you IP address? – michas Oct 13 '13 at 9:34

For "normal" network connectivity, you basically need three things:

  • A valid IP-address

  • A gateway, that provides you with a connection to the "Internet"

  • A nameserver that resolves host-names (for example, unix.stackexchange.com) to IP-addresses.

IP address

You cannot choose an arbitrary IP address; instead you must choose one according to your local network topology. For example, if you are in a subnet, you can choose, but not

Make sure that the IP address you chose is actually valid ("contact your network administrator" :-))

Also you must make sure that your IP is unique to your local network, e.g. you cannot have two hosts with the same IP address (again "contact your network administrator")

This is the step you have done so far.


Network traffic must be sent to a gateway, that will know how to distribute it further to the "rest of the Internet". When manually setting the IP address, you will also have to manually set the gateway of your network connection to your router.

Something like:

# route add default gw

The actual IP address of the router is network dependent (but for private networks like yours, it is often <network>.1).

If you have configured the gateway correctly, you should already have full Internet connectivity, that is: you should be able to reach any (reachable) server. You can confirm whether it's working by trying to ping a remote IP address:

$ ping
PING ( 56(84) bytes of data.
64 bytes from icmp_seq=1 ttl=50 time=51.6 ms

(note however that some network administrators like blocking ping requests with a firewall).


Even if you are connected to the net, you still might not be able to use firefox/iceweasel, simply because your system doesn't yet know how a name like unix.stackexchange.com can be translated to an IP address.

You have to specify a nameserver as well. This can be configured in the file /etc/resolv.conf.

For example, the following will configure your system to use Google's public nameserver for DNS resolving:

# echo "nameserver" > /etc/resolv.conf

will make your system use the nameserver at IP address Now you should be able to use domain names, and everything should be working OK:

$ ping unix.stackexchange.com
PING unix.stackexchange.com ( 56(84) bytes of data.
64 bytes from stackoverflow.com ( icmp_seq=1 ttl=53 time=146 ms

Simply using DHCP

Many networks offer client network configuration via DHCP, which will automatically provide your computer with information about which IP address, network mask, gateway and name server to use.

You can re-trigger this process (provided there is a DHCP-server in your network) by running:

# dhclient -v

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