PDA

View Full Version : [SOLVED] 22.04 lts with static ip can't ping gateway



capriole
December 28th, 2023, 05:16 PM
I'm attempting to set up a bare metal home server with a static ip and I think I've got everything set up right but I can't ping the gateway. If I change it back to dhcp everything works and I can access everything on the network and internet. So I'm trying to find out if it is something wrong with my netplan config or if not what else could I check to troubleshoot this.

Both netplan --debug generate and netplan --debug apply come back clean with no errors.

ufw and iptables


$ sudo ufw status
Status: inactive

$ sudo iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination

Chain FORWARD (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination


netplan yaml


network:
version: 2
renderer: networkd
ethernets:
enp0s31f6:
addresses: [172.31.22.35/24]
routes:
- to: default
via: 172.31.22.1
nameservers:
addresses: [172.31.6.13, 172.31.6.12]
optional: false


netplan status


Online state: online
DNS Addresses: 127.0.0.53 (stub)
DNS Search: .

● 1: lo ethernet UNKNOWN/UP (unmanaged)
MAC Address: 00:00:00:00:00:00
Addresses: 127.0.0.1/8
::1/128
Routes: ::1 metric 256

● 2: enp0s31f6 ethernet UP (networkd: enp0s31f6)
MAC Address: d8:9e:f3:3a:ed:1c (Intel Corporation)
Addresses: 172.31.22.35/24
fe80::da9e:f3ff:fe3a:ed1c/64 (link)
DNS Addresses: 172.31.6.13
172.31.6.12
Routes: default via 172.31.22.1 (static)
172.31.22.0/24 from 172.31.22.35 (link)
fe80::/64 metric 256


ip route


default via 172.31.22.1 dev enp0s31f6 proto static
172.31.22.0/24 dev enp0s31f6 proto kernel scope link src 172.31.22.35


Attempting to ping the gateway


PING 172.31.22.1 (172.31.22.1) 56(84) bytes of data.
From 172.31.22.35 icmp_seq=1 Destination Host Unreachable
From 172.31.22.35 icmp_seq=2 Destination Host Unreachable
From 172.31.22.35 icmp_seq=3 Destination Host Unreachable

--- 172.31.22.1 ping statistics ---
3 packets transmitted, 0 received, +3 errors, 100% packet loss, time 2030ms
pipe 2


Traceroute


traceroute to 172.31.22.1 (172.31.22.1), 30 hops max, 60 byte packets
1 172.31.22.35 (172.31.22.35) 1894.936 ms !H 1894.930 ms !H 1894.928 ms !H


Any thoughts, plans, or ideas? What am I missing?

TheFu
December 28th, 2023, 06:10 PM
Show the same information when using DHCP. Then show it using static IPs.
Ensure your DHCP range for IPs is outside the range you saved to use for static IPs.

I suspect your router/default gateway doesn't have 172.31.22.1 as the IP on the LAN side.
Also, enp0s31f6 seems like a really long device name. enp3s0 is the device name here for a single NIC system. On a server with 5 NICs (1 on the MB and 4 on a PCIe card),
enp3s0
enp7s0f0 enp7s0f1
enp8s0f0 enp8s0f1
are the NICs.

Doug S
December 28th, 2023, 06:16 PM
show us the same information, but when you are using DHCP.
Your name servers are on a different local sub-net, which I think is a little odd, but don't know if it is significant or not.

EDIT: Oh, I had not seen that TheFu replied until after I posted.

MAFoElffen
December 28th, 2023, 08:14 PM
enp0s31f6

I do not see that as that odd... Though slot #31 seems a bit high.

RE: Ubuntu Man Page systemd.net-naming-scheme(8) (https://manpages.ubuntu.com/manpages/jammy/man7/systemd.net-naming-scheme.7.html)


# enp0s31f6
## Two character prefixes based on the type of interface
en = Ethernet
## ID_NET_NAME_PATH=prefix[P domain]p bussslot[f function][n phys_port_name|d dev_port]uport...[c config][i interface]
p0 = bus0
s31 = slot 31
f6 = function 6

For instance, mine):


mafoelffen@msi-ubuntu:~$ ls /sys/class/net
br0 enp7s0f0v0 enp7s0f0v3 enp7s0f0v6 enp7s0f1v1 enp7s0f1v4 lo virbr2
enp6s0 enp7s0f0v1 enp7s0f0v4 enp7s0f1 enp7s0f1v2 enp7s0f1v5 virbr0 virbr3
enp7s0f0 enp7s0f0v2 enp7s0f0v5 enp7s0f1v0 enp7s0f1v3 enp7s0f1v6 virbr1 wlo1



# enp7s0f0v1
Ethernet, Bus 7, Slot 0, Function (port 1 of 2), Virtual port 1... (SR-IOV)


*** What I am curious about... Is what i was taught, start to diagnose through the 7 OSI layers in order.
- Do you have a link light?
- Can you ping the assigned address of the NIC?


ping -c 4 172.31.22.35

Then ... Can you ping the gateway?

If it does not have a link light, it doesn't have a physical route. It you cannot ping the assigned address to the NIC, then there is either something wrong with the NIC, it's driver, or the IP assignment... If beyond that to the gateway, maybe a problem at the switch, between the PC and the Gateway, or the gateway itself...

And, as TheFu said, if I am stuck, I'll comment the static assignment out in the netplan yaml, give it "dhcp4: true", and make sure it can connect somehow, then if so, see if anything jumps out at me.

capriole
December 28th, 2023, 10:13 PM
Here's what everything looks like under dhcp. If you need additional information or there isn't what you meant just let me know.

netplan status


Online state: online
DNS Addresses: 127.0.0.53 (stub)

● 1: lo ethernet UNKNOWN/UP (unmanaged)
MAC Address: 00:00:00:00:00:00
Addresses: 127.0.0.1/8
::1/128
Routes: ::1 metric 256

● 2: enp0s31f6 ethernet UP (networkd: enp0s31f6)
MAC Address: d8:9e:f3:3a:ed:1c (Intel Corporation)
Addresses: 172.16.15.16/16 (dhcp)
fe80::da9e:f3ff:fe3a:ed1c/64 (link)
DNS Addresses: 172.31.6.13
172.31.6.12
Routes: default via 172.16.2.223 from 172.16.15.16 metric 100 (dhcp)
172.16.0.0/16 from 172.16.15.16 metric 100 (link)
172.16.2.223 from 172.16.15.16 metric 100 (dhcp, link)
172.31.6.12 via 172.16.2.223 from 172.16.15.16 metric 100 (dhcp)
172.31.6.13 via 172.16.2.223 from 172.16.15.16 metric 100 (dhcp)
fe80::/64 metric 256


ip route


default via 172.16.2.223 dev enp0s31f6 proto dhcp src 172.16.15.16 metric 100
172.16.0.0/16 dev enp0s31f6 proto kernel scope link src 172.16.15.16 metric 100
172.16.2.223 dev enp0s31f6 proto dhcp scope link src 172.16.15.16 metric 100
172.31.6.12 via 172.16.2.223 dev enp0s31f6 proto dhcp src 172.16.15.16 metric 100
172.31.6.13 via 172.16.2.223 dev enp0s31f6 proto dhcp src 172.16.15.16 metric 100
172.31.22.100 via 172.16.2.223 dev enp0s31f6 proto dhcp src 172.16.15.16 metric 100


pinging dhcp gateway


$ ping -c 3 172.16.2.223
PING 172.16.2.223 (172.16.2.223) 56(84) bytes of data.
64 bytes from 172.16.2.223: icmp_seq=1 ttl=255 time=3.26 ms
64 bytes from 172.16.2.223: icmp_seq=2 ttl=255 time=4.60 ms
64 bytes from 172.16.2.223: icmp_seq=3 ttl=255 time=1.08 ms

--- 172.16.2.223 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 1.082/2.981/4.601/1.450 ms


pinging static ip's gateway


$ ping -c 3 172.31.22.1
PING 172.31.22.1 (172.31.22.1) 56(84) bytes of data.
64 bytes from 172.31.22.1: icmp_seq=1 ttl=255 time=4.83 ms
64 bytes from 172.31.22.1: icmp_seq=2 ttl=255 time=3.10 ms
64 bytes from 172.31.22.1: icmp_seq=3 ttl=255 time=5.88 ms

--- 172.31.22.1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 3.095/4.599/5.876/1.146 ms


And as for the nic I couldn't tell you. I don't know.


$ ip a
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: enp0s31f6: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether d8:9e:f3:3a:ed:1c brd ff:ff:ff:ff:ff:ff
inet 172.16.15.16/16 metric 100 brd 172.16.255.255 scope global dynamic enp0s31f6
valid_lft 592385sec preferred_lft 592385sec
inet6 fe80::da9e:f3ff:fe3a:ed1c/64 scope link
valid_lft forever preferred_lft forever

$ ls /sys/class/net
enp0s31f6 lo




*** What I am curious about... Is what i was taught, start to diagnose through the 7 OSI layers in order.
- Do you have a link light?
- Can you ping the assigned address of the NIC?


So I double checked after putting it back to static and yes, I do have a link light. I can ping 172.31.22.1 but I can't ping the gateway.

TheFu
December 28th, 2023, 10:38 PM
172.31.22.35 can't just be picked as the gateway randomly.

The DHCP subnet is 172.16.15.16/16. .... that network is 172.16.0.0/16.
You need to replicate the entire chain of routing if you want to do that.

172.16.15.16 goes through 172.16.2.223. There's no mention of a 172.31.22.x/24 subnet.

Doug S
December 28th, 2023, 11:43 PM
Your netplan yaml file needs to be something like this:


network:
version: 2
renderer: networkd
ethernets:
enp0s31f6:
addresses: [172.16.0.1/16] <<< Example only. You need to pick an address within the 172.16.0.0/16 sub-net, but outside of your DHCP reserved pool of addresses.
routes:
- to: default
via: 172.16.2.223
nameservers:
addresses: [172.31.6.13, 172.31.6.12]
optional: false

capriole
December 29th, 2023, 04:30 PM
So my apologies. First let me say that yes ya'll are 100% correct. The setup I'm working with and attaching this sever too is a home lab environment for learning. It's set up like a corporate network and I've got multiple sites and vlans and routes and eigrp. But before that it was ospf.

While not being new to linux I am new to netplan and reading about the recentish config change with gateway and route and how the internet seems to be littered with your config isn't right but not much else. I assumed (my bad) that I was doing something wrong on the machine.

TheFu's last post yesterday made me go wait a minute.. and so I went back and dug through my network setup and realized that I had an error in my network re-config from ospf to eigrp and what was where.

After fixing that everything works and the server is actually good to go. It should have made me realize it might be something else when I created a yaml file straight from netplans site using the documentation and it still didn't work. Thanks for the help in getting me to realize my mistake.