Back to Posts

Linux Networking 101

Posted in Linux & Sysadmin

Linux Basic Networking

This is a quick guide and/or reference to Linux Basic Networking. I’ll be adding more as time goes on. Most examples will be targetd towards Debain flavors.

Before changing network configurations it’s beneficial to have physical access to the machines. If you’re using ssh and restarting the networking service with an error, how will you access the machine to fix it?

net-tools

By default more Linux distros are not including ifconfig or netstat since they are considered to be depreciated. It would be best practice to learn alternative tools, but if you wish to install, run:

apt-get install net-tools


Up & Down

Quickly bring a network interface up or down

ifdown eth1
ifup eth1


Set Static IP

Set Static IP of host on Debian in /etc/network/interfaces. This will set the ip to 192.168.1.10 with the router or gateway to 192.168.1.1 - using auto eth0 will bring the interface up on startup.

auto eth0
iface eth0 inet static
        address  192.168.1.10
        netmask  255.255.255.0
        gateway  192.168.1.1


Once any changes are saved to /etc/network/interfaces, the networking service will need ot be restarted. If you’re on a Desktop enviroment try the Network-Manager. A few commands to note:

systemctl restart networking
systemctl restart network-manager
systemctl reboot


Adding Routes

If you’ve created a new VLAN or Bridge, you may want to access it from other hosts on different networks.

For example, your WAN/Home/NAT’ed network is on 192.168.1.0/24. You have a lab network on 192.168.50.0/24 with a virtual pfSense instance routing the traffic at 192.168.1.20 AND 192.168.50.1. You want your RDP or attacking machine on your WAN/Home/NAT’ed network to access the lab network of 192.168.50.0/24.

You’ll simple add the route to your attacking machine, pointing it to the router/gateway.

route add -net 192.168.50.0/24 gw 192.168.1.20


DNS

Linux DNS configs can be located in /etc/resolv.conf. To add google DNS to your machine, simply add the below line and save.

nameserver 8.8.8.8

¦̵̱ ̵̱ ̵̱ ̵̱ ̵̱(̢ ̡͇̅└͇̅┘͇̅ (▤8כ−◦

Read Next

Wakanda CTF