Announcement

Collapse
No announcement yet.

Scripts to set up the interfaces

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Scripts to set up the interfaces

    Im in need of running scripts when i get to college and reset em when i get to my room.
    I need static ip, proxy address , netmask and DNS to be set.. IN COLLEGE (wired & wireless)
    When i come back to the room.. i need both the interfaces to be in dhcp

    These are the scripts ive written.. doesnt work completely.. doesnt set the default gateway

    wired - coll
    Code:
    sudo -S ifconfig wlan0 down
    sudo ifconfig eth0 up
    sudo ifconfig eth0 address 192.168.13.61 netmask addr 255.255.0.0
    wireless - coll
    Code:
    sudo -S ifconfig eth0 down
    sudo modprobe ndiswrapper
    sudo ifconfig wlan0 up
    sudo ifconfig wlan0 address 192.168.14.61 netmask addr 255.255.0.0
    sudo iwconfig wlan0 essid any
    kwifimanager
    I do not know how to set the DNS and also the default gateway addresses
    another issue i face while i use knetworkmanager to this is.. i need to disable eth0 whenever i need to use wlan0 to use the net.

    I do not know about setting dhcp as well.. please throw some light on that as well.

    Please do help me with the scripts..

    Thanks

    #2
    Re: Scripts to set up the interfaces

    Can anyone please tell me how to set the Default gateway for an interface.. ?
    Also how do i set the DNS address..
    I need commands to do these.. as i need to include them in a script
    Thanks

    Comment


      #3
      Re: Scripts to set up the interfaces

      Try this:

      ip route add default via 1.2.3.254 Set default gateway to 1.2.3.254

      I think that you will have to do the dns change by swapping resolv.conf files like this:

      sudo cp /etc/resolv.room /etc/resolv.conf (and vice versa for resolv.class)
      sudo /etc/init.d/network restart (restart networking)

      The format for the resolv.conf file is as follows:

      -------------------
      # /etc/resolv.conf - DNS setup file
      #
      # possible entries are:
      #
      # domain <domain> Local domain name. If not present, the
      # gethostbyname syscall is used to
      # determine the local domain name.
      #
      # search <list_of_domains> Search list for hostname lookup.
      # The search list is normally determined
      # from the local domain name but it
      # can be set to a list of domains.
      #
      # nameserver <ip_addr> Define which server to contact
      # for DNS lookups. If there are
      # multiple nameserver lines (Max=3),
      # they are queried in the listed order.
      #
      # !!! Automatically generated by LISA from /etc/system.cnf. Do not edit !!!
      #
      #domain
      #search
      nameserver 192.168.0.1
      ___________________

      So in resolv.room and resolv.class, you will need to have the appropriate nameserver entries. I think that some of the networking apps allow profiles where you could capture this that might make it easier. I am not a knetworkmanager fan. One of the smarter folks here may have a better idea, but I believe this will work.

      Comment

      Working...
      X