network: utiliser 127.0.1.1 pour dhcp

This commit is contained in:
Jephté Clain 2021-04-06 16:31:38 +04:00
parent dfb5fc31d8
commit a75b91e2e9
2 changed files with 13 additions and 7 deletions

View File

@ -705,10 +705,9 @@ iface lo inet loopback
# si on ne spécifie pas l'adresse ip principale, la résoudre ici. ceci # si on ne spécifie pas l'adresse ip principale, la résoudre ici. ceci
# est nécessaire pour mettre à jour /etc/hosts # est nécessaire pour mettre à jour /etc/hosts
if [ "$mainip" == dhcp ]; then # si mainip == dhcp, c'est pris en charge par network_fix_hosts qui
# si l'adresse obtenue est en DHCP, ne pas mettre à jour /etc/hosts # utilisera 127.0.1.1 à la place
mainip= if [ -z "$mainip" ]; then
elif [ -z "$mainip" ]; then
local -a mainips local -a mainips
resolv_ips mainips "$host" resolv_ips mainips "$host"
[ -n "${mainips[*]}" ] || { [ -n "${mainips[*]}" ] || {

View File

@ -635,12 +635,19 @@ function network_fix_postfix() {
} }
function network_fix_hosts() { function network_fix_hosts() {
local host="$1" hostname="${1%%.*}"; local shost="${host//./\\.}"
local ip="$2"; local sip="${ip//./\\.}"
local oldhost="$3" oldhostname="${3%%.*}"; soldhost="${host//./\\.}"
local tmpfile; ac_set_tmpfile tmpfile local tmpfile; ac_set_tmpfile tmpfile
local modified local modified
local host="$1" hostname="${1%%.*}"
local shost="${host//./\\.}"
local ip="$2"
[ "$ip" == dhcp ] && ip=127.0.1.1
local sip="${ip//./\\.}"
local oldhost="$3" oldhostname="${3%%.*}"
local soldhost="${host//./\\.}"
awkrun </etc/hosts >"$tmpfile" \ awkrun </etc/hosts >"$tmpfile" \
host="$host" hostname="$hostname" \ host="$host" hostname="$hostname" \
ip="$ip" \ ip="$ip" \