Hello everyone!

I practicing with networking and assembled a "mini-network" as on image below:
Click image for larger version. 

Name:	Infrastructure.png 
Views:	9 
Size:	32.6 KB 
ID:	30332

Router is just a home network router (IP: 192.168.0.1), Computer 0 has 2 network interface:
  • Wi-Fi : for connecting to router, has access to internet (IP: 192.168.0.162)
  • Ethernet : for connection to other computers via network switch

Other computers has Ethernet interface only and plugged to a switch. All computers are running Fedora Server 30.

What I need:
  • Combine them into one network of computers with a certain netmask (let say 12.45.15.x)
  • Share Wi-FI internet connection from Computer 0 to Computers 1, 2 and 3 over Ethernet
  • Computers 1,2, and 3 must obtain static IP addresses. And those addresses should be defined by Computer 0, not by "client computers"


I achieved some of goals with varied success, but not all together. Here is what I tried / tested:


Setting up the eth0 as "Shared network"
Edit file `/etc/sysconfig/network-script/ifcfg-eth0` and add/edit following parameters:
  • BOOTPROTO=shared
  • IPV6_AUTOCONF=shared


It allows other machines to use internet from Computer 0, automatically assign IP 10.42.0.1 to Computer 0 and assigns 10.42.0.x IPs to each connected device.
I also figured out that I can adjust network via specifying in the same file:
  • IPADDR=12.45.15.1
  • GATEWAY=12.45.15.1
  • PREFIX=24


But, to get static addresses for client machines I need to connect to each of them and specify it locally on client machine via editing file /etc/sysconfig/network-script/ifcfg-eth0 which is not convenient.
Is there any other way to specify static IP addresses for client Computers, but specifying t on Computer 0?



Setting-up the Computer 0 as DHCP server
Get the MAC address of eth0 interface wit `ip addr`

Edit `/etc/dhcp/dhcpd.conf` on Computer 0 and add following lines:
Code:
default-lease-time 600;
max-lease-time 7200;
authoritative;

subnet 12.45.15.0 netmask 255.255.255.0 {
    interface eth0;

    default-lease-time 600;
    max-lease-time 7200;

    range 12.45.15.10 10.42.15.254;
    option routers 12.45.15.1;
    option broadcast-address 12.45.15.255;
    option domain-name "my_network";
    option domain-name-servers 8.8.8.8, 8.8.4.4, 12.45.15.1;

    host computer_0 {

        hardware ethernet "here_is_MAC_address_of_computer_0";
        fixed-address 12.45.15.1;
    }   
}
After that I enable dhcpd service, add it to firewall exceptions and start it.

Also, to assign static addresses for "client computers" I scan network with:
Code:
sudo arp-scan --interface=eth0 --localnet
And obtained list I use for editing `/etc/dhcp/dhcpd.conf`, where IP is specified based on template:
Code:
host computerX {
        hardware ethernet "here_is_MAC_address_of_computer_X";
        fixed-address 12.45.15.13; # Actually, I calculate it as 10 + X,
    }
And restart the dhcpd.

It does create a network 12.45.15.x, and all computers can see each other, but Computer 0 loses ability to connect to internet via Wi-Fi.
It is fixable via either:
  • running `route add default gw 192.168.0.1`
  • setting parameter `DEFROUTe=no` in `/etc/sysconfig/network-script/ifcfg-eth0` on Computer 0


Are there any other / better way to fix internet access?

Even after fixing Internet on Computer 0, no other computer in "switch network" can see the internet. Neither of `ping -c 3 8.8.8.8` or `ping -c 3 ww.google.com` can reach destination.

My first guess was, that I need to set-up the IP forwarding. So I ran following code on Computer 0:
Code:
sudo -i
sysctl -w net.ipv4.ip_forward=1
sysctl -p /etc/sysctl.conf
sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
iptables -A FORWARD -o wlan0 -i eth0 -m conntrack --ctstate NEW -j ACCEPT
iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
iptables -t nat -F POSTROUTING
iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
This allows to run `ping -c 3 8.8.8.8` on Computers 1,2 and 3, but `ping -c 3 www.google.com` still can't be reached.
What am I doing wrong? How to fix that and are there any other better way to do that?




Thank you!