2.6 KiB
To configure VLANs with static IP addresses on Debian using the native /etc/network/interfaces file, follow this setup. This replicates your current configuration using VLANs on eth0 and assigns static IPs to eth0.20 and eth0.30.
📁 /etc/network/interfaces Configuration
# Define VLAN interfaces with static IPs
auto eth0
iface eth0 inet static
address 10.56.0.243/24
gateway 10.56.0.1
dns-nameservers 8.8.8.8 8.8.4.4
auto eth0.20
iface eth0.20 inet static
address 10.56.2.103/24
gateway 10.56.2.1
dns-nameservers 8.8.8.8 8.8.4.4
inet6 address 2001:db8::1/64
inet6 gateway 2001:db8::1
inet6 dns-nameservers 2001:4860:4860::8888 2001:4860:4860::8844
auto eth0.30
iface eth0.30 inet static
address 10.56.3.108/24
gateway 10.56.3.1
dns-nameservers 8.8.8.8 8.8.4.4
inet6 address 2001:db8::2/64
inet6 gateway 2001:db8::2
inet6 dns-nameservers 2001:4860:4860::8888 2001:4860:4860::8844
🧰 Steps to Apply the Configuration
-
Install
vconfig(required for VLANs):sudo apt update sudo apt install vconfig -
Create VLAN interfaces (if not already created):
sudo vconfig add eth0 20 sudo vconfig add eth0 30 -
Update
/etc/network/interfaceswith the above configuration. -
Restart networking:
sudo systemctl restart networking -
Verify interfaces:
ip aYou should see
eth0.20andeth0.30with static IPs assigned.
📌 Key Notes
-
VLAN Interface Creation:
- The
vconfigtool creates the VLAN interfaces (eth0.20,eth0.30). - Ensure
vconfigis installed to manage VLANs.
- The
-
Static IPs:
- Use
addressfor IPv4 andinet6 addressfor IPv6. - Set
gatewayanddns-nameserversfor routing and DNS.
- Use
-
IPv6 Support:
- IPv6 addresses are configured using
inet6 addressandinet6 gateway. - Ensure your network supports IPv6 or adjust accordingly.
- IPv6 addresses are configured using
-
Parent Interface (
eth0):eth0is configured with a static IP (10.56.0.243/24) and a default gateway (10.56.0.1).
🧪 Validation
After applying the configuration:
- Check IP addresses:
ip a - Test connectivity:
ping -c 4 8.8.8.8 ping -c 4 2001:4860:4860::8888
📝 Summary
This /etc/network/interfaces configuration sets up VLANs (eth0.20, eth0.30) with static IPv4 and IPv6 addresses, matching your original setup. It avoids manual ip link commands and ensures consistent networking behavior.