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...")
 
(Remove use of "you", cleaned up naming information to be more generic and less "this might happen in the future" since it appears to be device based, put names in quotes.)
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.  For example, to enable DHCP for "eth0" by default on startup:


<source lang=bash>
<source lang=bash>
Line 21: Line 21:
</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.

Revision as of 16:32, 9 July 2019

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:

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:

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.