Skip to content

Commit

Permalink
Fix getting default gateway (#16)
Browse files Browse the repository at this point in the history
This fix a nasty bug that only occurs when you have a mac address that
is composed of all zeroes (at least 2) before having a non numeric character (A-F)
  • Loading branch information
drizzt committed Jun 13, 2016
1 parent 182e92c commit 9f7b638
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion vps2arch
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ configure_network() {
local gateway dev ip

read -r dev gateway <<-EOF
$(awk '$2 == 00000000 { ip = strtonum(sprintf("0x%s", $3));
$(awk '$2 == "00000000" { ip = strtonum(sprintf("0x%s", $3));
printf ("%s\t%d.%d.%d.%d", $1,
rshift(and(ip,0x000000ff),00), rshift(and(ip,0x0000ff00),08),
rshift(and(ip,0x00ff0000),16), rshift(and(ip,0xff000000),24)) }' < /proc/net/route)
Expand Down

0 comments on commit 9f7b638

Please sign in to comment.