52 lines
1.2 KiB
Bash
52 lines
1.2 KiB
Bash
|
#!/bin/bash
|
||
|
|
||
|
interface=wlo1
|
||
|
mac=6c:88:14:f9:6f:78
|
||
|
timestamp=$(date +%Y-%m-%d_%H:%M:%S.%6N)
|
||
|
|
||
|
bridged-network {
|
||
|
# Define the physical bridged network
|
||
|
cat > ifcfg-$interface <<EOF
|
||
|
DEVICE=wlol
|
||
|
HWADDR=$mac
|
||
|
ONBOOT=yes
|
||
|
BRIDGE=br0
|
||
|
NM_CONTROLLED=no
|
||
|
EOF
|
||
|
}
|
||
|
|
||
|
bridged-device () {
|
||
|
# Define the bridged network
|
||
|
cat > ifcfg-br0 <<EOF
|
||
|
DEVICE=br0
|
||
|
TYPE=Bridge
|
||
|
BOOTPROTO=dhcp
|
||
|
ONBOOT=yes
|
||
|
DELAY=0
|
||
|
NM_CONTROLLED=no
|
||
|
EOF
|
||
|
service network restart
|
||
|
}
|
||
|
|
||
|
# Disable the netfilter on the bridged network
|
||
|
if test -f /etc/sysctl.conf; then
|
||
|
cp /etc/sysctl.conf /etc/sysctl.conf-$timestamp.bak
|
||
|
fi
|
||
|
|
||
|
echo "net.bridge.bridge-nf-call-ip6tables = 0" >> /etc/sysctl.conf
|
||
|
echo "net.bridge.bridge-nf-call-iptables = 0" >> /etc/sysctl.conf
|
||
|
echo "net.bridge.bridge-nf-call-arptables = 0" >> /etc/sysctl.conf
|
||
|
|
||
|
sysctl -p /etc/sysctl.conf
|
||
|
|
||
|
# Define the bridged network traffic forwarding firewall rule
|
||
|
if test -f /etc/sysconfig/iptables-forward-bridged; then
|
||
|
cp /etc/sysconfig/iptables-forward-bridged /etc/sysconfig/iptables-forward-bridged-$timestamp.bak
|
||
|
fi
|
||
|
|
||
|
echo "-I FORWARD -m physdev --physdev-is-bridged -j ACCEPT" >> /etc/sysconfig/iptables-forward-bridged
|
||
|
lokkit --custom-rules=ipv4:filter:/etc/sysconfig/iptables-forward-bridged
|
||
|
service libvirtd reload
|
||
|
|
||
|
exit 0
|