Regular Expressions 101

Community Patterns

Linux Routing Table

0

Regular Expression
PCRE (PHP <7.3)

/
(?P<destination>\d+\.\d+\.\d+\.\d+)\ +(?P<gateway>\d+\.\d+\.\d+\.\d+)\ +(?P<mask>\d+\.\d+\.\d+\.\d+)\ +\w+\ +\d+\ +\d+\ +\d+\ +(?P<interface>\w+)
/
g

Description

Allows you to retrieve information from the linux command route -n directly from your PHP code (or any other language).

Example:

0.0.0.0         192.168.100.254 0.0.0.0         UG    100    0        0 enp2s0
10.8.0.1        10.8.0.109      255.255.255.255 UGH   0      0        0 tun0
10.8.0.109      0.0.0.0         255.255.255.255 UH    0      0        0 tun0
192.168.10.0    10.8.0.109      255.255.255.0   UG    0      0        0 tun0
192.168.100.0   0.0.0.0         255.255.255.0   U     100    0        0 enp2s0
Submitted by g4uti3r - 7 years ago