How to configure Static IP address in Linux and Unix

  • Dan St.André

    Thank you for this clearly written description of static IP configuration. I would be interested in a follow-up article that discusses static IP for a walk-about laptop. Specifically, I need STATIC_IP_A when I’m part of NETWORK_1, STATIC_IP_B when I’m part of NETWORK_2,…, STATIC_IP_Z when I’m part of NETWORK_N, and dynamic IP address the rest of the time.

    • SK

      I am afraid we couldn’t do that in Linux with single network interface card. However, It is possible to do it with manageable network switch. We could create different vlans and assign different set of IP addresses for each vlan.

  • Dan St.André

    Is there some way to:
    1. detect which network is available
    2. run one or more scripts that are per-network specific
    3. the scripts would used DHCP or static-IP as needed
    4. might need to connect-inspect-bounce-configure

    While I would like to detect wired & wireless and launch appropriate scripts, wireless is by far the most common and most useful.

    I am trying, with poor success, to find the network connection hooks that I could use to launch my own scripts.


    ASIDE — I use Linux Mint 17.3 from the Ubuntu family of distributions.

  • SK

    As I understood..
    Create a script..First detect which network available on system. And show available network status like up or down and also show Static ip or DHCP IP.
    Something like-
    Available—Status—DH/ ST——–IP
    eth0. Up. dhcp. *******
    wlan0. Down. —- ——-
    Second option detect network configuration – Enter Available network name- when we enter name , then again show option set ip address dhcp or static-
    -> Input dhcp (auto set dhcp ip)
    -> Input static (Then auto set static ip) or
    Enter -> Ipaddress-
    -> netmask-
    -> gateway-
    -> dns1
    -> dns2

    I think when we are connected both network (wlan & lan) ..the first priority of wireless network if wireless network down then automatic up lan port…