Stretch Network: Difference between revisions

From embeddedTS Manuals
(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.)
(Add quotes around referenced file)
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>

Revision as of 16:46, 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.