diff options
Diffstat (limited to 'Scripts')
-rw-r--r-- | Scripts/reset_tap.sh | 22 | ||||
-rw-r--r-- | Scripts/revert_tap_wireless_int.sh | 53 | ||||
-rw-r--r-- | Scripts/setup_tap.sh | 84 |
3 files changed, 0 insertions, 159 deletions
diff --git a/Scripts/reset_tap.sh b/Scripts/reset_tap.sh deleted file mode 100644 index d8080cd..0000000 --- a/Scripts/reset_tap.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -if [[ $EUID > 0 ]]; then - echo "Run this script as root" - exit -fi - -BRIDGE="br0" -TAP="tap0" - -echo "Removing bridge $BRIDGE" -ip link delete $BRIDGE type bridge - -echo "Removing tap $TAP" -ip link delete $TAP type tap - -echo "Setting $INTERFACE up" -ip link set up dev $INTERFACE - -echo "Starting NetworkManager" -systemctl start NetworkManager - diff --git a/Scripts/revert_tap_wireless_int.sh b/Scripts/revert_tap_wireless_int.sh deleted file mode 100644 index b23cf3a..0000000 --- a/Scripts/revert_tap_wireless_int.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/bash - -BRIDGE=br0 -NETWORK=10.10.10.0 -NETMASK=255.255.255.0 -GATEWAY=10.10.10.1 -DHCPRANGE=10.10.10.100,10.10.10.254 - -# Delete the bridge interface -ip link delete dev $BRIDGE type bridge - -# Disable IP forwarding -sysctl -w net.ipv4.ip_forward=0 > /dev/null 2>&1 - -# Flush existing iptables rules and set default policies to ACCEPT -iptables --flush -iptables -t nat -F -iptables -X -iptables -Z -iptables -P OUTPUT ACCEPT -iptables -P INPUT ACCEPT -iptables -P FORWARD ACCEPT - -# Allow DHCP and DNS traffic on the network interface -iptables -A INPUT -i $BRIDGE -p tcp -m tcp --dport 67 -j ACCEPT -iptables -A INPUT -i $BRIDGE -p udp -m udp --dport 67 -j ACCEPT -iptables -A INPUT -i $BRIDGE -p tcp -m tcp --dport 53 -j ACCEPT -iptables -A INPUT -i $BRIDGE -p udp -m udp --dport 53 -j ACCEPT - -# Allow forwarding of packets between the network and the bridge -iptables -A FORWARD -s $NETWORK/$NETMASK -i $BRIDGE -j ACCEPT -iptables -A FORWARD -d $NETWORK/$NETMASK -o $BRIDGE -m state --state RELATED,ESTABLISHED -j ACCEPT - -# Delete the network address translation (NAT) rules -iptables -t nat -D POSTROUTING -s $NETWORK/$NETMASK -d $NETWORK/$NETMASK -j ACCEPT -iptables -t nat -D POSTROUTING -s $NETWORK/$NETMASK -j MASQUERADE - -# Delete the dnsmasq process -pid_file="/var/run/qemu-dnsmasq-$BRIDGE.pid" -if [ -f "$pid_file" ]; then - kill $(cat "$pid_file") - rm "$pid_file" -fi - -# Remove the wireless interface from the forwarding rules -iptables -D FORWARD -i $BRIDGE -o $WIRELESS -j ACCEPT -iptables -t nat -D POSTROUTING -o $WIRELESS -j MASQUERADE - -# Allow known traffic from the wireless interface to return to the network interface -iptables -D FORWARD -i $WIRELESS -o $BRIDGE -m state --state RELATED,ESTABLISHED -j ACCEPT - -echo "Reverted back to default configuration." - diff --git a/Scripts/setup_tap.sh b/Scripts/setup_tap.sh deleted file mode 100644 index 1c71344..0000000 --- a/Scripts/setup_tap.sh +++ /dev/null @@ -1,84 +0,0 @@ -#!/bin/bash - -if [[ $EUID > 0 ]]; then - echo "Run this script as root" - exit -fi - -BRIDGE="br0" -TAP="tap0" - -echo "Available network interfaces:" -interfaces=$(ip link | awk -F ': ' '{print $2}') -index=0 - -# Array to store interface names -declare -a interface_names - -# Array to store interface types -declare -a interface_types - -# Loop through each interface and display its type -for interface in $interfaces; do - type=$(ip link show $interface | grep -o 'type .*' | awk '{print $2}') - echo "$index: $interface - $type" - - # Store interface name and type in arrays - interface_names[$index]=$interface - interface_types[$index]=$type - - ((index++)) -done - -# Prompt the user to select an interface -read -p "Enter the number of the interface you want to use: " selection - -# Validate the user's input -if [[ ! $selection =~ ^[0-9]+$ || $selection -lt 0 || $selection -ge $index ]]; then - echo "Invalid selection. Exiting." - exit -fi - -INTERFACE=${interface_names[$selection]} -INTERFACE_TYPE=${interface_types[$selection]} - -echo "Selected interface: $INTERFACE - $INTERFACE_TYPE" - -echo "Adding bridge $BRIDGE" -ip link add name $BRIDGE type bridge - -echo "Flushing interface $INTERFACE" -ip addr flush dev $INTERFACE - -echo "Setting $BRIDGE as master of $INTERFACE" -ip link set $INTERFACE master $BRIDGE - -echo "Adding tap $TAP" -ip tuntap add $TAP mode tap - -echo "Setting $BRIDGE as master of $TAP" -ip link set $TAP master $BRIDGE - -echo "Setting $INTERFACE, $BRIDGE, and $TAP up" -ip link set up dev $INTERFACE -ip link set up dev $TAP -ip link set up dev $BRIDGE - -echo "Stopping NetworkManager" -systemctl stop NetworkManager - -echo "Requesting IP for $BRIDGE" -dhclient -1 -v $BRIDGE - -if [ $? -eq 0 ]; then - echo "Requesting IP for $INTERFACE" - dhclient $INTERFACE - echo "Killing dhclient and starting NetworkManager" - pkill -9 dhclient - systemctl start NetworkManager -fi - -# run qemu with the below arguments -# -# qemu-system-x86_64 -netdev tap,id=net0,ifname=tap0,script=no,downscript=no -device virtio-net-pci,netdev=net0 - |