Stretch Network: Difference between revisions

From embeddedTS Manuals
(Created page with "Debian can automatically set up the networking based on the contents of /etc/network/interfaces. For example, to enable DHCP for eth0 by default on startup: <source lang=bas...")
 
m (It wasn't clear to me if this was only for the static ip option or if it included the dhcp option.)
 
(3 intermediate revisions by one other user not shown)
Line 1: Line 1:
Debian can automatically set up the networking based on the contents of /etc/network/interfaces.  For example, to enable DHCP for eth0 by default on startup:
Debian can automatically set up the networking based on the contents of "/etc/network/interfaces.d/" files.  For example, to enable DHCP for "eth0" by default on startup:


<source lang=bash>
<source lang=bash>
Line 16: Line 16:
</source>
</source>


To make this take effect immediately:
To make this take effect immediately for either option:
<source lang=bash>
<source lang=bash>
service networking restart
service networking restart
</source>
</source>


To configure other interfaces, replace eth0 with your other network device.  New distributions will use [https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/ predictable interface names].  For example, on older Linux a second ethernet port might be eth1, but may now be enp1s0 for pcie, or "enx00D069C0FFEE" including the MAC address for USB ethernets.  Run "ifconfig -a" or "ip a" to get a complete list of interfaces, including the ones that are not configured.
To configure other interfaces, replace "eth0" with the other network device nameSome interfaces may use [https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/ predictable interface names].  For example, the traditional name for an ethernet port might be "eth1", but some devices may use "enp1s0" for PCIe, or "enx00D069C0FFEE" (the MAC address appended) for USB ethernet interfaces.  Run 'ifconfig -a' or 'ip a' to get a complete list of interfaces, including the ones that are not configured.

Latest revision as of 11:36, 31 March 2020

Debian can automatically set up the networking based on the contents of "/etc/network/interfaces.d/" files. For example, to enable DHCP for "eth0" by default on startup:

echo "auto eth0
iface eth0 inet dhcp" > /etc/network/interfaces.d/eth0

To set up a static IP:

echo "auto eth0
iface eth0 inet static
    address 192.168.0.50
    netmask 255.255.255.0
    gateway 192.168.0.1" > /etc/network/interfaces.d/eth0
echo "nameserver 1.1.1.1" > /etc/resolv.conf

To make this take effect immediately for either option:

service networking restart

To configure other interfaces, replace "eth0" with the other network device name. Some interfaces may use predictable interface names. For example, the traditional name for an ethernet port might be "eth1", but some devices may use "enp1s0" for PCIe, or "enx00D069C0FFEE" (the MAC address appended) for USB ethernet interfaces. Run 'ifconfig -a' or 'ip a' to get a complete list of interfaces, including the ones that are not configured.