OpenSDE Packages Database (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
1.9 KiB

  1. #!/bin/bash
  2. # --- T2-COPYRIGHT-NOTE-BEGIN ---
  3. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  4. #
  5. # T2 SDE: package/.../iproute2/dumpnetcfg.sh
  6. # Copyright (C) 2004 - 2006 The T2 SDE Project
  7. #
  8. # More information can be found in the files COPYING and README.
  9. #
  10. # This program is free software; you can redistribute it and/or modify
  11. # it under the terms of the GNU General Public License as published by
  12. # the Free Software Foundation; version 2 of the License. A copy of the
  13. # GNU General Public License can be found in the file COPYING.
  14. # --- T2-COPYRIGHT-NOTE-END ---
  15. echo
  16. echo "# IP-Tables configuration"
  17. while read line; do
  18. [ -z "${line##\**}" ] && table="${line#\*}"
  19. [ -z "${line##-A*}" ] && echo iptables -t $table $line
  20. done < <( iptables-save )
  21. echo
  22. echo "# Link Configuration"
  23. ip link | awk -- '
  24. BEGIN {
  25. f["ARP"] = "on";
  26. f["MULTICAST"] = "on";
  27. f["ALLMULTI"] = "off";
  28. f["PROMISC"] = "off";
  29. f["DYNAMIC"] = "off";
  30. a["00:00:00:00:00:00"] = 1;
  31. a["ff:ff:ff:ff:ff:ff"] = 1;
  32. }
  33. /^[0-9]/ {
  34. if ( command ) print command updown;
  35. interface = $2;
  36. sub(":", "", interface);
  37. command = "ip link set " interface;
  38. updown = " down";
  39. if ( match($3, "[^A-Z]UP[^A-Z]") ) updown = " up";
  40. for ( field in f ) {
  41. val = f[field];
  42. if ( match($3, "[^A-Z]" field "[^A-Z]") ) val = "on";
  43. if ( match($3, "[^A-Z]NO" field "[^A-Z]") ) val = "off";
  44. if ( val != f[field] && val != "auto" ) {
  45. command = command " " tolower(field) " " val;
  46. }
  47. }
  48. if ( $4 == "mtu" ) {
  49. command = command " mtu " $5;
  50. }
  51. }
  52. /^ *link\// {
  53. if ( ! a[$2] ) command = command " address " $2;
  54. if ( ! a[$4] ) command = command " broadcast " $4;
  55. }
  56. END {
  57. if ( command ) print command updown;
  58. }
  59. '
  60. echo
  61. echo "# IPv4 Address Configuration"
  62. ip addr | grep '^ *inet ' | sed 's, *inet,ip addr add,; s,\(.*\) ,\1 dev ,'
  63. echo
  64. echo "# IPv4 Route Configuration"
  65. ip route | grep -v ' scope link ' | sed 's,^,ip route add ,'
  66. echo