I have been trying to get static ip working on a Debian 10 install. The server is to operate in a VLAN separate from any other network. The VLAN id according to the router interface is 3. The router model is Pakedge RE-2.
The router configuration:
IP: 192.168.2.1 Netmask: 255.255.255.0 DHCP range: 192.168.2.2 - 192.168.2.10
The following is what the VLAN is configured for:
VLAN IP: 192.168.0.1 Netmask: 255.255.255.0 DHCP range: 192.168.0.10 - 192.168.0.254
The server static ip is
192.168.0.2. The following is /etc/network/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 # The primary network interface auto eth0 allow-hotplug eth0 #iface eth0 inet static # address 192.168.0.2 # netmask 255.255.255.0 # gateway 192.168.0.1
The following is interfaces.d/eth0:
# 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 # The primary network interface #auto eth0 #allow-hotplug eth0 iface eth0 inet static address 192.168.0.2 netmask 255.255.255.0 gateway 192.168.0.1
I am able to ping domains names and IPs successfully with
dhclient eth0, but it is using an IP that's in the dhcp range of the router.
ip route before
default via 192.168.0.1 dev eth0 onlink 192.168.0.0/24 dev eth0 proto kernel scope link src 192.168.0.2
ip route after
default via 192.168.0.1 dev eth0 onlink 192.168.0.0/24 dev eth0 proto kernel scope link src 192.168.0.2 192.168.2.0/24 dev eth0 proto kernel scope link src 192.168.2.3
'ip a' output before
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 00:0b:db:be:9f:a5 brd ff:ff:ff:ff:ff:ff inet 192.168.0.2/24 brd 192.168.0.255 scope global eth0 valid_lft forever preferred_lft forever inet6 fe80::20b:dbff:febe:9fa5/64 scope link valid_lft forever preferred_lft forever
I'm not sure what to do. It seems like the gateway might be an issue since dhcp works, but changing it to the router ip (outside the vlan) doesn't seem to work and it doesn't work no matter how many times I reboot or restart the
networking daemon. I would also like to add that it seems like restarting the
networking daemon doesn't detect changes in in
/etc/network/interfaces.d/eth0 when it restarts so it seems like every change I make to test I need to restart which is exceedingly annoying.
EDIT: I'd also like to add that the Ethernet connection works (domains and IPs ping back successfully and websites work) on other computers that I plugged into to test (yes, even after disabling wifi). It seems to be this particular server I'm having issues with. It has Windows XP Professional installed on another partition, but it seems not to be able to communicate automatically there either. I would say this is a hardware problem, but dhcp works fine. Probably, the other computers I was testing were using dhcp and just connecting back to the router outside the VLAN since static wasn't set. I'll retest with no dhcp and dhcp to see given ip.
EDIT 2: I disabled the dhcp server for the vlan and the router and I am still not able to connect to the internet on the server. I'd also like to mention that I couldn't ping 192.168.0.1 (the vlan ip i.e. the gateway) before I disabled the dhcp servers and I still can't ping 192.168.0.1.
EDIT 3: Thanks to A.B, I was able to manually able to use the vlan interface. The commands are as follows:
ip address delete 192.168.0.2/24 dev eth0; ip link add link eth0 name eth0.3 type vlan id 3; ip link set dev eth0.3 up; ip address add 192.168.0.2/24 dev eth0.3; ip route add default via 192.168.0.1 dev eth0.3
//Deletes the address assigned to eth0 ip address delete 192.168.0.2/24 dev eth0; //Creates a link to eth0 with the vlan interface eth0.3 which is configured for vlan id 3 ip link add link eth0 name eth0.3 type vlan id 3; //Sets eth0.3 up ip link set dev eth0.3 up; //Adds and associates 192.168.0.2/24 with eth0.3 ip address add 192.168.0.2/24 dev eth0.3; //Configures the default route to go to the gateway 192.168.0.1 with the eth0.3 interface ip route add default via 192.168.0.1 dev eth0.3;
However, this does not resolve the issue with the ifupdown configuration files. A.B says the address on eth0 may be the cause of the ifupdown issues. In the comments, there is information regarding configuring eth0.3 as an interface in the interfaces configs which may be helpful to someone. I ended up installing the vlan package, modprobing 8021q, and creating a file named
/etc/network/interfaces.d/ with the following:
auto eth0.3 iface eth0.3 inet static address 192.168.0.2 netmask 255.255.255.0 gateway 192.168.0.1 vlan-raw-device eth0
But, as already stated, for me this ended up causing the networking daemon to fail (after a reboot) because ifup can't bring up eth0.3. If someone has information which can help resolve this, that would be great.
EDIT 4: When I removed
auto eth0.3 from
/etc/network/interfaces.d, the networking daemon no longer failed on restart and showed that it was active and after a reboot
systemctl --failed showed that no daemons failed to start; however, pinging still yields
Destination Host Unreachable (even after restart).