Command ip examples

 
# Forcefully close a connection to a specific destination
sudo ss -K dst 192.168.1.100

# view routes
ip r
ip route

# To reject a route (block traffic to an IP)
ip route add unreachable 74.1.1.0/24
ip route del unreachable 74.1.1.0/24

  
# add route 
sudo ip route add {NETWORK/MASK} via {GATEWAYIP}
sudo ip route add {NETWORK/MASK} dev {DEVICE}
sudo ip route add default {NETWORK/MASK} dev {DEVICE}
sudo ip route add default {NETWORK/MASK} via {GATEWAYIP}

# Here is another example where I am setting up route for my VPN gateway:
ip link set dev tun0 up mtu 1500
ip addr add dev tun0 10.8.0.2/24 broadcast 10.8.0.255
ip route add 139.59.2.125/32 via 192.168.2.254
ip route add 0.0.0.0/1 via 10.8.0.1
ip route add 128.0.0.0/1 via 10.8.0.1


Edit config file such as /etc/sysconfig/network-scripts/route-eth0 on a CentOS/RHEL/Fedora Linux for interface eth0 using a text editor such as nano command or vim command:
vim /etc/sysconfig/network-scripts/route-eth0

Append the following text:
172.10.1.0/24 via 10.0.0.100 dev eth0

Save and exit (close) the file in a vim text editor. Finally, restart your network service on a CentOS/RHEL/Fedora Linux so they take effect:
systemctl restart network.service



A note about ip command and persistence static routing on a Debian/Ubuntu

Edit your /etc/network/interfaces file for say eth0:
vi /etc/network/interfaces

Update it as follows:

auto eth0
iface eth0 inet static
address 192.168.1.2
netmask 255.255.255.0
gateway 192.168.1.254
## static ip config START ##
up /sbin/ip route add 172.10.1.0/24 via 10.8.0.1 dev eth0
down /sbin/ip route delete 172.10.1.0/24 via 10.8.0.1 dev eth0
## static ip config END ##


## How to find the route used for an destination IP

The syntax is as follows:
ip route get to {IPv4_address_here}
ip route get to {IPv6_address_here}
ip route get to 172.66.43.74

Outputs indicating that 172.66.43.74 can be reached via the wg0 interface with 192.168.13.4 as source IP:

172.66.43.74 dev wg0 table 51832 src 192.168.13.4 uid 1000 
    cache 

Vimrc example

 syntax on                   " modo visual/colorido ativo
set showmode                " apresenta o modo de utilizacao atual (command/insert)
set ignorecase              " ignora case sensitive durante a busca
set ruler                   " apresenta a posicao do cursor
set showcmd                 " visualiza comandos incompletos
set smarttab                " trabalha a identacao do arquivo
set sm                      " ativar/desativar as coincidencias
set laststatus=1            " exibe a linha de status
set title                                    " habilita o titulo
set term=xterm-256color     " modo do terminal
set smartcase                        " modo de pesquisa
set incsearch               " busca incremental
set autoindent              " auto identacao
set smartindent             " identacao
set undolevels=1000         " numero maximo de restore (undo)
set number            " adiciona numero das linhas
set bg=dark
set paste
set tabstop=2
set shiftwidth=2
set expandtab
autocmd FileType yaml setlocal ai sw=1 et cuc cul

Schedule a Linux reboot

 

Schedule a Linux reboot using shutdown -r <time>  

for one-time events, or crontab -e for recurring reboots. 

Common methods include sudo shutdown -r +60 (in 60 mins),  

sudo shutdown -r 02:00 (at 2 AM), 

 Use "shutdown -c" to cancel reboot 

or adding 0 3 * * * /sbin/shutdown -r now to crontab for daily 3 AM reboots


Restaurar perda de confiança com o domínio

 

Windows 10/11/2019/2022/2025

Com o Windows 10, existem várias soluções para resolver o problema, que veremos aqui.
Reset-ComputerMachinePassword

A primeira solução será usar o cmdlet Reset-ComputerMachinePassword que redefine a senha da conta do computador, o que resolve o problema.

1. Faça login com uma conta de administrador local

2. Inicie uma janela de comando do PowerShell como administrador

3. Digite o seguinte comando:

Reset-ComputerMachinePassword -Server "SERVER_DC" -Credential compte-admin@domaine.local

4. Reinicie o computador. 



Test-ComputerSecureChannel

A outra solução para resolver o problema de aprovação é usar o cmdlet Test-ComputerSecureChannel com o parâmetro -repair

1. Faça logon no computador (de preferência com a conta de administrador local).

2. Abra um prompt de janela do PowerShell como administrador.

3. Digite o seguinte cmdlet para reparar a “ligação segura”.

Test-ComputerSecureChannel -Repair -Credential admin-on-domain@domain.local

Digite a senha vinculada à conta usada no pedido.

4. Reinicie o computador. 

Set https proxy variable on windows

 Check variables: 

[System.Environment]::GetEnvironmentVariable("HTTP_PROXY","user");
[System.Environment]::GetEnvironmentVariable("HTTPS_PROXY","user");
[System.Environment]::GetEnvironmentVariable("HTTPS_PROXY","user");
[System.Environment]::GetEnvironmentVariable("HTTP_PROXY","user");


Set variable:
setx https_proxy http://<your_proxy_name_or_IP>:3128/ 

Command ip examples

  # Forcefully close a connection to a specific destination sudo ss -K dst 192.168.1.100 # view routes ip r ip route # To reject a route (bl...

Mais vistos