mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2025-12-06 17:22:49 +01:00
Merge branch 'feature/ec2_setup' into feature/setup-changes
This commit is contained in:
@@ -499,28 +499,45 @@ create_local_directories() {
|
||||
|
||||
}
|
||||
|
||||
create_sensor_bond() {
|
||||
echo "Setting up sensor bond" >> "$setup_log" 2>&1
|
||||
|
||||
configure_network_sensor() {
|
||||
echo "Setting up sensor interface" >> "$setup_log" 2>&1
|
||||
local nic_error=0
|
||||
|
||||
check_network_manager_conf >> "$setup_log" 2>&1
|
||||
|
||||
# Set the MTU
|
||||
if [[ $NSMSETUP != 'ADVANCED' ]]; then
|
||||
MTU=1500
|
||||
if [[ $is_ec2 ]]; then MTU=1575; else MTU=1500; fi
|
||||
fi
|
||||
|
||||
if [[ $is_ec2 ]]; then
|
||||
INTERFACE=${BNICS[0]}
|
||||
local nmcli_con_arg="type ethernet"
|
||||
else
|
||||
INTERFACE='bond0'
|
||||
local nmcli_con_arg="type bond mode 0"
|
||||
fi
|
||||
|
||||
# Create the bond interface only if it doesn't already exist
|
||||
if ! [[ $(nmcli -f name,uuid -p con | sed -n 's/bond0 //p' | tr -d ' ') ]]; then
|
||||
nmcli con add ifname bond0 con-name "bond0" type bond mode 0 -- \
|
||||
|
||||
nmcli -f name,uuid -p con | grep -q "$INTERFACE"
|
||||
local found_int=$?
|
||||
|
||||
if [[ ! $found_int ]]; then
|
||||
nmcli con add ifname "$INTERFACE" con-name "$INTERFACE" $nmcli_con_arg -- \
|
||||
ipv4.method disabled \
|
||||
ipv6.method ignore \
|
||||
ethernet.mtu $MTU \
|
||||
connection.autoconnect "yes" >> "$setup_log" 2>&1
|
||||
else
|
||||
local int_uuid
|
||||
int_uuid=$(nmcli -f name,uuid -p con | sed -n "s/$INTERFACE //p" | tr -d ' ')
|
||||
|
||||
nmcli con mod "$int_uuid" \
|
||||
ipv4.method disabled \
|
||||
ipv6.method ignore \
|
||||
ethernet.mtu $MTU \
|
||||
connection.autoconnect "yes" >> "$setup_log" 2>&1
|
||||
fi
|
||||
|
||||
|
||||
for BNIC in "${BNICS[@]}"; do
|
||||
# Check if specific offload features are able to be disabled
|
||||
for string in "generic-segmentation-offload" "generic-receive-offload" "tcp-segmentation-offload"; do
|
||||
@@ -536,15 +553,29 @@ create_sensor_bond() {
|
||||
ethtool -K "$BNIC" $i off >> "$setup_log" 2>&1
|
||||
done
|
||||
|
||||
# Check if the bond slave connection has already been created
|
||||
if ! [[ $(nmcli -f name,uuid -p con | sed -n "s/bond0-slave-$BNIC //p" | tr -d ' ') ]]; then
|
||||
# Create the slave interface and assign it to the bond
|
||||
nmcli con add type ethernet ifname "$BNIC" con-name "bond0-slave-$BNIC" master bond0 -- \
|
||||
ethernet.mtu $MTU \
|
||||
connection.autoconnect "yes" >> "$setup_log" 2>&1
|
||||
fi
|
||||
if [[ $is_ec2 ]]; then
|
||||
nmcli con up "$BNIC" >> "$setup_log" 2>&1
|
||||
else
|
||||
# Check if the bond slave connection has already been created
|
||||
nmcli -f name,uuid -p con | grep -q "bond0-slave-$BNIC"
|
||||
local found_int=$?
|
||||
|
||||
if [[ ! $found_int ]]; then
|
||||
# Create the slave interface and assign it to the bond
|
||||
nmcli con add type ethernet ifname "$BNIC" con-name "bond0-slave-$BNIC" master bond0 -- \
|
||||
ethernet.mtu $MTU \
|
||||
connection.autoconnect "yes" >> "$setup_log" 2>&1
|
||||
else
|
||||
local int_uuid
|
||||
int_uuid=$(nmcli -f name,uuid -p con | sed -n "s/bond0-slave-$BNIC //p" | tr -d ' ')
|
||||
|
||||
nmcli con up "bond0-slave-$BNIC" >> "$setup_log" 2>&1 # Bring the slave interface up
|
||||
nmcli con mod "$int_uuid" \
|
||||
ethernet.mtu $MTU \
|
||||
connection.autoconnect "yes" >> "$setup_log" 2>&1
|
||||
fi
|
||||
|
||||
nmcli con up "bond0-slave-$BNIC" >> "$setup_log" 2>&1 # Bring the slave interface up
|
||||
fi
|
||||
done
|
||||
|
||||
if [ $nic_error != 0 ]; then
|
||||
@@ -1331,7 +1362,7 @@ sensor_pillar() {
|
||||
# Create the sensor pillar
|
||||
printf '%s\n'\
|
||||
"sensor:"\
|
||||
" interface: bond0"\
|
||||
" interface: $INTERFACE"\
|
||||
" mainip: $MAINIP"\
|
||||
" mainint: $MNIC" >> "$pillar_file"
|
||||
|
||||
@@ -1442,13 +1473,13 @@ set_initial_firewall_policy() {
|
||||
$default_salt_dir/salt/common/tools/sbin/so-firewall --apply includehost search_node "$MAINIP"
|
||||
case "$install_type" in
|
||||
'EVAL')
|
||||
$default_salt_dir/pillar/data/addtotab.sh evaltab "$MINION_ID" "$MAINIP" "$num_cpu_cores" "$random_uid" "$MNIC" "$filesystem_root" "$filesystem_nsm" bond0 True
|
||||
$default_salt_dir/pillar/data/addtotab.sh evaltab "$MINION_ID" "$MAINIP" "$num_cpu_cores" "$random_uid" "$MNIC" "$filesystem_root" "$filesystem_nsm" $INTERFACE True
|
||||
;;
|
||||
'MASTERSEARCH')
|
||||
$default_salt_dir/pillar/data/addtotab.sh mastersearchtab "$MINION_ID" "$MAINIP" "$num_cpu_cores" "$random_uid" "$MNIC" "$filesystem_root" "$filesystem_nsm"
|
||||
;;
|
||||
'STANDALONE')
|
||||
$default_salt_dir/pillar/data/addtotab.sh standalonetab "$MINION_ID" "$MAINIP" "$num_cpu_cores" "$random_uid" "$MNIC" "$filesystem_root" "$filesystem_nsm" bond0
|
||||
$default_salt_dir/pillar/data/addtotab.sh standalonetab "$MINION_ID" "$MAINIP" "$num_cpu_cores" "$random_uid" "$MNIC" "$filesystem_root" "$filesystem_nsm" $INTERFACE
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
@@ -1462,7 +1493,7 @@ set_initial_firewall_policy() {
|
||||
case "$install_type" in
|
||||
'SENSOR')
|
||||
ssh -i /root/.ssh/so.key soremote@"$MSRV" sudo $default_salt_dir/salt/common/tools/sbin/so-firewall --apply includehost sensor "$MAINIP"
|
||||
ssh -i /root/.ssh/so.key soremote@"$MSRV" sudo $default_salt_dir/pillar/data/addtotab.sh sensorstab "$MINION_ID" "$MAINIP" "$num_cpu_cores" "$random_uid" "$MNIC" "$filesystem_root" "$filesystem_nsm" bond0
|
||||
ssh -i /root/.ssh/so.key soremote@"$MSRV" sudo $default_salt_dir/pillar/data/addtotab.sh sensorstab "$MINION_ID" "$MAINIP" "$num_cpu_cores" "$random_uid" "$MNIC" "$filesystem_root" "$filesystem_nsm" $INTERFACE
|
||||
;;
|
||||
'SEARCHNODE')
|
||||
ssh -i /root/.ssh/so.key soremote@"$MSRV" sudo $default_salt_dir/salt/common/tools/sbin/so-firewall --apply includehost search_node "$MAINIP"
|
||||
@@ -1471,7 +1502,7 @@ set_initial_firewall_policy() {
|
||||
'HEAVYNODE')
|
||||
ssh -i /root/.ssh/so.key soremote@"$MSRV" sudo $default_salt_dir/salt/common/tools/sbin/so-firewall includehost sensor "$MAINIP"
|
||||
ssh -i /root/.ssh/so.key soremote@"$MSRV" sudo $default_salt_dir/salt/common/tools/sbin/so-firewall --apply includehost search_node "$MAINIP"
|
||||
ssh -i /root/.ssh/so.key soremote@"$MSRV" sudo $default_salt_dir/pillar/data/addtotab.sh sensorstab "$MINION_ID" "$MAINIP" "$num_cpu_cores" "$random_uid" "$MNIC" "$filesystem_root" "$filesystem_nsm" bond0
|
||||
ssh -i /root/.ssh/so.key soremote@"$MSRV" sudo $default_salt_dir/pillar/data/addtotab.sh sensorstab "$MINION_ID" "$MAINIP" "$num_cpu_cores" "$random_uid" "$MNIC" "$filesystem_root" "$filesystem_nsm" $INTERFACE
|
||||
ssh -i /root/.ssh/so.key soremote@"$MSRV" sudo $default_salt_dir/pillar/data/addtotab.sh nodestab "$MINION_ID" "$MAINIP" "$num_cpu_cores" "$random_uid" "$MNIC" "$filesystem_root" "$filesystem_nsm"
|
||||
;;
|
||||
'FLEET')
|
||||
@@ -1634,3 +1665,10 @@ es_heapsize() {
|
||||
export NODE_ES_HEAP_SIZE
|
||||
fi
|
||||
}
|
||||
|
||||
detect_ec2() {
|
||||
# Check if EC2
|
||||
curl --fail -s -m 5 http://169.254.169.254/latest/meta-data/instance-id > /dev/null
|
||||
is_ec2=$?
|
||||
export is_ec2
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user