Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have a problem in my Kali Linux.

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

ifconfig eth0 198.168.198.130 netmask 255.255.255.0 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)?

share|improve this question
1  
Why do you manually change you IP address? –  michas Oct 13 '13 at 9:34

1 Answer 1

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 (e.g. 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. e.g. if you are in a subnet 198.168.198.0/24 you can choose 198.168.198.130 but not 8.8.4.4.

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

this is the step you have done so far.

gateway

network traffic must is 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 192.168.198.1

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 an remote IP:

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

DNS

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.

e.g. the following will configure your system to use google's public nameserver for DSN-resolving:

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

will make your system use the nameserver at IP-address 8.8.8.8. now you should be able to use domain-names, and everything should be working ok:

$ ping unix.stackexchange.com
PING unix.stackexchange.com (198.252.206.16) 56(84) bytes of data.
64 bytes from stackoverflow.com (198.252.206.16): 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 nameserver to use. you can re-trigger this process (provided there is a DHCP-server in your network) by running:

# dhclient -v
share|improve this answer

protected by Community Sep 9 at 20:57

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

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