Summary Files Commits Branches @commit @diff @stats
diff options
context:
space:
mode:
Commita989c33e610b495b8a096d28b9f9391669bb4dfe (patch)
Author
 Syndamia <kamen@syndamia.com>
2023-06-04 17:20:08 +0300
Committer
 Syndamia <kamen@syndamia.com>
2023-06-04 17:20:08 +0300
Files595f092aae08aa8cd8bb06744357b4cb5dd2c2f4
uni-projects-a989c33e610b495b8a096d28b9f9391669bb4dfe.tar
uni-projects-a989c33e610b495b8a096d28b9f9391669bb4dfe.tar.gz
uni-projects-a989c33e610b495b8a096d28b9f9391669bb4dfe.zip
Parent5dfcc99c3c67e3b55ce98b76862e28ecd556628d (diff)
[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.sh48
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