I have a single network interface on this server named enp2s0 This interface had a static address 192.168.2.xxx with gateway 192.168.2.1 Now I changed the static address in yaml file to 192.168.1.xxx and the gateway too in 192.168.1.1 but every time I restart the server the default gateway comes back to 192.168.2.1 I tried to launch route commmand to remove default gateway and set the new one but if I restart the server it comes back to 192.168.2.1
This is the yaml config file
Code:
# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
version: 2
renderer: networkd
ethernets:
enp2s0:
addresses: [192.168.1.10/24]
gateway4: 192.168.1.1
nameservers:
addresses: [1.1.1.1,1.0.0.1]
Output of networkctl status enp2s0 after reboot
Code:
2: enp2s0
Link File: /lib/systemd/network/99-default.link
Network File: /run/systemd/network/10-netplan-enp2s0.network
Type: ether
State: routable (configured)
Path: pci-0000:02:00.0
Driver: r8169
Vendor: Realtek Semiconductor Co., Ltd.
Model: RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (M4A
HW Address: 48:5b:39:02:41:c9 (ASUSTek COMPUTER INC.)
Address: 192.168.1.10
192.168.2.100
fe80::4a5b:39ff:fe02:41c9
Gateway: 192.168.2.1
DNS: 1.1.1.1 1.0.0.1
Output of route command after reboot
Code:
Tabella di routing IP del kernel
Destination Gateway Genmask Flags Metric Ref Use Iface
default 192.168.2.1 0.0.0.0 UG 202 0 0 enp2s0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 enp2s0
192.168.2.0 0.0.0.0 255.255.255.0 U 202 0 0 enp2s0
Result of networkctl status enp2s0 after restored default gateway to 192.168.1.1
Code:
2: enp2s0
Link File: /lib/systemd/network/99-default.link
Network File: /run/systemd/network/10-netplan-enp2s0.network
Type: ether
State: routable (configured)
Path: pci-0000:02:00.0
Driver: r8169
Vendor: Realtek Semiconductor Co., Ltd.
Model: RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (M4A
HW Address: 48:5b:39:02:41:c9 (ASUSTek COMPUTER INC.)
Address: 192.168.1.10
fe80::4a5b:39ff:fe02:41c9
Gateway: 192.168.1.1
DNS: 1.1.1.1 1.0.0.1
Output of route command after restored default gateway to 192.168.1.1
Code:
Tabella di routing IP del kernel
Destination Gateway Genmask Flags Metric Ref Use Iface
default 192.168.1.1 0.0.0.0 UG 0 0 0 enp2s0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 enp2s0
How to solve ?
Bookmarks