Last active
March 3, 2020 09:25
-
-
Save skvl/ecc2eca1483bbefbe692f0b1aa577d7c to your computer and use it in GitHub Desktop.
Revisions
-
skvl revised this gist
Sep 20, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -49,7 +49,7 @@ sudo iptables -t nat -A PREROUTING -i xenbr0 -p tcp --dport 53 -j DNAT --to-dest ```bash sudo apt install iptables-persistent ``` Данная команда создаст файл `/etc/iptables/rules.v4`, который можно будет отредактировать (удалив лишние правила). Во время загрузки системы все правила сохранённые правила будут добавляться в _iptables_. * В `*.hvm` файл добавить строку вида: ``` vif = [ "type=ioemu, model=e1000, ip=192.168.0.10/24" ] -
skvl revised this gist
Sep 20, 2019 . 1 changed file with 2 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -45,13 +45,11 @@ sudo iptables -A FORWARD -i eno1 -o xenbr0 -m state --state RELATED,ESTABLISHED sudo iptables -t nat -A PREROUTING -i xenbr0 -p udp --dport 53 -j DNAT --to-destination 10.42.0.1:53 sudo iptables -t nat -A PREROUTING -i xenbr0 -p tcp --dport 53 -j DNAT --to-destination 10.42.0.1:53 ``` * Сделать новые правила постоянными: ```bash sudo apt install iptables-persistent ``` Данная команда создаст файл `/etc/iptables/rules.v4`, который можно будет отредактировать (удалив лишние правила). Во время загрузки системы все правила сохранённые правила будут добавляться в _iptables_. * В `*.hvm` файл добавить строку вида: ``` vif = [ "type=ioemu, model=e1000, ip=192.168.0.10/24" ] -
skvl revised this gist
Sep 20, 2019 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -49,7 +49,9 @@ sudo iptables -t nat -A PREROUTING -i xenbr0 -p tcp --dport 53 -j DNAT --to-dest ```bash sudo apt install iptables-persistent ``` Данная команда создаст файл `/etc/iptables/rules.v4`, который можно будет отредактировать (удалив лишние правила). Во время загрузки системы все правила сохранённые правила будут добавляться в _iptables_. * В `*.hvm` файл добавить строку вида: ``` vif = [ "type=ioemu, model=e1000, ip=192.168.0.10/24" ] -
skvl revised this gist
Sep 20, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -46,7 +46,7 @@ sudo iptables -t nat -A PREROUTING -i xenbr0 -p udp --dport 53 -j DNAT --to-dest sudo iptables -t nat -A PREROUTING -i xenbr0 -p tcp --dport 53 -j DNAT --to-destination 10.42.0.1:53 ``` * Сделать новые правила постоянными ```bash sudo apt install iptables-persistent ``` Данная команда создаст файл `/etc/iptables/rules.v4`, который можно будет отредактировать (удалив лишние правила). Во время загрузки системы все правила сохранённые правила будут добавляться в _iptables_. -
skvl revised this gist
Sep 20, 2019 . 1 changed file with 5 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -45,6 +45,11 @@ sudo iptables -A FORWARD -i eno1 -o xenbr0 -m state --state RELATED,ESTABLISHED sudo iptables -t nat -A PREROUTING -i xenbr0 -p udp --dport 53 -j DNAT --to-destination 10.42.0.1:53 sudo iptables -t nat -A PREROUTING -i xenbr0 -p tcp --dport 53 -j DNAT --to-destination 10.42.0.1:53 ``` * Сделать новые правила постоянными ```base sudo apt install iptables-persistent ``` Данная команда создаст файл `/etc/iptables/rules.v4`, который можно будет отредактировать (удалив лишние правила). Во время загрузки системы все правила сохранённые правила будут добавляться в _iptables_. * В `*.hvm` файл добавить строку вида: ``` vif = [ "type=ioemu, model=e1000, ip=192.168.0.10/24" ] -
skvl revised this gist
Sep 11, 2019 . 1 changed file with 6 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,7 @@ Основывается на [ответе](https://askubuntu.com/a/1075321). * В файл `/etc/netplan/50-cloud-init.yaml` добавить строки вида (из [примера](https://netplan.io/examples#configuring-network-bridges)): ``` network: ethernets: @@ -33,10 +33,7 @@ network: sudo netplan --debug generate sudo netplan --debug apply ``` * В `/etc/sysctl.conf` добавить строку `net.ipv4.ip_forward=1` и выполнить `sysctl -p /etc/sysctl.conf`. * Настроить _NAT_ следующими командами (предполагается, что _eno1_ физический сетевой интерфейс в сети `10.42.0.0/24` и провайдер блокирует порт 53): ```bash # Настройка NAT @@ -48,6 +45,10 @@ sudo iptables -A FORWARD -i eno1 -o xenbr0 -m state --state RELATED,ESTABLISHED sudo iptables -t nat -A PREROUTING -i xenbr0 -p udp --dport 53 -j DNAT --to-destination 10.42.0.1:53 sudo iptables -t nat -A PREROUTING -i xenbr0 -p tcp --dport 53 -j DNAT --to-destination 10.42.0.1:53 ``` * В `*.hvm` файл добавить строку вида: ``` vif = [ "type=ioemu, model=e1000, ip=192.168.0.10/24" ] ``` * В виртуальной машине настроить статический адрес `192.168.0.10/24` и любой _DNS_ сервер ----- -
skvl revised this gist
Sep 11, 2019 . 1 changed file with 43 additions and 23 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -42,8 +42,8 @@ vif = [ "type=ioemu, model=e1000, ip=192.168.0.10/24" ] # Настройка NAT sudo iptables -t nat -A POSTROUTING -o eno1 -s 192.168.0.0/24 -j MASQUERADE # Пробрасывание пакетов между интерфейсами (нужно если политика DROP) sudo iptables -A FORWARD -o eno1 -i xenbr0 -j ACCEPT sudo iptables -A FORWARD -i eno1 -o xenbr0 -m state --state RELATED,ESTABLISHED -j ACCEPT # Перенаправление DNS sudo iptables -t nat -A PREROUTING -i xenbr0 -p udp --dport 53 -j DNAT --to-destination 10.42.0.1:53 sudo iptables -t nat -A PREROUTING -i xenbr0 -p tcp --dport 53 -j DNAT --to-destination 10.42.0.1:53 @@ -54,25 +54,45 @@ sudo iptables -t nat -A PREROUTING -i xenbr0 -p tcp --dport 53 -j DNAT --to-dest На всякий случай все настройки _iptables_: ```bash $ sudo iptables -L -v Chain INPUT (policy ACCEPT 663 packets, 116K bytes) pkts bytes target prot opt in out source destination Chain FORWARD (policy DROP 0 packets, 0 bytes) pkts bytes target prot opt in out source destination 687 835K ACCEPT all -- eno1 xenbr0 anywhere anywhere state RELATED,ESTABLISHED 433 51417 ACCEPT all -- xenbr0 eno1 anywhere anywhere Chain OUTPUT (policy ACCEPT 723 packets, 187K bytes) pkts bytes target prot opt in out source destination Chain DOCKER (0 references) pkts bytes target prot opt in out source destination Chain DOCKER-ISOLATION-STAGE-1 (0 references) pkts bytes target prot opt in out source destination 0 0 RETURN all -- any any anywhere anywhere Chain DOCKER-ISOLATION-STAGE-2 (0 references) pkts bytes target prot opt in out source destination 0 0 RETURN all -- any any anywhere anywhere $ sudo iptables -L -v -t nat Chain PREROUTING (policy ACCEPT 274 packets, 40068 bytes) pkts bytes target prot opt in out source destination 150 9137 DNAT udp -- xenbr0 any anywhere anywhere udp dpt:domain to:10.42.0.1:53 0 0 DNAT tcp -- xenbr0 any anywhere anywhere tcp dpt:domain to:10.42.0.1:53 Chain INPUT (policy ACCEPT 26 packets, 4704 bytes) pkts bytes target prot opt in out source destination Chain OUTPUT (policy ACCEPT 10 packets, 632 bytes) pkts bytes target prot opt in out source destination Chain POSTROUTING (policy ACCEPT 8 packets, 480 bytes) pkts bytes target prot opt in out source destination 267 17225 MASQUERADE all -- any eno1 anywhere anywhere Chain DOCKER (0 references) pkts bytes target prot opt in out source destination ``` -
skvl revised this gist
Sep 11, 2019 . 1 changed file with 62 additions and 19 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,30 +6,73 @@ * В файл `/etc/netplan/50-cloud-init.yaml` добавить строки вида (из [примера](https://netplan.io/examples#configuring-network-bridges): ``` network: ethernets: eno1: addresses: - 10.42.0.104/24 gateway4: 10.42.0.1 nameservers: addresses: - 10.42.0.1 search: - 10.42.0.1 optional: true bridges: xenbr0: addresses: - 192.168.0.1/24 interfaces: [] parameters: forward-delay: 0 stp: false version: 2 ``` * Выполнить команды: ```bash sudo netplan --debug generate sudo netplan --debug apply ``` * В `*.hvm` файл добавить строку вида: ``` vif = [ "type=ioemu, model=e1000, ip=192.168.0.10/24" ] ``` * Настроить _NAT_ следующими командами (предполагается, что _eno1_ физический сетевой интерфейс в сети `10.42.0.0/24` и провайдер блокирует порт 53): ```bash # Настройка NAT sudo iptables -t nat -A POSTROUTING -o eno1 -s 192.168.0.0/24 -j MASQUERADE # Пробрасывание пакетов между интерфейсами (нужно если политика DROP) sudo iptables -A FORWARD -o xenbr0 -i eno1 -j ACCEPT sudo iptables -A FORWARD -i eno1 -o xenbr0 -m state --state RELATED,ESTABLISHED # Перенаправление DNS sudo iptables -t nat -A PREROUTING -i xenbr0 -p udp --dport 53 -j DNAT --to-destination 10.42.0.1:53 sudo iptables -t nat -A PREROUTING -i xenbr0 -p tcp --dport 53 -j DNAT --to-destination 10.42.0.1:53 ``` * В виртуальной машине настроить статический адрес `192.168.0.10/24` и любой _DNS_ сервер ----- На всякий случай все настройки _iptables_: ```bash $ sudo iptables-save # Generated by iptables-save v1.6.1 on Wed Sep 11 15:01:58 2019 *nat :PREROUTING ACCEPT [59:5951] :INPUT ACCEPT [2:319] :OUTPUT ACCEPT [2:120] :POSTROUTING ACCEPT [2:120] -A PREROUTING -i xenbr0 -p udp -m udp --dport 53 -j DNAT --to-destination 10.42.0.1:53 -A PREROUTING -i xenbr0 -p tcp -m tcp --dport 53 -j DNAT --to-destination 10.42.0.1:53 -A POSTROUTING -o eno1 -j MASQUERADE COMMIT # Completed on Wed Sep 11 15:01:58 2019 # Generated by iptables-save v1.6.1 on Wed Sep 11 15:01:58 2019 *filter :INPUT ACCEPT [46551:3824336] :FORWARD ACCEPT [1290:172274] :OUTPUT ACCEPT [87997:29413481] -A FORWARD -i eno1 -o xenbr0 -j ACCEPT -A FORWARD -i eno1 -o xenbr0 -m state --state RELATED,ESTABLISHED COMMIT # Completed on Wed Sep 11 15:01:58 2019 ``` -
skvl revised this gist
Sep 10, 2019 . 1 changed file with 16 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,15 +4,23 @@ Основывается на [ответе](https://askubuntu.com/a/1075321). * В файл `/etc/netplan/50-cloud-init.yaml` добавить строки вида (из [примера](https://netplan.io/examples#configuring-network-bridges): ``` network: version: 2 renderer: networkd ethernets: enp0s25: dhcp4: true bridges: xenbr0: addresses: [ 10.3.99.25/24 ] interfaces: [ vlan15 ] vlans: vlan15: accept-ra: no id: 15 link: enp0s25 ``` * Выполнить команды: -
skvl revised this gist
Sep 10, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ # Создание `xenbr0` в системе с [netplan](https://netplan.io) Исходная задача состояла в том, что бы восстановить ВМ из снимка. При этом доступность интернета не имела значения. -
skvl created this gist
Sep 10, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ # Создание `xenbr0` в системе с [netplan](netplan.io) Исходная задача состояла в том, что бы восстановить ВМ из снимка. При этом доступность интернета не имела значения. Основывается на [ответе](https://askubuntu.com/a/1075321). * В файл `/etc/netplan/50-cloud-init.yaml` добавить строки вида: ``` bridges: xenbr0: interfaces: [] dhcp4: true parameters: stp: false forward-delay: 0 ``` * Выполнить команды: ```bash sudo netplan --debug generate sudo netplan apply ``` * В `*.hvm` файл добавить строку вида: ``` vif = [ "type=ioemu, model=e1000" ] ```