User Tools

Site Tools


filter_out_unwanted_interfaces_using_grep

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
filter_out_unwanted_interfaces_using_grep [2023/11/09 22:55] – created walkeradminfilter_out_unwanted_interfaces_using_grep [2023/11/09 23:07] (current) walkeradmin
Line 1: Line 1:
-Filter Out Unwanted Interfaces Using Grep+====== Filter Out Unwanted Interfaces Using Grep ====== 
 +<color #db5f0b>Nov 2023</color> 
 +\\  
 +\\  
 + 
 +---- 
 +When using Linux with Docker/Containers there can be a lot of virtual interfaces, while this is not a problem itself, listing just the physical interfaces can be. 
 +\\  
 +\\  
 +For example, if we do an '<color #ed1c24>ip -br -c a</color>' we can get quite a list: 
 +\\  
 +<file> 
 +lo               UNKNOWN        127.0.0.1/
 +eno1             UP             10.32.13.233/24 
 +eno2             UP             11.0.233.2/16 
 +eno3             UP             12.0.233.3/16 
 +eno4             DOWN 
 +internalk3s0     UNKNOWN        192.168.255.1/24 
 +kube-ipvs0       DOWN           10.43.121.13/32 10.43.139.106/32 10.43.41.193/32 10.43.199.244/32 10.43.0.10/32 10.43.88.3/32 10.43.25.131/32 10.43.120.24/32 10.43.39.71/32 10.43.212.213/32 192.168.255.1/32 10.43.41.212/32 10.43.206.154/32 10.43.148.235/32 10.43.26.88/32 10.43.217.244/32 10.43.79.27/32 10.43.115.178/32 10.43.114.120/32 10.43.66.108/32 10.43.44.118/32 10.43.136.197/32 10.43.127.60/32 10.43.138.232/32 10.43.54.183/32 10.43.110.33/32 10.43.0.1/32 10.43.60.91/32 10.43.19.143/32 10.43.123.229/32 10.43.21.162/32 10.43.92.123/32 10.43.220.178/32 10.43.87.169/32 10.43.159.224/32 10.43.18.24/32 10.43.47.137/32 10.43.24.141/32 10.43.236.14/32 10.43.17.91/32 10.43.182.233/32 10.43.195.135/32 10.43.192.38/32 10.43.157.8/32 10.43.137.179/32 10.43.196.255/32 10.43.158.51/32 10.43.23.5/32 
 +flannel.1        UNKNOWN        10.42.0.0/32 
 +cni0             UP             10.42.0.1/24 
 +veth3d27dfa7@if2 UP 
 +vethb0a17eb4@if2 UP 
 +veth619f3a08@if2 UP 
 +veth0977d0fb@if2 UP 
 +vethe60bc71c@if2 UP 
 +veth8a69f3b6@if2 UP 
 +veth1437d366@if2 UP 
 +veth3a247e74@if2 UP 
 +vethc8654bec@if2 UP 
 +veth62cbba67@if2 UP 
 +vethfd3f5763@if2 UP 
 +vethdd5adce6@if2 UP 
 +veth567a8f8d@if2 UP 
 +veth0b064639@if2 UP 
 +vethdeed99b2@if2 UP 
 +veth04829d3b@if2 UP 
 +veth6660a31c@if2 UP 
 +veth2c06a596@if2 UP 
 +veth99db8892@if2 UP 
 +veth47ce8ea5@if2 UP 
 +veth976d6e7f@if2 UP 
 +vethe4ae5d10@if2 UP 
 +veth6c7cd23e@if2 UP 
 +veth71d280a4@if2 UP 
 +vethd227b1f6@if2 UP 
 +veth55a1c60b@if2 UP 
 +vethbc6f5ccc@if2 UP 
 +vethc25d04a7@if2 UP 
 +veth93d06e97@if2 UP 
 +veth2641a619@if2 UP 
 +veth284b1fa0@if2 UP 
 +vethe1fdb3e7@if2 UP 
 +veth905c6a4e@if2 UP 
 +vethd1853059@if2 UP 
 +veth0a79a49b@if2 UP 
 +veth48b4b040@if2 UP 
 +veth1ac96caa@if2 UP 
 +veth3f9ad283@if2 UP 
 +vethef6fb521@if2 UP 
 +vethaacee777@if2 UP 
 +vetha6ac44b4@if2 UP 
 +veth05123eed@if2 UP 
 +veth91566343@if2 UP 
 +veth0f16c600@if2 UP 
 +</file> 
 +This may or may not be an issue, but sometimes this long list means the interfaces you are interested in will scroll off the top of the page. You could use something like head: 
 +\\  
 +\\  
 +<color #ed1c24>ip -br -c a | head</color> 
 +\\  
 +\\  
 +This will give an output similar to: 
 +<file> 
 +lo               UNKNOWN        127.0.0.1/
 +eno1             UP             10.32.13.233/24 
 +eno2             UP             11.0.233.2/16 
 +eno3             UP             12.0.233.3/16 
 +eno4             DOWN 
 +internalk3s0     UNKNOWN        192.168.255.1/24 
 +kube-ipvs0       DOWN           10.43.121.13/32 10.43.139.106/32 10.43.41.193/32 10.43.199.244/32 10.43.0.10/32 10.43.88.3/32 10.43.25.131/32 10.43.120.24/32 10.43.39.71/32 10.43.212.213/32 192.168.255.1/32 10.43.41.212/32 10.43.206.154/32 10.43.148.235/32 10.43.26.88/32 10.43.217.244/32 10.43.79.27/32 10.43.115.178/32 10.43.114.120/32 10.43.66.108/32 10.43.44.118/32 10.43.136.197/32 10.43.127.60/32 10.43.138.232/32 10.43.54.183/32 10.43.110.33/32 10.43.0.1/32 10.43.60.91/32 10.43.19.143/32 10.43.123.229/32 10.43.21.162/32 10.43.92.123/32 10.43.220.178/32 10.43.87.169/32 10.43.159.224/32 10.43.18.24/32 10.43.47.137/32 10.43.24.141/32 10.43.236.14/32 10.43.17.91/32 10.43.182.233/32 10.43.195.135/32 10.43.192.38/32 10.43.157.8/32 10.43.137.179/32 10.43.196.255/32 10.43.158.51/32 10.43.23.5/32 
 +flannel.1        UNKNOWN        10.42.0.0/32 
 +cni0             UP             10.42.0.1/24 
 +veth3d27dfa7@if2 UP 
 +</file> 
 +\\  
 +However, we can use GREP to filter out the unwanted entries, in this example the biggest number of unwanted entries are the 'vethxxxxxxxx' entries, we can filter these out using the following (because they all contain 'veth'
 +\\  
 +\\  
 +<color #ed1c24>ip -br -c a |grep -v veth</color> 
 +\\  
 +\\  
 +<file> 
 +lo               UNKNOWN        127.0.0.1/
 +eno1             UP             10.32.13.233/24 
 +eno2             UP             11.0.233.2/16 
 +eno3             UP             12.0.233.3/16 
 +eno4             DOWN 
 +internalk3s0     UNKNOWN        192.168.255.1/24 
 +kube-ipvs0       DOWN           10.43.121.13/32 10.43.139.106/32 10.43.41.193/32 10.43.199.244/32 10.43.0.10/32 10.43.88.3/32 10.43.25.131/32 10.43.120.24/32 10.43.39.71/32 10.43.212.213/32 192.168.255.1/32 10.43.41.212/32 10.43.206.154/32 10.43.148.235/32 10.43.26.88/32 10.43.217.244/32 10.43.79.27/32 10.43.115.178/32 10.43.114.120/32 10.43.66.108/32 10.43.44.118/32 10.43.136.197/32 10.43.127.60/32 10.43.138.232/32 10.43.54.183/32 10.43.110.33/32 10.43.0.1/32 10.43.60.91/32 10.43.19.143/32 10.43.123.229/32 10.43.21.162/32 10.43.92.123/32 10.43.220.178/32 10.43.87.169/32 10.43.159.224/32 10.43.18.24/32 10.43.47.137/32 10.43.24.141/32 10.43.236.14/32 10.43.17.91/32 10.43.182.233/32 10.43.195.135/32 10.43.192.38/32 10.43.157.8/32 10.43.137.179/32 10.43.196.255/32 10.43.158.51/32 10.43.23.5/32 
 +flannel.1        UNKNOWN        10.42.0.0/32 
 +cni0             UP             10.42.0.1/24 
 +</file> 
 +\\  
 +If we wish to go further, we can filter out the kube/flannel/cnio etc by adding these to our command. 
 +\\  
 +\\  
 +<color #ed1c24>ip -br -c a |grep -v kube |grep -v veth |grep -v internal |grep -v flannel |grep -v cni0</color> 
 +\\  
 +\\  
 +This will give us a list of just the physical interfaces: 
 +\\  
 +<file> 
 +lo               UNKNOWN        127.0.0.1/
 +eno1             UP             10.32.13.233/24 
 +eno2             UP             11.0.233.2/16 
 +eno3             UP             12.0.233.3/16 
 +eno4             DOWN 
 +</file> 
 +\\  
 +\\ 
filter_out_unwanted_interfaces_using_grep.1699570536.txt.gz · Last modified: 2023/11/09 22:55 by walkeradmin