Created
December 27, 2017 23:31
-
-
Save joka90/4b8cfd8161a2334c85f883b532cad806 to your computer and use it in GitHub Desktop.
will configure a linux machine to route multicast trafic and start a dhcp server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#stop on error | |
set -e | |
LOCAL_IF="enp2s0" | |
UPSTREAM_IF="enp2s0" | |
ifconfig ${LOCAL_IF} 192.168.2.1 netmask 255.255.255.0 broadcast 192.168.2.255 | |
# Disabled by default! | |
echo "1" > /proc/sys/net/ipv4/ip_forward | |
# Load various modules. Usually they are already loaded | |
# (especially for newer kernels), in that case | |
# the following commands are not needed. | |
# Load iptables module: | |
modprobe ip_tables | |
# activate connection tracking | |
# (connection's status are taken into account) | |
modprobe ip_conntrack | |
# Special features for IRC: | |
modprobe ip_conntrack_irc | |
#Special features for FTP: | |
modprobe ip_conntrack_ftp | |
iptables -t nat -A POSTROUTING -o ${UPSTREAM_IF} -j MASQUERADE | |
echo 40 > /proc/sys/net/ipv4/igmp_max_msf | |
echo "2" > /proc/sys/net/ipv4/conf/${LOCAL_IF}/force_igmp_version | |
#forward all multicast traffic | |
ip route add 224.0.0.0/4 dev ${LOCAL_IF} | |
#setup dhcp server | |
cat <<EOF | |
option domain-name-servers 192.168.1.1; | |
option subnet-mask 255.255.255.0; | |
option routers 192.168.2.1; | |
subnet 192.168.2.0 netmask 255.255.255.0 { | |
range 192.168.2.150 192.168.2.250; | |
} | |
EOF > /tmp/dhcpd_tmp.conf | |
#start dhcp server | |
/usr/bin/dhcpd -4 -q -cf /tmp/dhcpd_tmp.conf -pf /run/dhcpd4.pid ${LOCAL_IF} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment