mirror of
https://github.com/bohanyang/debi.git
synced 2026-09-26 22:16:11 +00:00
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>
This commit is contained in:
co-authored by
Anonymous <>
Brent, Yang Bohan <youthdna@live.com>
parent
8e779c7999
commit
4807410541
@@ -71,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
|
* `--interface <string>` Manually select a network interface, e.g. eth1
|
||||||
* `--ethx` Disable *Consistent Network Device Naming* to get interface names like *ethX* back
|
* `--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`
|
* `--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::`
|
* `--netmask <string>` e.g. `255.255.255.0`, `ffff:ffff:ffff:ffff::`
|
||||||
* `--gateway <string>` e.g. `10.0.0.1`, `none` if no gateway
|
* `--gateway <string>` e.g. `10.0.0.1`, `none` if no gateway
|
||||||
* `--dns '8.8.8.8 8.8.4.4'`
|
* `--dns '8.8.8.8 8.8.4.4'`
|
||||||
|
|||||||
@@ -274,6 +274,14 @@ while [ $# -gt 0 ]; do
|
|||||||
mirror_host=mirrors.tuna.tsinghua.edu.cn
|
mirror_host=mirrors.tuna.tsinghua.edu.cn
|
||||||
ntp=time.amazonaws.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)
|
||||||
interface=$2
|
interface=$2
|
||||||
shift
|
shift
|
||||||
|
|||||||
Reference in New Issue
Block a user