Skip to content

Instantly share code, notes, and snippets.

@count48
Last active January 21, 2019 15:09
Show Gist options
  • Save count48/be32a589ad38027e088b75a9f0876fa4 to your computer and use it in GitHub Desktop.
Save count48/be32a589ad38027e088b75a9f0876fa4 to your computer and use it in GitHub Desktop.
Configuring network on Linux Debian

Useful Commands while setting up / troubleshooting networking on Debian/Ubuntu

List MAC address for all network interface cards

  /sbin/ifconfig -a | grep HWaddr

Figuring out which network interface is what

  ls -l /sys/class/net

Assigning a static IP to a network interface

Setting up a static ip requires you to edit the file : /etc/network/interfaces.

Below is what this file looks like after all the appropriate setting are done .

  # This file describes the network interfaces available on your system
  # and how to activate them. For more information, see interfaces(5).

  # The loopback network interface
  auto lo
  iface lo inet loopback

  # The primary network interface
  auto eth0
  iface eth0 inet static
      address 10.0.0.41
      netmask 255.255.255.0
      network 10.0.0.0
      broadcast 10.0.0.255
      gateway 10.0.0.1
      dns-nameservers 10.0.0.1 8.8.8.8
      dns-domain acme.com
      dns-search acme.com

Redirecting a port locally using iptables

for example if you want a process running on 49161 to be accessible on 1521.

  sudo iptables -t nat -A OUTPUT -o lo -p tcp --dport 1521 -j REDIRECT --to-port 49161
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment