Author SHA1 Message Date
Brent YangandGitHub b67c340954 DNS: Cloudflare by default; Cloud-init: disable ds-identify and force NoCloud 2025-07-12 17:59:15 +09:00
cha0sCatGitHubAnonymous <>Brent, Yang Bohan <youthdna@live.com>
4807410541 feat: add --static-ipv4 option, auto parse current network settings. (#131)
* feat: use static ip without manually typing it

* fix(cidr_to_netmask): rewrite to support sh

* refactor: remove cidr_to_netmask(), set cidr directly

https://lists.debian.org/debian-boot/2012/09/msg00239.html

* refactor: rename option --static-ip to --static-ipv4

* Add --static-ipv4 doc

---------

Co-authored-by: Anonymous <>
Co-authored-by: Brent, Yang Bohan <youthdna@live.com>
2025-02-22 21:54:04 +09:00
Eric-2369andBrent Yang 8e779c7999 fix: correct Debian version mapping for Trixie 2024-10-17 20:21:42 +09:00
Brent YangandGitHub 88cb473795 Update README.md 2024-05-18 16:29:56 +09:00
2 changed files with 19 additions and 7 deletions
+1 -3
View File
@@ -32,9 +32,6 @@ Download the script with curl:
curl -fLO https://raw.githubusercontent.com/bohanyang/debi/master/debi.sh
# for IPv6-only machines
curl -fLO --resolve 'raw.githubusercontent.com:443:2a04:4e42::133' https://raw.githubusercontent.com/bohanyang/debi/master/debi.sh
or wget:
wget -O debi.sh https://raw.githubusercontent.com/bohanyang/debi/master/debi.sh
@@ -74,6 +71,7 @@ Otherwise, you can run this command to revert all changes made by the script:
* `--interface <string>` Manually select a network interface, e.g. eth1
* `--ethx` Disable *Consistent Network Device Naming* to get interface names like *ethX* back
* `--ip <string>` Disable the auto network config (DHCP) and configure a static IP address, e.g. `10.0.0.2`, `1.2.3.4/24`, `2001:2345:6789:abcd::ef/48`
* `--static-ipv4` Disable the auto network config (DHCP) and configure with the current IPv4 address and gateway detected automatically
* `--netmask <string>` e.g. `255.255.255.0`, `ffff:ffff:ffff:ffff::`
* `--gateway <string>` e.g. `10.0.0.1`, `none` if no gateway
* `--dns '8.8.8.8 8.8.4.4'`
+18 -4
View File
@@ -156,7 +156,7 @@ set_debian_version() {
set_suite bookworm
;;
13|trixie|testing)
set_suite bookworm
set_suite trixie
;;
sid|unstable)
set_suite sid
@@ -196,8 +196,9 @@ interface=auto
ip=
netmask=
gateway=
dns='8.8.8.8 8.8.4.4'
dns6='2001:4860:4860::8888 2001:4860:4860::8844'
dns='1.1.1.1 1.0.0.1'
dns6='2606:4700:4700::1111 2606:4700:4700::1001'
dns10='1.1.1.1 2606:4700:4700::1111'
hostname=
network_console=false
set_debian_version 12
@@ -274,6 +275,14 @@ while [ $# -gt 0 ]; do
mirror_host=mirrors.tuna.tsinghua.edu.cn
ntp=time.amazonaws.cn
;;
--static-ipv4)
ip=$(ip r get 1.1.1.1 | awk '/src/ {print $7}')
gateway=$(ip r get 1.1.1.1 | awk '/via/ {print $3}')
_cidr=$(ip -o -f inet addr show | grep -w "$ip" | awk '{print $4}' | cut -d'/' -f2)
ip="$ip/$_cidr"
hostname=$(hostname)
interface=$(ip r get 1.1.1.1 | awk '/dev/ {print $5}')
;;
--interface)
interface=$2
shift
@@ -588,6 +597,10 @@ EOF
echo 'd-i netcfg/confirm_static boolean true' | $save_preseed
}
[ -z "$ip" ] && {
echo "d-i netcfg/get_nameservers string $dns10" | $save_preseed
}
if [ -n "$hostname" ]; then
echo "d-i netcfg/hostname string $hostname" | $save_preseed
hostname=debian
@@ -865,7 +878,8 @@ EOF
[ "$bbr" = true ] && in_target '{ echo "net.core.default_qdisc=fq"; echo "net.ipv4.tcp_congestion_control=bbr"; } > /etc/sysctl.d/bbr.conf'
[ -n "$cidata" ] && in_target 'echo "{ datasource_list: [ NoCloud ], datasource: { NoCloud: { fs_label: ~ } } }" > /etc/cloud/cloud.cfg.d/99_debi.cfg'
[ -n "$cidata" ] && in_target 'echo "{ datasource_list: [ NoCloud ], datasource: { NoCloud: { fs_label: ~ } } }" > /etc/cloud/cloud.cfg.d/99_mandate_nocloud.cfg'
[ -n "$cidata" ] && in_target 'printf "%s\n%s\n" "policy: disabled" "datasource: NoCloud" > /etc/cloud/ds-identify.cfg'
late_command='true'
[ -n "$in_target_script" ] && late_command="$late_command; in-target sh -c '$in_target_script'"