# Quick Configurations

## Static Config

### Manually

```
$ sudo service NetworkManager stop
$ ifconfig 
$ sudo ifconfig eth0 10.10.13.37 netmask 255.255.255.0
$ sudo route add default gw 10.10.13.1 dev eth0
$ route -n
$ sudo vi /etc/resolv.conf
domain megacorp.local
search megacorp.local
nameserver 192.168.0.1
$ ping 8.8.8.8
$ nslookup ya.ru
$ sudo systemctl enable ssh --now
```

### netplan

`/etc/netplan/*.yaml`:

```
network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      addresses: [10.10.13.37/24]
      gateway4: 10.10.13.1
      dhcp4: true
      optional: true
      nameservers:
        addresses: [8.8.8.8,8.8.4.4]
```

Apply:

```
$ sudo service NetworkManager stop
$ sudo netplan apply
```

### Disable IPv6

Wired:

```
$ sudo vi /etc/sysctl.conf
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
$ sudo sudo sysctl -p
```

Wireless:

```
$ nmcli connection show
$ nmcli connection modify "<SSID>" ipv6.method ignore
$ nmcli connection up "<SSID>"
```

## resolvconf

* <https://unix.stackexchange.com/questions/128220/how-do-i-set-my-dns-when-resolv-conf-is-being-overwritten>

```
$ sudo apt install resolvconf
$ sudo vi /etc/resolvconf/resolv.conf.d/base
$ sudo resolvconf -u
```

## Simultaneous Interfaces

Configure multiple interfaces to work simultaneously:

```
$ cat /etc/network/interfaces
 # This file describes the network interfaces available on your system
 # and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

 # NAT
allow-hotplug eth0
iface eth0 inet dhcp

 # Internal
allow-hotplug eth1
iface eth1 inet dhcp

 # Host-only
allow-hotplug eth2
iface eth2 inet dhcp

 # The loopback network interface
auto lo
iface lo inet loopback
```

```
$ ifup eth0
$ ifup eth1
$ ifup eth2
```

## Inner and Outer Traffic

Route inner traffic to eth0 (lan), Internet to wlan0 (wan):

```
$ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.0.1     0.0.0.0         UG    100    0        0 eth0
0.0.0.0         172.20.10.1     0.0.0.0         UG    600    0        0 wlan0
172.20.10.0     0.0.0.0         255.255.255.240 U     600    0        0 wlan0
192.168.0.0     0.0.0.0         255.255.255.0   U     100    0        0 eth0

$ sudo ip route add 192.168.0.0/16 via 192.168.0.1 metric 100 dev eth0
$ sudo ip route add 172.16.0.0/12 via 192.168.0.1 metric 100 dev eth0
$ sudo ip route add 10.0.0.0/8 via 192.168.0.1 metric 100 dev eth0
$ sudo ip route del 0.0.0.0/0 via 192.168.0.1 dev eth0

$ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         172.20.10.1     0.0.0.0         UG    600    0        0 wlan0
10.0.0.0        192.168.0.1     255.0.0.0       UG    100    0        0 eth0
172.16.0.0      192.168.0.1     255.240.0.0     UG    100    0        0 eth0
172.20.10.0     0.0.0.0         255.255.255.240 U     600    0        0 wlan0
192.168.0.0     0.0.0.0         255.255.255.0   U     100    0        0 eth0
192.168.0.0     192.168.0.1     255.255.0.0     UG    100    0        0 eth0

$ sudo chattr -i /etc/resolv.conf
$ sudo vi /etc/resolv.conf
...change dns resolve order if necessary...
```

## Wrap All Traffic into VPN in Windows

Check the name of VPN interface (`Virtual Ethernet Adapter`):

```
Cmd > ipconfig /all

Адаптер Ethernet Ethernet 2:

   DNS-суффикс подключения . . . . . :
   Описание. . . . . . . . . . . . . : Virtual Ethernet Adapter
   ...
   IPv4-адрес. . . . . . . . . . . . : 192.168.100.181(Основной)
```

Checks its id (`16`, it's shown in decimal):

```
Cmd > route print -4
===========================================================================
Список интерфейсов
  16...00 ff 00 ff 00 ff ......Virtual Ethernet Adapter
```

Add a static route to wrap all traffic into the VPN gateway. To achieve that specify VPN interface id in hexadecimal (`0x10` in this example) and set higher priority for this route (i.e., lower metric) than default gateway route has:

```
Cmd > route add 0.0.0.0 mask 0.0.0.0 192.168.100.1 metric 7 if 0x10
Cmd > route print -4
...
IPv4 таблица маршрута
===========================================================================
Активные маршруты:
Сетевой адрес           Маска сети      Адрес шлюза         Интерфейс   Метрика
          0.0.0.0          0.0.0.0      192.168.0.1     192.168.0.101       25
          0.0.0.0          0.0.0.0    192.168.100.1   192.168.100.181        7
```

To delete the route run:

```
Cmd > route add 0.0.0.0 mask 0.0.0.0 192.168.100.1
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ppn.snovvcra.sh/admin/networking/quick-configurations.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
