Basic Networking in Linux

 This post is only tailored for debian based distros (debian/ubuntu/mint/kali/tails etc)
most of this info is still the same with others but for eg RHEL based distros change some of the config file names

Check your WiFi card details
:~$ iwconfig

Check your local IP address
:~$ ifconfig
If you’re not behind a router/not using NAT but directly connected with a modem then it will be your public IP.
Here are the different interfaces you might see from executing ifconfig
eth0 – Ethernet/Wired connection
wlan0 – WiFi card
lo -loopback address/localhost/Your machine

To disable or enable any interface
:~$ ifconfig eth0 down
:~$ ifconfig eth0 up

To edit your interface settings edit /etc/network/interfaces
You will see entries like:
auto lo <– Makes the below rule(s) for this interface is automatically used on interface restart
iface lo inet loopback <– iface just stands for interface followed with the interface, inet defines what version of the IP protocol will be used could be inet or inet6

Add wired dhcp rule example:
auto eth0
iface eth0 inet dhcp

or to make a static wired rule:
auto eth0
iface eth0 inet static
address 192.168.1.50 (Can be whatever on 192.168.0.0/24,10.0.0.0/8,172.16.0.0/12)
netmask 255.255.255.0 (or whatever subnet)
gateway 192.168.1.1 (usually the router or a gateway on your network you want to route through)

Now save /etc/network/interfaces and disable then enable the interface you edited

How to see your predefined domain associations, simple view /etc/hosts
there will usually only be two;127.0.0.1 linked to localhost and your hostname but if you’re having problems with DNS and couldn’t apt-get install <package> you could associate the repository domain with their IP in this file

Leave a Reply