How to Access Internet Through Terminal in Linux
If you want to know how to access internet through terminal in Linux, the short answer is: check that your network interface is up, confirm you have an IP address and a default route, then test DNS and external connectivity with commands like ping, curl, or wget. On most systems, you can also connect to Wi-Fi directly from the terminal with nmcli or nmtui.
What it means to access the internet from the terminal
“Accessing the internet” from a Linux terminal can mean two different things:
- Connecting your machine to a network, usually by Ethernet or Wi-Fi.
- Verifying that the network can reach the internet, not just your local router.
A system can be connected to a local network and still fail to reach websites because of DNS problems, a missing default gateway, captive portal login, proxy settings, or firewall rules. That is why a good terminal-based check uses a few different commands, not just one.
Quickest way to check if Linux is online
If you need a fast answer, run these commands in order:
ip linkto see whether the network interface is up.ip addrto check whether the interface has an IP address.ip routeto confirm there is a default gateway.ping -c 3 8.8.8.8to test raw internet reachability.ping -c 3 google.comto test DNS resolution.curl -I https://example.comto confirm HTTP access.
If ping 8.8.8.8 works but ping google.com fails, your internet connection is probably fine, but DNS is not.
Check your network interface, IP address, and route
The first step in diagnosing Linux terminal networking is to confirm that the interface is active and has been configured correctly.
1. Check the interface state
ip linkLook for your wired or wireless interface, such as eth0, enp3s0, or wlan0. If you see state DOWN, the interface is not active. If you see state UP, that is a good sign.
You can bring an interface up with:
sudo ip link set dev wlan0 upReplace wlan0 with your actual interface name.
2. Check for an IP address
ip addrFind the interface you are using and look for an IPv4 address such as 192.168.x.x or 10.x.x.x. If there is no address, the machine may not be getting one from DHCP, or the connection has not been established yet.
3. Check the default route
ip routeYou should usually see a line that begins with default via. That tells Linux where to send traffic that is not meant for the local network.
Example:
default via 192.168.1.1 dev wlan0If there is no default route, you may be connected to the router but not actually configured for internet access.
Connect to Wi-Fi from the terminal
For many Linux systems, especially desktops and laptops, the easiest command-line tools are nmcli and nmtui, both part of NetworkManager.
Using nmcli
First, list nearby Wi-Fi networks:
nmcli device wifi listThen connect to your network:
nmcli device wifi connect "YourSSID" password "YourPassword"If you already know the wireless interface name, you can be more specific:
nmcli device wifi connect "YourSSID" password "YourPassword" ifname wlan0To check connection status:
nmcli general statusOr:
nmcli device statusUsing nmtui
If you prefer a text menu instead of typing long commands, use:
nmtuiThis opens a terminal-based interface where you can activate a connection, enter Wi-Fi credentials, and adjust settings without leaving the terminal.
When nmcli is not available
Not every Linux installation uses NetworkManager. Server distributions and minimal systems may use other tools, such as systemd-networkd, netplan, or custom network scripts. In those cases, the commands above may not work, and you will need to use the networking tool configured on that system.
Test internet access with ping, curl, and wget
Once your interface, IP address, and route look correct, test actual internet access.
Test reachability with ping
ping -c 3 8.8.8.8This checks whether your system can reach an external IP address. If this fails, the problem is usually routing, gateway access, VPN issues, or a blocked connection.
Then test a domain name:
ping -c 3 google.comIf this fails but the numeric IP works, DNS is the likely issue.
Test HTTP or HTTPS access with curl
curl -I https://example.comThe -I option requests only headers, which is enough to confirm that the system can reach a web server over HTTPS. A successful response usually includes an HTTP status line such as 200 OK or a redirect.
Test downloads with wget
wget -O - https://example.comThis fetches page content and prints it to the terminal. If you only want to check connectivity, curl -I is usually cleaner.
View DNS settings from the terminal
DNS problems are common when Linux has a local network connection but cannot open websites by name.
Check what DNS server is being used
On systems using systemd-resolved, try:
resolvectl statusThis can show which DNS servers are active for each interface.
You can also inspect the traditional resolver file:
cat /etc/resolv.confIf this file points to a local stub resolver, that is normal on many modern Linux distributions. The important part is whether name resolution actually works.
Test name resolution directly
Depending on what is installed, you can use:
nslookup google.comor:
dig google.comThese commands help confirm whether DNS queries are reaching a working server.
Fix common DNS and routing problems
When internet access fails in the terminal, the issue usually falls into one of a few categories. This simple checklist helps narrow it down quickly.
| Symptom | Likely cause | What to check |
|---|---|---|
| No IP address | DHCP failure, disconnected interface, wrong Wi-Fi password | ip addr, nmcli device status |
| IP address exists, but no internet | No default route, gateway issue, captive portal, VPN problem | ip route, ping 8.8.8.8 |
| Can ping IP, but not domain names | DNS failure | resolvectl status, cat /etc/resolv.conf, nslookup |
| Some sites work, others do not | Proxy, firewall, MTU, or filtering issue | Proxy environment variables, browser or system firewall, VPN settings |
Restart the network connection
If you are using NetworkManager, disconnect and reconnect the interface:
nmcli networking off
nmcli networking onYou can also restart a single connection profile if you know its name:
nmcli connection show
nmcli connection down "Connection Name"
nmcli connection up "Connection Name"Renew DHCP if needed
If the system has no valid IP address, renewing DHCP may help. The exact command can vary by setup, but on many systems you can cycle the connection through NetworkManager or reconnect the interface.
Fix DNS temporarily for troubleshooting
If DNS looks broken, the problem may be the configured resolver rather than the network link itself. You can confirm this by testing a numeric IP first, then a domain name. If the IP works and the domain fails, focus on DNS configuration rather than Wi-Fi or Ethernet.
On some systems, switching DNS servers through NetworkManager or your system’s network configuration can resolve the issue. The exact method depends on the distribution and network stack in use.
Watch for captive portals
Some public Wi-Fi networks require a login page before internet access is allowed. In that case, you may be connected to the network but still unable to reach normal websites from the terminal until you complete the sign-in in a browser or portal page.
What to do if you can reach the router but not the web
If you can ping your router but not external addresses, the issue is often outside your local machine. Check these possibilities:
- The router has no upstream internet connection.
- The default gateway is missing or incorrect.
- A VPN is redirecting or blocking traffic.
- A proxy is required but not configured.
- Firewall rules are blocking outbound traffic.
- The network requires authentication through a captive portal.
Start with this sequence:
ip route
ping -c 3 192.168.1.1
ping -c 3 8.8.8.8
ping -c 3 google.com
curl -I https://example.comThat progression tells you whether the issue is local, routing-related, DNS-related, or web-specific.
Terminal networking commands cheat sheet
| Command | What it tells you |
|---|---|
ip link | Whether interfaces are up or down |
ip addr | Whether the system has an IP address |
ip route | Whether a default gateway exists |
nmcli device status | NetworkManager device state |
nmcli device wifi list | Nearby Wi-Fi networks |
ping -c 3 8.8.8.8 | External IP connectivity |
ping -c 3 google.com | DNS plus connectivity |
curl -I https://example.com | HTTP or HTTPS access |
resolvectl status | Active DNS configuration |
Practical example of diagnosing no internet from the terminal
Here is a simple example of how to narrow down the problem:
- Run
ip addrand confirm your Wi-Fi or Ethernet interface has an IP address. - Run
ip routeand check for a default route. - Run
ping -c 3 8.8.8.8. If this fails, focus on the interface, gateway, or upstream link. - Run
ping -c 3 google.com. If this fails but step 3 works, focus on DNS. - Run
curl -I https://example.com. If this works, your internet access is functioning for web traffic too.
This approach saves time because it separates connection, routing, DNS, and browser or web access problems.
Common mistakes
- Checking only
ping google.comand assuming the whole network is down. - Forgetting that Wi-Fi may be connected locally but not authenticated to the internet yet.
- Assuming DNS is fine when only IP-based tests have been used.
- Using the wrong interface name in commands.
- Not checking the default route after getting an IP address.
Frequently Asked Questions About how to access internet through terminal in linux
How do I check if Linux has internet from the command line?
Use ping -c 3 8.8.8.8 to test raw internet access, then ping -c 3 google.com to test DNS. If the IP works but the domain does not, the network is up but DNS is failing.
What is the fastest way to connect Wi-Fi in the Linux terminal?
If your system uses NetworkManager, nmcli device wifi connect "SSID" password "PASSWORD" is usually the fastest method. If you want a menu-based approach, use nmtui.
Why can I ping an IP address but not a website name?
That usually means DNS is not working. Your internet connection may be fine, but Linux cannot translate domain names into IP addresses.
How do I fix DNS in Linux from the terminal?
Start by checking resolvectl status or cat /etc/resolv.conf. If DNS servers are missing or incorrect, adjust the DNS settings through your network manager or system network configuration.
How do I know if the problem is my router or my Linux machine?
If you can ping your router but not an external IP, the issue may be the router, upstream connection, VPN, or firewall. If you cannot even ping the router, the problem is likely on your Linux machine or local network link.
Can I use curl to test internet access?
Yes. curl -I https://example.com is a good way to confirm that your system can reach a web server over HTTPS from the terminal.
What if nmcli is not installed?
Some minimal Linux systems do not use NetworkManager. In that case, the network may be managed by another service, and you will need to use that tool instead of nmcli.
Conclusion
The most reliable way to access and verify internet connectivity from a Linux terminal is to check the interface state, confirm you have an IP address, verify the default route, and then test both an IP address and a domain name. If needed, use nmcli or nmtui to connect to Wi-Fi, and use resolvectl, ping, and curl to pinpoint whether the problem is routing, DNS, or web access. Once you learn the sequence, terminal-based networking becomes much easier to diagnose.
