.pve-ignore
as prefix. i.e, if you not need the PVE edit the /etc/hosts at the startup, you can do the following command:touch /etc/.pve-ignore.hosts
systemctl restart networking
after you add a `up route add -net` to the Container network configuration.# Set manual routes after reboot
@reboot root /usr/sbin/ip route add 192.168.4.0/24 via 192.168.43.1 dev eth0 > /dev/null 2>&1
@reboot root /usr/sbin/ip route add 192.168.41.0/24 via 192.168.43.1 dev eth0 > /dev/null 2>&1
@reboot root /usr/sbin/ip route add 192.168.42.0/24 via 192.168.43.1 dev eth0 > /dev/null 2>&1
@reboot root /usr/sbin/ip route add 192.168.44.0/24 via 192.168.43.1 dev eth0 > /dev/null 2>&1
@reboot root /usr/sbin/ip route add 192.168.46.0/24 via 192.168.43.1 dev eth0 > /dev/null 2>&1
@reboot root /usr/sbin/ip route add 192.168.47.0/24 via 192.168.43.1 dev eth0 > /dev/null 2>&1
@reboot root /usr/sbin/ip route add 192.168.50.0/24 via 192.168.43.1 dev eth0 > /dev/null 2>&1
# Set static routes after reboot
@reboot root /usr/sbin/ip route add 192.168.4.0/24 via 192.168.43.1 dev eth0 > /dev/null 2>&1
@reboot root /usr/sbin/ip route add 192.168.41.0/24 via 192.168.43.1 dev eth0 > /dev/null 2>&1
@reboot root /usr/sbin/ip route add 192.168.42.0/24 via 192.168.43.1 dev eth0 > /dev/null 2>&1
@reboot root /usr/sbin/ip route add 192.168.44.0/24 via 192.168.43.1 dev eth0 > /dev/null 2>&1
@reboot root /usr/sbin/ip route add 192.168.46.0/24 via 192.168.43.1 dev eth0 > /dev/null 2>&1
@reboot root /usr/sbin/ip route add 192.168.47.0/24 via 192.168.43.1 dev eth0 > /dev/null 2>&1
@reboot root /usr/sbin/ip route add 192.168.50.0/24 via 192.168.43.1 dev eth0 > /dev/null 2>&1
touch /etc/network/if-up.d/custom-routes.sh
chown root:root /etc/network/if-up.d/custom-routes.sh
chmod 750 /etc/network/if-up.d/custom-routes.sh
nano /etc/network/if-up.d/custom-routes.sh
#!/bin/bash
[ "$IFACE" = "eth0" ] || exit 0 # we only want interface "eth0"
[ "$ADDRFAM" = "inet" ] || exit 0 # we only want IPv4 (not "inet6" for IPv6)
# add manual routes to old subnets
/usr/sbin/ip route add 192.168.4.0/24 via 192.168.43.1 dev eth0 || true
/usr/sbin/ip route add 192.168.41.0/24 via 192.168.43.1 dev eth0 || true
/usr/sbin/ip route add 192.168.42.0/24 via 192.168.43.1 dev eth0 || true
/usr/sbin/ip route add 192.168.44.0/24 via 192.168.43.1 dev eth0 || true
/usr/sbin/ip route add 192.168.46.0/24 via 192.168.43.1 dev eth0 || true
/usr/sbin/ip route add 192.168.47.0/24 via 192.168.43.1 dev eth0 || true
/usr/sbin/ip route add 192.168.50.0/24 via 192.168.43.1 dev eth0 || true
touch /etc/network/if-down.d/custom-routes.sh
chown root:root /etc/network/if-down.d/custom-routes.sh
chmod 750 /etc/network/if-down.d/custom-routes.sh
nano /etc/network/if-down.d/custom-routes.sh
#!/bin/bash
[ "$IFACE" = "eth0" ] || exit 0 # we only want interface "eth0"
[ "$ADDRFAM" = "inet" ] || exit 0 # we only want IPv4 (not "inet6" for IPv6)
# remove manual routes to old subnets
/usr/sbin/ip route delete 192.168.4.0/24 via 192.168.43.1 dev eth0 || true
/usr/sbin/ip route delete 192.168.41.0/24 via 192.168.43.1 dev eth0 || true
/usr/sbin/ip route delete 192.168.42.0/24 via 192.168.43.1 dev eth0 || true
/usr/sbin/ip route delete 192.168.44.0/24 via 192.168.43.1 dev eth0 || true
/usr/sbin/ip route delete 192.168.46.0/24 via 192.168.43.1 dev eth0 || true
/usr/sbin/ip route delete 192.168.47.0/24 via 192.168.43.1 dev eth0 || true
/usr/sbin/ip route delete 192.168.50.0/24 via 192.168.43.1 dev eth0 || true
root@ZabbixLXC:~# ip addr
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
2: eth0@if355: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 0e:98:b0:72:0d:37 brd ff:ff:ff:ff:ff:ff link-netnsid 0
inet 192.168.43.70/24 brd 192.168.43.255 scope global eth0
valid_lft forever preferred_lft forever
3: eth1@if359: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether bc:24:11:c0:91:ff brd ff:ff:ff:ff:ff:ff link-netnsid 0
inet 10.60.175.10/16 brd 10.60.255.255 scope global eth1
valid_lft forever preferred_lft forever
4: eth2@if363: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether bc:24:11:a9:1f:c9 brd ff:ff:ff:ff:ff:ff link-netnsid 0
inet 10.61.175.10/16 brd 10.61.255.255 scope global eth2
valid_lft forever preferred_lft forever
root@ZabbixLXC:~# ip route show
default via 10.60.0.1 dev eth1 onlink
10.60.0.0/16 dev eth1 proto kernel scope link src 10.60.175.10
10.61.0.0/16 dev eth2 proto kernel scope link src 10.61.175.10
192.168.43.0/24 dev eth0 proto kernel scope link src 192.168.43.70
...
Feb 25 23:20:46 ZabbixLXC systemd[1]: networking.service: Main process exited, code=exited, status=1/FAILURE
Feb 25 23:20:46 ZabbixLXC systemd[1]: networking.service: Failed with result 'exit-code'.
Feb 25 23:20:46 ZabbixLXC systemd[1]: Failed to start networking.service - Raise network interfaces.
Feb 25 23:20:46 ZabbixLXC systemd[1]: Reached target network.target - Network.
...
Feb 25 23:25:47 ZabbixLXC systemd[1]: ifupdown-wait-online.service: Main process exited, code=exited, status=1/FAILURE
Feb 25 23:25:47 ZabbixLXC systemd[1]: ifupdown-wait-online.service: Failed with result 'exit-code'.
Feb 25 23:25:47 ZabbixLXC systemd[1]: Failed to start ifupdown-wait-online.service - Wait for network to be configured by ifupdown.
Feb 25 23:25:47 ZabbixLXC systemd[1]: Reached target network-online.target - Network is Online.
...
/usr/sbin/ip route add 192.168.4.0/24 via 192.168.43.1 dev eth0 || true
/usr/sbin/ip route add 192.168.41.0/24 via 192.168.43.1 dev eth0 || true
/usr/sbin/ip route add 192.168.42.0/24 via 192.168.43.1 dev eth0 || true
/usr/sbin/ip route add 192.168.44.0/24 via 192.168.43.1 dev eth0 || true
/usr/sbin/ip route add 192.168.46.0/24 via 192.168.43.1 dev eth0 || true
/usr/sbin/ip route add 192.168.47.0/24 via 192.168.43.1 dev eth0 || true
/usr/sbin/ip route add 192.168.50.0/24 via 192.168.43.1 dev eth0 || true
root@ZabbixLXC:~# ip route show
default via 10.60.0.1 dev eth1 onlink
10.60.0.0/16 dev eth1 proto kernel scope link src 10.60.175.10
10.61.0.0/16 dev eth2 proto kernel scope link src 10.61.175.10
192.168.4.0/24 via 192.168.43.1 dev eth0
192.168.41.0/24 via 192.168.43.1 dev eth0
192.168.42.0/24 via 192.168.43.1 dev eth0
192.168.43.0/24 dev eth0 proto kernel scope link src 192.168.43.70
192.168.44.0/24 via 192.168.43.1 dev eth0
192.168.46.0/24 via 192.168.43.1 dev eth0
192.168.47.0/24 via 192.168.43.1 dev eth0
192.168.50.0/24 via 192.168.43.1 dev eth0
echo "Script triggered" >> /tmp/ifup.log
echo $IFACE >> /tmp/ifup.log
Try without ".sh" at the end of your scripts.Nope. Adding a ...
.. to the top of the script won't create any logfile which could point out what interface name is used. So the script will probably not run in the first place.Code:echo "Script triggered" >> /tmp/ifup.log echo $IFACE >> /tmp/ifup.log
could try that but same OS but VM instead of LXC is working perfectly fine ending with ".sh".Try without ".sh" at the end of your scripts.
ref : https://manpages.debian.org/bookworm/ifupdown/interfaces.5.en.html#INCLUDING_OTHER_FILES:~:text=names of the files are checked to match the following regular expression: ^[a-zA-Z0-9_-]+$. In other words, the names must consist entirely of ASCII upper- and lower-case letters, ASCII digits, ASCII underscores, and ASCII minus-hyphens. In the directory path, shell wildcards may be used as well.