diff options
[CN/P] Added helper script for configuring routers and "servers"
1 files changed, 48 insertions, 0 deletions
| -rw-r--r-- | Year 2/Computer Networks/Project/router-init.sh | 48 |
diff --git a/Year 2/Computer Networks/Project/router-init.sh b/Year 2/Computer Networks/Project/router-init.sh new file mode 100644 index 0000000..a853529 --- /dev/null +++ b/Year 2/Computer Networks/Project/router-init.sh @@ -0,0 +1,48 @@ +# Name +system identity set name=Router0 +# DNS servers +ip dns set servers=8.8.8.8,8.8.4.4 +# Disable DHCP client, we're setting up router IPs manually +ip dhcp-client remove 0 + +## Router ## + # Add addresses to subnetworks on each interface + ip address add address=0.0.0.0/0 interface=ether0 + + + # Setup RIP + routing rip set redistribute-connected=yes + routing rip set update-timer=15s + routing rip set timeout-timer=30s + routing rip set garbage-timer=30s + + # For routers; send and receive routing info + routing rip interface add interface=ether0 send=v2 receive=v2 + # For clients; only receive routing info + routing rip interface add interface=ether0 passive=yes + + routing rip network add network=0.0.0.0/0 + + routing rip route print # маршрути + + # DHCP Relay + ip dhcp-relay add interface=ether1 dhcp-server=0.0.0.0 name=relay1 disabled=no + + # Setup Gateway + ip dhcp-client add interface=ether0 disabled=no + routing rip set distribute-default=if-installed + ip firewall nat add chain=srcnat action=masquerade out-interface=ether0 + +## Server ## + ip address add address=0.0.0.0/0 interface=ether1 + + # Static route; dst-address - packges go to this subnet, gateway - next router to send data + ip route add dst-address=0.0.0.0/0 gateway=1.1.1.1 + + # DHCP server + ip pool add name=pool1 ranges=0.0.0.0-0.0.0.10 + # Create DHCP server, which will be leasing out only adresses in the given pool, only on the interface + ip dhcp-server add interface=ether0 address-pool=pool1 lease-time=24h name=dhcpi disabled=no + relay=0.0.0.0 # handle DHCP requests which come from a relay, i.e. not from the machine itself + # Leasing is done for address with gateway. All of this information is given to the client. + ip dhcp-server network add address=0.0.0.0/24 dns-server=8.8.8.8,8.8.4.4 gateway=0.0.0.254 |
