Friday, June 13, 2025

ALPINE LINUX share internet 2 nic

#!/bin/sh


# Enable IP forwarding

echo "net.ipv4.ip_forward=1" >> /etc/sysctl.conf

sysctl -p


# Install required packages

apk add iptables iptables-openrc dnsmasq


# Configure iptables for NAT

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

iptables -A FORWARD -i eth1 -j ACCEPT


# Save iptables rules

mkdir -p /etc/iptables

iptables-save > /etc/iptables/rules-save


# Enable iptables service at boot

rc-update add iptables default


# Assign static IP to eth1

cat <<EOF > /etc/network/interfaces

auto lo

iface lo inet loopback


auto eth0

iface eth0 inet dhcp


auto eth1

iface eth1 inet static

    address 192.168.100.1

    netmask 255.255.255.0

EOF


# Enable networking service at boot

rc-update add networking default


# Configure dnsmasq

cat <<EOF > /etc/dnsmasq.conf

interface=eth1

dhcp-range=192.168.100.50,192.168.100.150,12h

dhcp-option=3,192.168.100.1

dhcp-option=6,8.8.8.8

EOF


# Enable and start dnsmasq

rc-update add dnsmasq default

rc-service dnsmasq restart


echo "Internet sharing setup complete and persistent across reboots."


Monday, June 9, 2025

MikroTik

Check Network card

 /interface print

set ip for nat card

/ip dhcp-client add interface=ether3 disabled=no
show status
/ip dhcp-client print

set ip for exit card
/ip address add address=192.168.137.1/24 interface=ether4

/ip pool add name=dhcp_pool_ether4 ranges=192.168.137.10-192.168.137.100
/ip dhcp-server network add address=192.168.137.0/24 gateway=192.168.137.1 dns-server=8.8.8.8
/ip dhcp-server add name=dhcp_ether4 interface=ether4 address-pool=dhcp_pool_ether4 disabled=no
show lease
/ip dhcp-server lease print

share
/ip firewall nat add chain=srcnat out-interface=ether3 action=masquerade

/system package update check-for-updates

/system package update download

Saturday, June 7, 2025

Debian 12 to share internet

1. Download The Debian Bookworm network installation CD

2. install follow steps and on set software unselect all

note command to see network

   ip a

3 sudo nano /etc/network/interfaces


3.1 sudo systemctl restart networking
3.2 echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward
3.3 sudo nano /etc/sysctl.conf
    uncomment #
    net.ipv4.ip_forward=1
3.4 sudo sysctl -p
3.5 
sudo iptables -t nat -A POSTROUTING -o enx000ec6c29c18-j MASQUERADE
sudo iptables -A FORWARD -i ens33 -o enx000ec6c29c18 -j ACCEPT
sudo iptables -A FORWARD -i enx000ec6c29c18 -o ens33 -m state --state RELATED,ESTABLISHED -j ACCEPT
3.6 sudo apt install iptables-persistent


sudo nano /etc/apt/sources.list


sudo apt update && sudo apt upgrade
sudo apt install open-vm-tools isc-dhcp-server
sudo nano /etc/dhcp/dhcpd.conf

sudo nano /etc/default/isc-dhcp-server

sudo systemctl restart isc-dhcp-server

  sudo systemctl enable isc-dhcp-server

8 sudo nano /etc/systemd/system/nightly-reboot.service

[Unit]
Description=Scheduled Nightly Reboot

[Service]
Type=oneshot
ExecStart=/usr/bin/systemctl --force reboot

sudo nano /etc/systemd/system/nightly-reboot.timer

[Unit]
Description=Nightly Reboot Scheduling

[Timer]
OnCalendar=*-*-* 2:01:00
RandomizedDelaySec=300

[Install]
WantedBy=multi-user.target

10 sudo systemctl daemon-reload

   sudo systemctl enable nightly-reboot.timer

   sudo systemctl start nightly-reboot.timer