Manipulate Android's network configuration file

Android network and proxy configuration is stored in a file named ipconfig.txt (often found in /data/misc/ethernet/ or /data/misc/wifi/), and does not contain plain-text configuration, despite its extension.

Packed Format

See com.android.server.net.IpConfigStore.

Packed Format Examples

Version 1: STATIC ipAssignment

      00000000: 0000 0001 000c 6970 4173 7369 676e 6d65  ......ipAssignme
      00000010: 6e74 0006 5354 4154 4943 000b 6c69 6e6b  nt..STATIC..link
      00000020: 4164 6472 6573 7300 0c31 3732 2e33 312e  Address..172.31.
      00000030: 302e 3235 3400 0000 1800 0767 6174 6577  0.254......gatew
      00000040: 6179 000a 3137 322e 3331 2e30 2e31 0003  ay..172.31.0.1..
      00000050: 646e 7300 0a31 3732 2e33 312e 302e 3700  dns..172.31.0.7.
      00000060: 0364 6e73 000a 3137 322e 3331 2e30 2e38  .dns..172.31.0.8
      00000070: 000d 7072 6f78 7953 6574 7469 6e67 7300  ..proxySettings.
      00000080: 044e 4f4e 4500 0269 6400 0000 0000 0365  .NONE..id......e
      00000090: 6f73                                     os

      version: 1
      00000000: 0000 0001                                ....

      ipAssignment: STATIC
      00000004: 000c 6970 4173 7369 676e 6d65 6e74 0006  ..ipAssignment..
      00000014: 5354 4154 4943                           STATIC

      linkAddress: 172.31.0.254/24
      0000001a: 000b 6c69 6e6b 4164 6472 6573 7300 0c31  ..linkAddress..1
      0000002a: 3732 2e33 312e 302e 3235 3400 0000 18    72.31.0.254....

      gateway: 172.31.0.1
      00000039: 0007 6761 7465 7761 7900 0a31 3732 2e33  ..gateway..172.3
      00000049: 312e 302e 31                             1.0.1

      dns: 172.31.0.7
      0000004e: 0003 646e 7300 0a31 3732 2e33 312e 302e  ..dns..172.31.0.
      0000005e: 37                                       7

      dns: 172.31.0.8
      0000005f: 0003 646e 7300 0a31 3732 2e33 312e 302e  ..dns..172.31.0.
      0000006f: 38                                       8

      proxySettings: NONE
      00000070: 000d 7072 6f78 7953 6574 7469 6e67 7300  ..proxySettings.
      00000080: 044e 4f4e 45                             .NONE

      id: 0
      00000085: 0002 6964 0000 0000                      ..id....

      eos
      0000008f: 0003 656f 73                             ..eos
    

Version 2: DHCP ipAssignment

      00000000: 0000 0002 000c 6970 4173 7369 676e 6d65  ......ipAssignme
      00000010: 6e74 0004 4448 4350 0002 6964 0000 0000  nt..DHCP..id....
      00000020: 0003 656f 73                             ..eos

      version: 2
      00000000: 0000 0002                                ....

      ipAssignment: DHCP
      00000004: 000c 6970 4173 7369 676e 6d65 6e74 0004  ..ipAssignment..
      00000014: 4448 4350                                DHCP

      id: 0
      00000018: 0002 6964 0000 0000                      ..id....

      eos
      00000020: 0003 656f 73                             ..eos
    

Version 3: STATIC ipAssignment and STATIC proxySettings

      00000000: 0000 0003 000c 6970 4173 7369 676e 6d65  ......ipAssignme
      00000010: 6e74 0006 5354 4154 4943 000b 6c69 6e6b  nt..STATIC..link
      00000020: 4164 6472 6573 7300 0c31 3732 2e33 312e  Address..172.31.
      00000030: 302e 3235 3400 0000 1800 0767 6174 6577  0.254......gatew
      00000040: 6179 0000 0000 0000 0001 000a 3137 322e  ay..........172.
      00000050: 3331 2e30 2e31 0003 646e 7300 0a31 3732  31.0.1..dns..172
      00000060: 2e33 312e 302e 3700 0364 6e73 000a 3137  .31.0.7..dns..17
      00000070: 322e 3331 2e30 2e38 000d 7072 6f78 7953  2.31.0.8..proxyS
      00000080: 6574 7469 6e67 7300 0653 5441 5449 4300  ettings..STATIC.
      00000090: 0970 726f 7879 486f 7374 000a 3137 322e  .proxyHost..172.
      000000a0: 3331 2e30 2e34 0009 7072 6f78 7950 6f72  31.0.4..proxyPor
      000000b0: 7400 000c 3800 0269 6400 0465 7468 3000  t...8..id..eth0.
      000000c0: 0365 6f73                                .eos

      version: 3
      00000000: 0000 0003                                ....

      ipAssignment: STATIC
      00000004: 000c 6970 4173 7369 676e 6d65 6e74 0006  ..ipAssignment..
      00000014: 5354 4154 4943                           STATIC

      linkAddress: 172.31.0.254/24
      0000001a: 000b 6c69 6e6b 4164 6472 6573 7300 0c31  ..linkAddress..1
      0000002a: 3732 2e33 312e 302e 3235 3400 0000 18    72.31.0.254....

      gateway: 172.31.0.1
      00000039: 0007 6761 7465 7761 7900 0000 0000 0000  ..gateway.......
      00000049: 0100 0a31 3732 2e33 312e 302e 31         ...172.31.0.1

      dns: 172.31.0.7
      00000056: 0003 646e 7300 0a31 3732 2e33 312e 302e  ..dns..172.31.0.
      00000066: 37                                       7

      dns: 172.31.0.8
      00000067: 0003 646e 7300 0a31 3732 2e33 312e 302e  ..dns..172.31.0.
      00000077: 38                                       8

      proxySettings: STATIC
      00000078: 000d 7072 6f78 7953 6574 7469 6e67 7300  ..proxySettings.
      00000088: 0653 5441 5449 43                        .STATIC

      proxyHost: 172.31.0.4
      0000008f: 0009 7072 6f78 7948 6f73 7400 0a31 3732  ..proxyHost..172
      0000009f: 2e33 312e 302e 34                        .31.0.4

      proxyPort: 3128
      000000a6: 0009 7072 6f78 7950 6f72 7400 000c 38    ..proxyPort...8

      id: eth0
      000000b5: 0002 6964 0004 6574 6830                 ..id..eth0

      eos
      000000bf: 0003 656f 73                             ..eos
    

