Blog on general technical stuff (Datacentre, networking, packets, programming, etc.)
Thursday, 7 May 2015
Debian simple network configuration
I recently deployed a Debian 8.0 box and found that the location for the networking configuration was a little different than the CentOS and RHEL systems I have been used to. After some poking around, I found that the network configuration is stored in /etc/network/interfaces and include files in the /etc/network/interfaces.d directory.
root@debian:/etc/network# ls -l /etc/network
total 24
drwxr-xr-x 2 root root 4096 May 3 23:28 if-down.d
drwxr-xr-x 2 root root 4096 May 3 23:28 if-post-down.d
drwxr-xr-x 2 root root 4096 May 3 23:28 if-pre-up.d
drwxr-xr-x 2 root root 4096 May 4 00:37 if-up.d
-rw-r--r-- 1 root root 240 May 4 20:26 interfaces
drwxr-xr-x 2 root root 4096 May 4 22:43 interfaces.d
lrwxrwxrwx 1 root root 12 May 3 20:24 run -> /run/network
Configuration for an interface can be placed in the interfaces file or by adding a new file under interfaces.d. Files in the interfaces.d directory are sourced by the interfaces file.
root@debian:/etc/network# cat interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
To do a basic network configuration for eth0, put the following in /etc/network/interfaces.d/eth0 (substituting correct network addressing.)
##
# eth0 configuration
auto eth0
iface eth0 inet static
address 192.168.1.10
netmask 255.255.255.0
gateway 192.168.1.254
dns-nameservers 192.168.1.254
The auto keyword defines that this interface should be brought up automatically and the iface keyword begins the configuration for the interface, which in this case is static.
More information: https://www.debian.org/doc/manuals/debian-reference/ch05.en.html#_the_basic_syntax_of_etc_network_interfaces
Labels:
Debian,
Linux,
Networking
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment