Linux Networking Lab · Xubuntu · VirtualBox
Terminal Networking with Xubuntu in VirtualBox
A hands-on networking tutorial for a Xubuntu virtual machine running inside VirtualBox on a Windows 11 host. Learn interfaces, IP addressing, routing, DHCP, DNS, ARP, sockets, HTTP, network paths and packet capture almost entirely from the Linux terminal.
Understand the VirtualBox Network
Before touching Linux commands, understand where your Xubuntu VM sits. VirtualBox creates a virtual network adapter that Xubuntu treats much like a physical Ethernet interface.
| Mode | Internet | VM → Windows | Windows → VM | Best Use |
|---|---|---|---|---|
| NAT | Yes | Yes | Not directly | General Internet access |
| Bridged | Yes | Yes | Yes | VM acts like another LAN computer |
| Host-only | Usually no | Yes | Yes | Isolated host/VM lab |
| Internal Network | No | No | Other VMs | Multi-VM networking labs |
Inspect Interfaces and IP Addresses
Open Xubuntu Terminal with Ctrl + Alt + T. Your first job is
to discover which interfaces Linux knows about.
$ ip link $ ip addr # shorthand $ ip a # show assigned host addresses $ hostname -I
You will normally see lo, the loopback interface, and an
Ethernet interface such as enp0s3. Your exact interface name
may differ.
1: lo: <LOOPBACK,UP,LOWER_UP>
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP>
inet 10.0.2.15/24
Read the Routing Table
An IP address tells you who the machine is on a network. The routing table tells Linux where packets should go.
$ ip route
A typical VirtualBox NAT configuration may resemble:
default via 10.0.2.2 dev enp0s3
10.0.2.0/24 dev enp0s3 proto kernel scope link src 10.0.2.15
The default route is used when Linux does not have a more
specific route for the destination.
# show only the default route $ ip route show default # ask Linux how it would reach this address $ ip route get 8.8.8.8
Test Connectivity Layer by Layer
Good troubleshooting moves outward from the local machine instead of randomly changing settings.
- Test the local TCP/IP stack.
- Test the VM's own interface address.
- Test the default gateway.
- Test an Internet IP address without depending on DNS.
- Finally, test a hostname to verify DNS resolution.
# 1 — loopback $ ping -c 4 127.0.0.1 # 2 — your own IP; substitute the real address $ ping -c 4 10.0.2.15 # 3 — discover the gateway first $ ip route show default # then test it; example only $ ping -c 4 10.0.2.2 # 4 — Internet without DNS $ ping -c 4 1.1.1.1 # 5 — Internet plus DNS $ ping -c 4 example.com
Investigate DNS
DNS translates names such as example.com into IP addresses.
Xubuntu normally integrates DNS configuration with NetworkManager and the
system resolver.
$ cat /etc/resolv.conf $ resolvectl status $ resolvectl query example.com
Install dig
$ sudo apt update $ sudo apt install dnsutils $ dig example.com # query a specific resolver $ dig @1.1.1.1 example.com # compact result $ dig +short example.com
Control NetworkManager from the Terminal
Xubuntu normally uses NetworkManager. Its command-line client,
nmcli, lets you inspect and control networking without opening
the graphical settings application.
$ nmcli $ nmcli general status $ nmcli device status $ nmcli device show enp0s3 $ nmcli connection show $ nmcli connection show --active
Disconnect and reconnect
$ sudo nmcli device disconnect enp0s3 $ nmcli device status $ ip a $ sudo nmcli device connect enp0s3 $ ip a $ ip route
enp0s3 with your actual interface name before running
interface-specific commands.
Inspect DHCP Configuration
VirtualBox NAT normally supplies network configuration automatically.
NetworkManager represents automatic IPv4 configuration with
ipv4.method auto.
$ nmcli connection show # example connection name $ nmcli connection show "Wired connection 1" # display IPv4 information for the interface $ nmcli -f IP4 device show enp0s3
Explore ARP and the Neighbor Table
On an IPv4 Ethernet network, Linux maintains neighbor information that maps reachable local IP addresses to Layer 2 MAC addresses.
$ ip neigh
You may see an entry similar to:
10.0.2.2 dev enp0s3 lladdr 52:54:00:12:35:02 REACHABLE
Generate traffic and inspect the table again:
$ ping -c 1 10.0.2.2 $ ip neigh # monitor changes live $ ip monitor neigh
Press Ctrl+C to stop a live monitor.
Find the Virtual NIC's MAC Address
$ ip link show enp0s3
Look for link/ether:
link/ether 08:00:27:12:34:56
You can compare the information with NetworkManager:
$ nmcli device show enp0s3
Inspect Listening Ports and Connections
IP addresses identify hosts. TCP and UDP ports help identify network services running on those hosts.
# TCP + UDP listening sockets $ ss -tuln # include process information $ sudo ss -tulpn # current TCP connections $ ss -tn
TCP
Display TCP sockets.
UDP
Display UDP sockets.
Listening
Show services waiting for connections.
Numeric
Show numeric addresses and ports.
Build a Temporary Web Server
One of the easiest ways to understand client/server networking is to become the server.
$ mkdir -p ~/network-lab $ cd ~/network-lab $ echo "Hello from my Xubuntu VM" > index.html $ python3 -m http.server 8000
The server should report that it is listening on port 8000.
Open another Xubuntu terminal:
$ ss -ltn $ curl http://127.0.0.1:8000
Expected page content:
Hello from my Xubuntu VM
curl became
the client. Both communicated through the Linux networking stack.
Return to the server terminal and press Ctrl+C when finished.
Explore HTTP with curl
# fetch a page $ curl https://example.com # headers only $ curl -I https://example.com # verbose connection details $ curl -v https://example.com # save output to a file $ curl -o page.html https://example.com $ ls -lh page.html
Trace a Network Path
$ sudo apt install traceroute $ traceroute example.com # alternative $ tracepath example.com
Experiment with Bridged Networking
Bridged networking lets you compare VirtualBox NAT with a VM that behaves more like another computer connected directly to the physical LAN.
First shut down Xubuntu:
$ sudo poweroff
In VirtualBox on Windows 11, open the VM's network settings and change the adapter from NAT to Bridged Adapter. Start Xubuntu again.
$ ip a $ ip route
Compare the new configuration with the values you recorded while using VirtualBox NAT. The VM may now receive an address belonging to the same physical LAN as the Windows host.
inet 192.168.1.73/24
Compare NAT and Bridged mode
$ hostname -I $ ip route $ ip neigh $ resolvectl status
Capture Packets with tcpdump
Packet capture connects terminal commands with the packets actually moving through the interface.
$ sudo apt install tcpdump # list capture interfaces $ sudo tcpdump -D # capture traffic on the VM interface $ sudo tcpdump -i enp0s3
Capture ICMP
$ sudo tcpdump -i enp0s3 icmp
In another terminal:
$ ping example.com
Capture DNS
$ sudo tcpdump -i enp0s3 port 53
Generate a lookup:
$ dig example.com
Capture HTTP traffic from the local test server
Start the Python server in one terminal:
$ cd ~/network-lab $ python3 -m http.server 8000
Then inspect traffic associated with TCP port 8000:
$ sudo tcpdump -i any port 8000
Generate a request from another terminal:
$ curl http://127.0.0.1:8000
A Repeatable Troubleshooting Workflow
When networking breaks, gather evidence before changing configuration. Work from the local interface outward.
# 1. Does Linux see the interface? $ ip link # 2. Does it have an IP address? $ ip addr # 3. What does NetworkManager think? $ nmcli device status # 4. Is there a default route? $ ip route # 5. Does localhost work? $ ping -c 2 127.0.0.1 # 6. Discover and test the real gateway $ ip route show default # 7. Can we reach an Internet IP? $ ping -c 2 1.1.1.1 # 8. Does DNS work? $ resolvectl query example.com # 9. Does HTTPS work? $ curl -I https://example.com # 10. What services are listening? $ sudo ss -tulpn
10.0.2.2 is a common VirtualBox NAT example, not a universal
value. Use ip route show default to discover the gateway
actually assigned to your VM.
Networking Commands Worth Memorizing
Addresses
Inspect interface IP configuration.
Interfaces
Inspect Layer 2 interfaces and state.
Routing
Inspect where packets will be sent.
Neighbors
Inspect local IP-to-MAC mappings.
Reachability
Generate ICMP echo traffic.
Sockets
Inspect ports and connections.
NetworkManager
Inspect and control network configuration.
Resolver
Inspect and query DNS resolution.
DNS
Perform detailed DNS queries.
Application Test
Test HTTP and HTTPS from the shell.
Path
Explore hops toward a destination.
Packets
Capture traffic from an interface.
A useful five-command snapshot is:
$ ip a $ ip route $ nmcli device status $ resolvectl status $ sudo ss -tulpn
Where to Go Next
Once the commands make sense individually, combine them into complete labs.
- NAT lab: identify the VM address, subnet, gateway and DNS configuration, then verify Internet connectivity.
- Packet lab: run tcpdump while generating traffic with ping, dig and curl.
-
Server lab: run
python3 -m http.server 8000and inspect its socket withss. - Bridged lab: place Xubuntu directly on the LAN and compare its IP address, routes, DNS configuration and neighbor table with NAT mode.
- Host-only lab: create an isolated network between Windows and the Xubuntu VM and compare its routes with NAT and Bridged configurations.
- Two-VM lab: create another Xubuntu VM and connect both through a VirtualBox Internal Network.