Configuring and troubleshooting IPv4 addresses

On a router

Each routed interface needs an address and mask, and must be up. The router then adds two routes for it: C (the connected subnet) and L (its own address, /32).

In NetLab

▶ R1
R1>enable
R1#show ip interface brief | exclude unassigned
Interface              IP-Address      OK? Method Status                Protocol
GigabitEthernet0/0     192.168.10.1    YES manual up                    up
GigabitEthernet0/1     192.168.20.1    YES manual up                    up
R1#show ip route | begin Gateway
Gateway of last resort is not set

      192.168.10.0/24 is variably subnetted, 2 subnets, 2 masks
C        192.168.10.0/24 is directly connected, GigabitEthernet0/0
L        192.168.10.1/32 is directly connected, GigabitEthernet0/0
      192.168.20.0/24 is variably subnetted, 2 subnets, 2 masks
C        192.168.20.0/24 is directly connected, GigabitEthernet0/1
L        192.168.20.1/32 is directly connected, GigabitEthernet0/1

The router refuses bad addresses

In NetLab

▶ R1
R1>enable
R1#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
R1(config)#interface g0/2
R1(config-if)#ip address 192.168.30.0 255.255.255.0
% Bad mask /24 for address 192.168.30.0
R1(config-if)#ip address 192.168.30.1 255.0.255.0
% Bad mask 0xFF00FF00 for address 192.168.30.1
R1(config-if)#ip address 192.168.10.200 255.255.255.0
% 192.168.10.0 overlaps with GigabitEthernet0/0
  • .0 is the network address of a /24, so it can't be given to an interface.
  • 255.0.255.0 isn't a real mask: the ones aren't in one run.
  • 192.168.10.200/24 would put two interfaces in the same subnet, which overlaps Gi0/0.

On PCs

Windows: ipconfig to look, and netsh interface ip set address (or the IP settings button in NetLab) to change. Linux: ip addr and ip route; changes need sudo.

In NetLab

▶ PC1
NetLab Windows-style command prompt. Type help to see the commands.
C:\Users\student>ipconfig

Windows IP Configuration


Ethernet adapter Ethernet:

   Connection-specific DNS Suffix  . : 
   Link-local IPv6 Address . . . . . : fe80::11db:99de:fbce:36d1%12
   IPv4 Address. . . . . . . . . . . : 192.168.10.10
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 192.168.10.1
▶ PC2
student@PC2:~$ ip addr show
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 noprefixroute 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:1a:f2:3a:a4:ee brd ff:ff:ff:ff:ff:ff
    inet 192.168.20.10/24 brd 192.168.20.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::21a:f2ff:fe3a:a4ee/64 scope link 
       valid_lft forever preferred_lft forever
student@PC2:~$ ip route
default via 192.168.20.1 dev eth0 
192.168.20.0/24 dev eth0 proto kernel scope link src 192.168.20.10 
student@PC2:~$ ping -c 3 192.168.10.10
PING 192.168.10.10 (192.168.10.10) 56(84) bytes of data.
64 bytes from 192.168.10.10: icmp_seq=2 ttl=127 time=0.640 ms
64 bytes from 192.168.10.10: icmp_seq=3 ttl=127 time=0.580 ms

--- 192.168.10.10 ping statistics ---
3 packets transmitted, 2 received, 33% packet loss, time 2002ms
rtt min/avg/max/mdev = 0.580/0.610/0.640/0.030 ms

The first ping across the router is lost: the router didn't yet know PC1's MAC address, so it sent an ARP request and dropped that one packet. Every ping after that gets through. You will see this often, and it is normal.

Two classic mistakes

Below, PC1's mask is too short (/16 instead of /24), so it thinks PC2's address is in its own network and never asks the router. PC2's gateway is an address that doesn't exist on its subnet, so its replies never leave the LAN:

In NetLab

▶ PC1
NetLab Windows-style command prompt. Type help to see the commands.
C:\Users\student>ipconfig

Windows IP Configuration


Ethernet adapter Ethernet:

   Connection-specific DNS Suffix  . : 
   Link-local IPv6 Address . . . . . : fe80::11db:99de:fbce:36d1%12
   IPv4 Address. . . . . . . . . . . : 192.168.10.10
   Subnet Mask . . . . . . . . . . . : 255.255.0.0
   Default Gateway . . . . . . . . . : 192.168.10.1
C:\Users\student>ping 192.168.20.10

Pinging 192.168.20.10 with 32 bytes of data:
Reply from 192.168.10.10: Destination host unreachable.
Reply from 192.168.10.10: Destination host unreachable.
Reply from 192.168.10.10: Destination host unreachable.
Reply from 192.168.10.10: Destination host unreachable.

Ping statistics for 192.168.20.10:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
▶ PC2
NetLab Windows-style command prompt. Type help to see the commands.
C:\Users\student>ipconfig

Windows IP Configuration


Ethernet adapter Ethernet:

   Connection-specific DNS Suffix  . : 
   Link-local IPv6 Address . . . . . : fe80::6168:63e2:6bbb:b823%12
   IPv4 Address. . . . . . . . . . . : 192.168.20.10
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 192.168.2.1
C:\Users\student>ping 192.168.10.1

Pinging 192.168.10.1 with 32 bytes of data:
Request timed out.
Request timed out.
Request timed out.
Request timed out.

Ping statistics for 192.168.10.1:
    Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),
SymptomLikely cause
Can ping the gateway but nothing beyondWrong gateway on the far device, or a routing problem
"Destination host unreachable" from your own IPYour PC thinks the target is local: wrong mask, or the target is off
"PING: transmit failed. General failure."No address, no gateway, or the cable is unplugged
"Request timed out."Packets left but nothing came back: the far side, its gateway, or a filter

Remember: The default gateway must be in the PC's own subnet, and must be the router's address on that LAN.

HOME LABS COMMUNITY DASHBOARD