Unpacked Format

The ipconfigstore utility may be used to unpack ipconfig.txt. Be advised that the version pair and eos terminator are not recognised when unpacked.

Unpacked Format Examples

Version 1: STATIC ipAssignment

      ipAssignment: STATIC
      linkAddress: 172.31.0.254/24
      gateway: 172.31.0.1
      dns: 172.31.0.7
      dns: 172.31.0.8
      proxySettings: NONE
      id: 0
    

Version 2: DHCP ipAssignment

      ipAssignment: DHCP
      id: 0
    

Version 3: STATIC ipAssignment and STATIC proxySettings

      ipAssignment: STATIC
      linkAddress: 172.31.0.254/24
      gateway: 172.31.0.1
      dns: 172.31.0.7
      dns: 172.31.0.8
      proxySettings: STATIC
      proxyHost: 172.31.0.4
      proxyPort: 3128
      id: eth0
    

Pack & Unpack

Clone the ipconfigstore repository (or download the archive) and execute make.

ipconfigstore Usage

       -p VERSION    Pack IP configuration
       -u            Unpack IP configuration
    

Packing ipconfig.txt

      $ cat samples/v1/static.conf
      ipAssignment: STATIC
      linkAddress: 172.31.0.254/24
      gateway: 172.31.0.1
      dns: 172.31.0.7
      dns: 172.31.0.8
      proxySettings: NONE
      id: 0

      $ ipconfigstore -p 1 < samples/v1/static.conf > /tmp/ipconfig.txt

      $ xxd /tmp/ipconfig.txt
      00000000: 0000 0001 000c 6970 4173 7369 676e 6d65  ......ipAssignme
      00000010: 6e74 0006 5354 4154 4943 000b 6c69 6e6b  nt..STATIC..link
      00000020: 4164 6472 6573 7300 0c31 3732 2e33 312e  Address..172.31.
      00000030: 302e 3235 3400 0000 1800 0767 6174 6577  0.254......gatew
      00000040: 6179 000a 3137 322e 3331 2e30 2e31 0003  ay..172.31.0.1..
      00000050: 646e 7300 0a31 3732 2e33 312e 302e 3700  dns..172.31.0.7.
      00000060: 0364 6e73 000a 3137 322e 3331 2e30 2e38  .dns..172.31.0.8
      00000070: 000d 7072 6f78 7953 6574 7469 6e67 7300  ..proxySettings.
      00000080: 044e 4f4e 4500 0269 6400 0000 0000 0365  .NONE..id......e
      00000090: 6f73                                     os

      $ adb push /tmp/ipconfig.txt /data/misc/ethernet/ipconfig.txt
    

Unpacking ipconfig.txt

      $ adb pull /data/misc/ethernet/ipconfig.txt /tmp/ipconfig.txt

      $ xxd /tmp/ipconfig.txt
      00000000: 0000 0003 000c 6970 4173 7369 676e 6d65  ......ipAssignme
      00000010: 6e74 0006 5354 4154 4943 000b 6c69 6e6b  nt..STATIC..link
      00000020: 4164 6472 6573 7300 0c31 3732 2e33 312e  Address..172.31.
      00000030: 302e 3235 3400 0000 1800 0767 6174 6577  0.254......gatew
      00000040: 6179 0000 0000 0000 0001 000a 3137 322e  ay..........172.
      00000050: 3331 2e30 2e31 0003 646e 7300 0a31 3732  31.0.1..dns..172
      00000060: 2e33 312e 302e 3700 0364 6e73 000a 3137  .31.0.7..dns..17
      00000070: 322e 3331 2e30 2e38 000d 7072 6f78 7953  2.31.0.8..proxyS
      00000080: 6574 7469 6e67 7300 0653 5441 5449 4300  ettings..STATIC.
      00000090: 0970 726f 7879 486f 7374 000a 3137 322e  .proxyHost..172.
      000000a0: 3331 2e30 2e34 0009 7072 6f78 7950 6f72  31.0.4..proxyPor
      000000b0: 7400 000c 3800 0269 6400 0465 7468 3000  t...8..id..eth0.
      000000c0: 0365 6f73                                .eos

      $ ipconfigstore -u 3 < /tmp/ipconfig.txt > /tmp/ipconfig.conf

      $ cat /tmp/ipconfig.conf
      ipAssignment: STATIC
      linkAddress: 172.31.0.254/24
      gateway: 172.31.0.1
      dns: 172.31.0.7
      dns: 172.31.0.8
      proxySettings: STATIC
      proxyHost: 172.31.0.4
      proxyPort: 3128
      id: eth0