How to check if there is internet access ? and how to connect to eth0 and wlan0 in Ubuntu Server [closed]
Sophia Terry
I'm trying to install ubuntu server on my old laptop. the reason is it's faster. my problem is internet connection. after installing i have to install some new software from repos. and connect my laptop to my network with eth0. please tell me how to check if there is internet access. and how to connect to a network with eth0 or wlan0. thanks
22 Answers
Run the following command if you do not have an IP. If you do have an IP, skip the first part here and go down to the instructions for DNS:
sudo nano /etc/network/interfacesThen, make sure the file looks like this, if not, make changes:
# The loopback network interface
auto lo eth0
iface lo inet loopback
# The primary network interface
iface eth0 inet dhcpPress CTRL + o and then press ENTER to save the file. Press CTRL + x to exit nano.
Then, bring up the interface and restart networking:
sudo ifup -a
sudo service networking restartAgain, run ifconfig to see if you have an inet address. If so, run the following command to check the network. If the network is good, you will not get any errors:
sudo apt-get updateDNS
If you get errors, you may need to set the dns resolver. To do this, edit resolvconf:
sudo nano /etc/resolv.confNow, set your nameserver to something like 8.8.4.4 for now, so the file should look like this:
nameserver 8.8.4.4Press CTRL + o and then press ENTER to save the file. Press CTRL + x to exit nano.
Then, run the following command to update your dns settings:
sudo resolvconf -uRun the following command to test the network:
sudo apt-get updateor
To check to see if you have internet, run the following command; the less percent packet loss, the better:
ping 8.8.8.8 Just connect the network cable and run ifconfig. If you get an IP-address you're good to go. If not, you need to edit the /etc/network/interfaces file
Eth0 with dhcp:
# The loopback network interface
auto lo eth0
iface lo inet loopback
# The primary network interface
iface eth0 inet dhcp
Eth0 with static IP:
# The loopback network interface
auto lo eth0
iface lo inet loopback
# The primary network interface
iface eth0 inet static address 192.168.1.99 netmask 255.255.255.0 broadcast 192.168.1.255 network 192.168.1.0 gateway 192.168.1.1
dns-nameservers 192.168.1.1
For wlan0 with dhcp and WEP encryption add:
auto wlan0
iface wlan0 inet dhcp wireless-essid myssid wireless-key a1b2c3d4e5
For wlan0 with dhcp and WPA add:
auto wlan0
iface wlan0 inet dhcp
wpa-ssid myssid
wpa-psk a1b2c3d4e5
Obviously you need to set your own IP, gateway, wifi password etc.