Linux Networking

Commands, Tips and Tricks.
created by on 2013-03-17

Set a network interface metric

Show the metrics

route -n
netstat -nr

Change the metric for an interface

sudo route add -net default gw 10.10.0.1 netmask 0.0.0.0 dev wlan0 metric 1
sudo route del -net default gw 10.10.0.1 netmask 0.0.0.0 dev wlan0 metric 0

Stackoverflow.com - Set Network Interface Metric

Bridge Configuration

/etc/network/interfaces

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
  wpa-conf /etc/wpa_supplicant.conf
  address 192.168.2.105
  network 192.168.2.0
  netmask 255.255.255.0
  gateway 192.168.2.1
  dns-nameservers 192.168.2.1

iface eth0:1 inet static
  address 192.168.2.105
  network 192.168.2.0
  netmask 255.255.255.0

iface eth0:2 inet static
  address 192.168.2.109
  network 192.168.2.0
  netmask 255.255.255.0

serverfault - Pick the default network interface

DHCP Configuration

/etc/network/interfaces

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
  wpa-conf /etc/wpa_supplicant.conf
  address 192.168.2.105
  netmask 255.255.255.0
  gateway 192.168.2.1
  dns-nameservers 192.168.2.1

auto eth1
iface eth1 inet static
  address 192.168.2.105
  netmask 255.255.255.0
  gateway 192.168.2.1
  dns-nameservers 192.168.2.1

auto eth2
iface eth2 inet static
  address 192.168.2.109
  netmask 255.255.255.0
  gateway 192.168.2.1
  dns-nameservers 192.168.2.1
Tags:
Fork allmark on GitHub