Set static IP

Sometimes its necessary that your machine gets a static IP-address. For example if you want to run a server or a other service on that machine. On Debian based machines you can do this by:

  1. Edit /etc/network/interfaces (f.e.: with nano)

    auto lo
    iface lo inet loopback
    
    auto eth0
    iface eth0 inet static
            address 192.168.88.6
            netmask 255.255.255.0
            gateway 192.168.88.1
    
    auto wlan0
    allow-hotplug wlan0
    iface wlan0 inet static
            address 192.168.99.6
            netmask 255.255.255.0
            gateway 192.168.88.1
            wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
    
    iface default inet dhcp

    In this case we set the IP fix to 192.168.88.6 for both wlan and ethernet.

  2.  Setup wireless lan settings (/etc/wpa_supplicant/wpa_supplicant.conf)
    ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
    update_config=1
    
    network={
            ssid="VERYNICENET"
            psk="PSKKEYINCLEARTEXT"
            proto=RSN
            key_mgmt=WPA-PSK
            pairwise=CCMP
            auth_alg=OPEN
    }
  3. Disable network interface (wlan / eth)
    $> sudo ifdown wlan0
    $> sudo ifdown eth0
  4. Enable it again to load changes
    $> sudo ifup wlan0
    $> sudo ifup eth0
  5. You can skip step 3 and 4 if you just reboot your machine
    $> sudo reboot

     

     

     

 

 

1 thoughts on “Set static IP

Leave a Reply

Your email address will not be published. Required fields are marked *

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.