mirror of
https://github.com/pi-hole/pi-hole.git
synced 2025-03-31 20:50:17 +00:00
Merge pull request #1037 from pi-hole/tweak/IPv4_multi_address
Smarter pick of IPv4 address
This commit is contained in:
commit
823e874d20
1 changed files with 8 additions and 3 deletions
|
@ -182,13 +182,13 @@ getGitFiles() {
|
||||||
find_IPv4_information() {
|
find_IPv4_information() {
|
||||||
# Find IP used to route to outside world
|
# Find IP used to route to outside world
|
||||||
IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}')
|
IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}')
|
||||||
IPV4_ADDRESS=$(ip -o -f inet addr show dev "$IPv4dev" | awk '{print $4}' | awk 'END {print}')
|
IPV4_ADDRESS=$(ip route get 8.8.8.8| awk '{print $7}')
|
||||||
IPv4gw=$(ip route get 8.8.8.8 | awk '{print $3}')
|
IPv4gw=$(ip route get 8.8.8.8 | awk '{print $3}')
|
||||||
}
|
}
|
||||||
|
|
||||||
get_available_interfaces() {
|
get_available_interfaces() {
|
||||||
# Get available interfaces. Consider only getting UP interfaces in the future, and leaving DOWN interfaces out of list.
|
# Get available UP interfaces.
|
||||||
availableInterfaces=$(ip -o link | awk '{print $2}' | grep -v "lo" | cut -d':' -f1 | cut -d'@' -f1)
|
availableInterfaces=$(ip -o link | grep "state UP" | awk '{print $2}' | cut -d':' -f1 | cut -d'@' -f1)
|
||||||
}
|
}
|
||||||
|
|
||||||
welcomeDialogs() {
|
welcomeDialogs() {
|
||||||
|
@ -247,6 +247,11 @@ chooseInterface() {
|
||||||
# Loop sentinel variable
|
# Loop sentinel variable
|
||||||
local firstLoop=1
|
local firstLoop=1
|
||||||
|
|
||||||
|
if [[ $(echo ${availableInterfaces} | wc -l) -eq 1 ]]; then
|
||||||
|
PIHOLE_INTERFACE=${availableInterfaces}
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
while read -r line; do
|
while read -r line; do
|
||||||
mode="OFF"
|
mode="OFF"
|
||||||
if [[ ${firstLoop} -eq 1 ]]; then
|
if [[ ${firstLoop} -eq 1 ]]; then
|
||||||
|
|
Loading…
Add table
Reference in a new issue