Bala's Blog

Networking in Debian

January 8 2017
150 words, ~1 min. read
debian,  networking,  administration 

Static Network

Single Network Interface

# */etc/network/interfaces*

source /etc/network/interfaces.d/*

auto lo
iface lo inet loopback

allow-hotplug eth0
iface eth0 inet static
    address 192.168.52.8
    netmask 255.255.255.0
    network 192.168.52.0
    broadcast 192.168.52.255
    gateway 192.168.52.2

Multiple Network Interfaces

# /etc/network/interfaces

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

allow-hotplug eth0
iface eth0 inet static
	address 15.154.53.39
	netmask 255.255.254.0
	network 15.154.0.0
	broadcast 15.154.53.255
	gateway 15.154.52.1

allow-hotplug eth1
iface eth1 inet static
	address	192.168.9.8
	netmask	255.255.0.0	
	network	192.168.0.0	
	broadcast 192.168.255.255

DHCP Network

# */etc/network/interfaces*

source /etc/network/interfaces.d/*

auto lo
iface lo inet loopback

allow-hotplug eth0
iface eth0 inet dhcp

# for DHCPv6 (used for IPv6), use inet6 like the one shown below,
# iface eth0 inet6 dhcp

# IPv6 can be auto-configured using Statless Address Auto Configuration (SLAAC),
# iface eth0 inet6 auto

DNS

# /etc/resolv.conf

search sbchand.net
nameserver 192.168.52.1

Note

Individual interfaces could be restarted using systemctl

# systemctl restart ifup@eth0