Velvet Star Monitor

Standout celebrity highlights with iconic style.

news

How to check if there is internet access ? and how to connect to eth0 and wlan0 in Ubuntu Server [closed]

Writer 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

2

2 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/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

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.