Summary Files Commits Branches @commit @diff @stats
path: root / Year 2 / Computer Networks / Project / router-init.sh
blob: a853529844426f81b92ed1fae8e2243c650f9fde (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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