Hyper-V manager: Create new Virtual Private Switch
Configure network interfaces
file /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/*
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
allow-hotplug eth0
iface eth0 inet dhcp
# The secondary face
allow-hotplug eth1
iface eth1 inet static
address 10.0.10.1
netmask 255.255.255.0
dns-nameservers 10.0.10.1
Configure DHCP, DNS:
Configure iptables (masquearde)
# apt install -y iptables
create script and give executable privileges to it:
file /etc/network/if-up.d/001masquerade
#!/bin/sh
# Reload the iptables rules and activate forwarding
# delete all existing rules.
iptables -Z # zero counters
iptables -F # flush (delete) rules
iptables -t mangle -F
iptables -X # delete all extra chains
# If you want to clear the chains, then clear the chains:
iptables --policy INPUT ACCEPT;
iptables --policy OUTPUT ACCEPT;
iptables --policy FORWARD ACCEPT;
# Masquerade.
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
# Enable routing.
echo 1 > /proc/sys/net/ipv4/ip\_forward
exit 0
Create test page on faked address: http://ufo.mars
# apt install -y apache2
file: /var/www/html/index.html
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=UTF-8" >
<title>Welcome to Mars</title>
</head>
<body>
<span style="color:red"><h1>WELCOME TO MARS</h1></span>
<img src="mars.jpg">
</body>
</html>
systemctl status NetworkManager --no-pager
On Ubuntu 20.04
open http://ufo.mars)
You have to see this:
No SSH connection with "private switch" nodes.
No SSH connection with "private switch" nodes.
Allow packet forwarding on host (REGEDIT, reboot required):
Computer\
HKEY_LOCAL_MACHINE\
SYSTEM\
CurrentControlSet\
Services\
Tcpip\
Parameters
IPEnableRouter REG_DWORD 1
Make sure your ssh daemon is configured, up and running Networking
old style:
# ifconfig enp0s3 10.0.10.100 up
# route add default gw 10.0.10.1
new style:
# ip link set dev eth0 up mtu 1500
# ip addr add dev eth0 10.0.0.2/24 broadcast 10.0.0.255
# ip route add 10.0.0.2/24 via 10.0.0.1
https://www.cyberciti.biz/faq/ip-route-add-network-command-for-linux-explained/
Permanent DNS
old style:
# echo nameserver 192.168.253.250 > /etc/resolv.conf
# echo nameserver 192.168.253.249 >> /etc/resolv.conf
new style:
#!/bin/bash
apt install -y resolvconf
systemctl status resolvconf.service
echo nameserver 192.168.253.250 > \
/etc/resolvconf/resolv.conf.d/head
echo nameserver 192.168.253.249 >> \
/etc/resolvconf/resolv.conf.d/head
systemctl restart resolvconf.service