How to check if there is internet access ? and how to connect to eth0 and wlan0 in Ubuntu Server
Solution 1
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/interfaces
Then, 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 dhcp
Press 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 restart
Again, 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 update
DNS
If you get errors, you may need to set the dns resolver. To do this, edit resolvconf:
sudo nano /etc/resolv.conf
Now, set your nameserver to something like 8.8.4.4 for now, so the file should look like this:
nameserver 8.8.4.4
Press 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 -u
Run the following command to test the network:
sudo apt-get update
or
To check to see if you have internet, run the following command; the less percent packet loss, the better:
ping 8.8.8.8
Solution 2
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.
Related videos on Youtube
Vannrith
Updated on September 18, 2022Comments
-
Vannrith over 1 year
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
-
LittleByBlue over 8 yearscheck for connection using
ping
egping -c3 google.com
see also:man ping
maybe you need to usesudo ifconfig eth0 up; sudo dhcpd
to set the iface eth0 up and enable dhcp. -
David Foerster over 7 yearsCould you please edit your question to include the output of the terminal commands
lspci -nnk | grep -A2 Network
andLC_MESSAGES=POSIX nm-tool
? Thanks.
-