#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2013
    Posts
    8
    Rep Power
    0

    Newbe LAMP Question


    I've set up a LAMP machine to experiment / learn from.

    OS: CentOS v6

    However, every time I restart the machine, the network IP that HTTP is running on changes.

    For example, now it is http://192.168.1.5/ but if I restart it might be, say, http://192.168.1.12/

    I would like this address to be stable. Currently, every time I fire up the machine, I have to
    ifconfig eth0 | grep inet | awk '{ print $2 }'
    to figure out what IP Apache is running on...

    - JS
  2. #2
  3. Providing fuel for space ships
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2004
    Location
    nr Edinburgh, Scotland
    Posts
    14,317
    Rep Power
    3851
    You'll need to set your IP address to be static, rather than DHCP.

    Take a look under '/etc/sysconfig/network-scripts', you'll see the network configuration script in there for your connection (e.g. ifcfg-eth0).

    Comments on this post

    • Johnny Squeaky agrees
    The No Ma'am commandments:

    1.) It is O.K. to call hooters 'knockers' and sometimes snack trays
    2.) It is wrong to be French
    3.) It is O.K. to put all bad people in a giant meat grinder
    4.) Lawyers, see rule 3
    5.) It is O.K. to drive a gas guzzler if it helps you get babes
    6.) Everyone should car pool but me
    7.) Bring back the word 'stewardesses'
    8.) Synchronized swimming is not a sport
    9.) Mud wrestling is a sport
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2013
    Posts
    8
    Rep Power
    0
    Will this interfear with my internet connection?

    By the way, if this makes any difference: my DSL modem is more or less acting as a bridge, my wi-fi and hard-wired network is through a modem connected to the DSL modem.
  6. #4
  7. They're coming to take me away

    Join Date
    Jan 2005
    Location
    Florida
    Posts
    5,087
    Rep Power
    5080
    No it won't interfere with your internet connection unless you set more than 1 device on your network to have the same static IP. When you set a static Local IP address to your device, it will keep that IP every time you restart the device.
    "I don't need to get a life. I'm a gamer. I have lots of lives!"
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2013
    Posts
    8
    Rep Power
    0
    Here is what says:
    Code:
    DEVICE=eth0
    TYPE=Ethernet
    UUID=97257198-b746-4f80-8438-eeed9c728891
    ONBOOT=yes
    NM_CONTROLLED=yes
    BOOTPROTO=dhcp
    DEFROUTE=yes
    IPV4_FAILURE_FATAL=yes
    IPV6INIT=no
    NAME="System eth0"
    HWADDR=00:19:D1:A8:25:F0
    PEERDNS=yes
    PEERROUTES=yes
    I assume that I have to change BOOTPROTO.

    The options are:

    NONE, BOOTP, and DHCP.

    Nene?

    As well, I would have to specify the IP, right?

    So...

    There is NETWORK, NETMASK, and IPADDR.

    I'm lookinf at this page, by the way: 13.2. Interface Configuration Files

    Suggestions?
  10. #6
  11. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,304
    Rep Power
    7173
    Here's an example static configuration from a Centos 6.5 server:
    Code:
    DEVICE=eth0
    BOOTPROTO=static
    IPADDR=<ip address>
    NETMASK=255.255.255.0
    ONBOOT=yes
    GATEWAY=<gateway address>
    IPV6INIT=yes
    IPV6_AUTOCONF=no
    IPV6ADDR=<ip v6 address>
    I think BOOTPROTO 'static' was deprecated in favor of BOOTPROTO 'none', although I'm not completely sure about that. Your netmask might actually be different, but if you're not sure try 255.255.255.0.

    By the way, if this makes any difference: my DSL modem is more or less acting as a bridge, my wi-fi and hard-wired network is through a modem connected to the DSL modem.
    Assuming you meant your wifi and wired networks are through a router connected to your modem, then you have it set up correctly. You won't be able to configure a static IP on a device plugged directly into your modem unless the IP was assigned to you by your ISP (or the modem is a combo router/modem).

    It's also worth noting that most routers will let you assign static IPs to specific devices via their configuration panel - the router will reserve and always hand out the same IP to that device when the device uses DHCP.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2013
    Posts
    8
    Rep Power
    0
    Originally Posted by E-Oreo
    Assuming you meant your wifi and wired networks are through a router connected to your modem, then you have it set up correctly. You won't be able to configure a static IP on a device plugged directly into your modem unless the IP was assigned to you by your ISP (or the modem is a combo router/modem).
    Yes, that's right, my terminology is off. The modem that came with my DSL service has wi-fi, but I disabled it and opted for the router I've pltermonologyugged into the DSL modem, which all my devices are connected to.

    Because of some picky problems with my printer, it has a static IP on my network. So I guess, all I need to do is assign a static IP to my server, and make the changes in the file discussed above?

    Thanks!
  14. #8
  15. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,304
    Rep Power
    7173
    For *most* consumer-grade routers, you normally only need to do one or the other, but doing both won't hurt. Also if you do only assign the IP in the configuration file, it's best to make sure the IP is outside of the range of IPs the router uses for DHCP.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  16. #9
  17. No Profile Picture
    Grumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,553
    Rep Power
    4549
    Also you may have noticed NM_CONTROLLED = yes in your eth0 config file. This indicates the device settings are controlled by the NetworkManager service, and you should either turn off NetworkManager or use it's tools to edit your network configuration.
    ======
    Doug G
    ======
    I've never been able to appreciate the sublime arrogance of folks who feel they were put on earth just to save other folks from themselves .." - Donald Hamilton

IMN logo majestic logo threadwatch logo seochat tools logo