konosubakonoakua / blog

https://konosubakonoakua.github.io/blog/
MIT License
0 stars 0 forks source link

[sw][linux][windows] share personal network to network switch #95

Open konosubakonoakua opened 2 months ago

konosubakonoakua commented 2 months ago

computer A with working network (windows)

[!IMPORTANT] If you have windows (host) rebooted, you need to restart the share process, disable then enable. Or make it persistant. Follow tutorial here.

New-ItemProperty -Path HKLM:\Software\Microsoft\Windows\CurrentVersion\SharedAccess -Name EnableRebootPersistConnection -Value 1 -PropertyType dword
Set-Service SharedAccess –startuptype automatic –passthru
Start-Service SharedAccess
  • adapter 1 connect to outside network (to be shared)
konosubakonoakua commented 2 months ago

computer B connected to net switch (ubuntu 22)

#!/bin/bash

export NIC=eno1
export GATEWAY=192.168.137.1
export IP0=192.168.137.2
export IP1=10.9.8.8
export IP2=10.10.9.235

export CONNECTION=$(nmcli -t -f DEVICE,CONNECTION device status | grep $NIC | awk -F: '{print $2}')

sudo nmcli connection modify "$CONNECTION" ipv4.addresses $IP0/24
sudo nmcli connection modify "$CONNECTION" ipv4.gateway $GATEWAY
sudo nmcli connection modify "$CONNECTION" ipv4.dns $GATEWAY
sudo nmcli connection modify "$CONNECTION" ipv4.method manual
sudo nmcli connection modify "$CONNECTION" +ipv4.addresses $IP1/24
sudo nmcli connection modify "$CONNECTION" +ipv4.addresses $IP2/24

sudo nmcli connection up "$CONNECTION"

ip route show

then we get

konosubakonoakua commented 2 months ago

https://ubuntu.com/core/docs/networkmanager/edit-connections

konosubakonoakua commented 1 month ago

Troubleshooting