Configuring Kali Linux for Networking

Basically, we’re just telling our computer how to talk to other computers on the internet.

First, open up your terminal (the black box with white text) and type in “ifconfig”. This will show you all of the network interfaces that are currently active on your machine. If you see something like “eth0” or “wlan0”, congratulations! You’re already connected to a network.

Now, let’s say we want to connect to a website called “google.com”. To do this, we need to tell our computer where to find it on the internet. This is done by adding an entry in what’s called your DNS (Domain Name System) cache. You can think of this as a phone book for websites instead of remembering all those long IP addresses, you just type in “google.com” and your computer does the rest.

To add an entry to your DNS cache, open up your terminal again and type in “sudo nano /etc/hosts”. This will bring up a text editor called Nano where we can edit our hosts file. Add this line at the bottom:


# This script adds an entry to the DNS cache by editing the hosts file.
# To do so, open the terminal and type in "sudo nano /etc/hosts".

# The following line adds the IP address 192.168.0.1 to the hosts file, with the corresponding domain name "google.com".
# This allows the computer to access the website "google.com" without having to type in the full IP address.
192.168.0.1 google.com

This tells your computer that whenever you type in “google.com”, it should look for an IP address of 192.168.0.1 (which is just a random example replace this with the actual IP address of Google’s servers). Save and close Nano by pressing Ctrl+X, then Y to confirm changes, followed by Enter to exit.

Now that we have our DNS cache set up, let’s try connecting to “google.com” in a web browser (like Firefox or Chrome)! If everything is working correctly, you should see the Google homepage load up.

But what if we want to connect to another website? Or maybe we want to access our own network from within Kali Linux? That’s where routing comes in it tells your computer how to get from point A (your machine) to point B (the other computer). To set this up, open up your terminal again and type in “sudo nano /etc/sysctl.conf”. This will bring up the sysctl configuration file. Add these lines at the bottom:


# This line enables IP forwarding, allowing the computer to route traffic between networks
net.ipv4.ip_forward=1

This tells Kali Linux to allow forwarding of packets between networks (which is what we need for routing). Save and close Nano by pressing Ctrl+X, then Y to confirm changes, followed by Enter to exit.

Now let’s say you have a network with an IP address range of “192.168.0.0/24”. To add this to your routing table (which tells Kali Linux how to get there), open up your terminal again and type in:


# This script adds a route to the routing table in Kali Linux, allowing it to access a network with an IP address range of "192.168.0.0/24".

# Use sudo to run the command with root privileges.
sudo ip route add 192.168.0.0/24 dev eth0
# "ip route" is the command to add a route to the routing table.
# "add" specifies that we are adding a new route.
# "192.168.0.0/24" is the IP address range of the network we want to access.
# "dev eth0" specifies the device (ethernet interface) to use for this route.

This adds a new entry to the routing table, telling Kali Linux that whenever it needs to send packets to an IP address within “192.168.0.0/24”, it should use the network interface called “eth0”.

You’re now a networking guru (or at least, you can pretend). Remember, practice makes perfect keep experimenting and learning new things to become an even better hacker.

SICORPS