How to manually assign extra ips to a server?

How to manually assign extra ips to a server?

rEDrED Member

Hi,

I got dedi's from wholesaleinternet and joe's but didnt knew that we have to configure the extra ips ourselves..

I googled but there doesn't seem to be a proper guide on how to add the ips manually. From what I have googled so far it seems we have to copy the ifcfg-eth0 and ifcfg-lo and edit them and add the addional ip, netmask and gateway, one file for each new ip save and upload it to the same directory.

Some site say we have to rename it has "ifcfg-eth0:1", "ifcfg-eth0:2" ... etc and some say "ifcfg-lo:1", "ifcfg-lo:2" etc..

I am sure only one of this is correct.. so which one is it? Or is there something else am I missing?

Tagged:

Comments

  • GalaxyHostPlusGalaxyHostPlus Member, Provider
    edited March 18

    ifcfg-eth0:1

    DEVICE="eth0:1"
    BOOTPROTO="static"
    IPADDR="xxx.xxx.xx.xx"
    NETMASK="255.255.255.xxx"
    ONBOOT="yes"
    

    Should be easy to do. just add your IPv4 to IPADDR and Correct Netmask for your IP

    Than simply restart network

    GalaxyHostPlus / New KVM Plans from $7 can be found HERE

  • rEDrED Member
    edited March 18

    @GalaxyHostPlus said: ifcfg-eth0:1

    DEVICE="eth0:1"
    BOOTPROTO="static"
    IPADDR="xxx.xxx.xx.xx"
    NETMASK="255.255.255.xxx"
    ONBOOT="yes"
    

    Should be easy to do. just add your IPv4 to IPADDR and Correct Netmask for your IP

    Than simply restart network

    Is it okay if I just copy this as template and edit? Or there could be other things I might need to add?

    Also here https://godaddy.com/help/adding-ip-addresses-to-your-linux-server-loopback-8505

    It says to edit the "ifcfg-lo:[X]" file not the "ifcfg-eth0:1" file...

    EDIT: this seems right https://in.godaddy.com/help/adding-ip-addresses-to-your-linux-server-traditional-6238

  • GalaxyHostPlusGalaxyHostPlus Member, Provider

    Hi,

    Usually it's eth0 for public network. Well this cause test ifcfg-eth0:1 if works if not try with ifcfg-lo but in most causes eth0 is main NIC

    GalaxyHostPlus / New KVM Plans from $7 can be found HERE

    Thanked by 1rED
  • cochoncochon Member

    @rED said: Hi,

    but didnt knew that we have to configure the extra ips ourselves..

    Different Linux distributions have different ways of implementing this, what distribution (and version) are you using. Also are the additional IPs you've been allocated in a range or all different ?

    Thanked by 1rED
  • rEDrED Member

    @GalaxyHostPlus said: Hi,

    Usually it's eth0 for public network. Well this cause test ifcfg-eth0:1 if works if not try with ifcfg-lo but in most causes eth0 is main NIC

    Hi,

    thanks for you help. I see, I did it with ifcfg-eth0:1 etc but I got the following error

    error in ifcfg-eth0:3: invalid alias number . . . error in ifcfg-eth0:11: invalid alias number

    Got the same error till 11 as you can see, what can be the cause? there are total 13 ips I have, 1 is autoconfigured(main ip).

    Whats interesting is there are errors for eth0:1 and eth0:2 meaning they were configured correctly? I just did the same thing with the rest but only the above 2 worked.

    @cochon said:

    @rED said: Hi,

    but didnt knew that we have to configure the extra ips ourselves..

    Different Linux distributions have different ways of implementing this, what distribution (and version) are you using. Also are the additional IPs you've been allocated in a range or all different ?

    I am using CentOS 6 64.

    Yes they are all in same range. Total are 13 ips.

    Thanks

  • cochoncochon Member

    @rED said: I am using CentOS 6 64.

    The 'conventional' and simple way in CentOS is to create an ifcfg range file e.g. /etc/sysconfig/network-scripts/ifcfg-eth0-range containing:

    IPADDR_START=192.168.123.2 IPADDR_END=192.168.123.15 CLONENUM_START=1

    On restart that should create a sequence of interfaces eth0:1, eth0:2 etc. no need for lots of separate files.

    NOTE: substitute eth0 for your real internet Ethernet device (eth0 is normal for CentOS 6), and your first and last addresses as appropriate.

    Thanked by 3rED WSS doughmanes
  • @rED said: thanks for you help. I see, I did it with ifcfg-eth0:1 etc but I got the following error

    error in ifcfg-eth0:3: invalid alias number . . . error in ifcfg-eth0:11: invalid alias number

    Got the same error till 11 as you can see, what can be the cause? there are total 13 ips I have, 1 is autoconfigured(main ip).

    Whats interesting is there are errors for eth0:1 and eth0:2 meaning they were configured correctly? I just did the same thing with the rest but only the above 2 worked.

    Was the device name incremented for each alias?

    If the devices show up in ip addr or ifconfig, they should be good.

    For reference: https://www.cyberciti.biz/faq/linux-creating-or-adding-new-network-alias-to-a-network-card-nic/

    Thanked by 1rED
  • rEDrED Member

    @cochon said:

    @rED said: I am using CentOS 6 64.

    The 'conventional' and simple way in CentOS is to create an ifcfg range file e.g. /etc/sysconfig/network-scripts/ifcfg-eth0-range containing:

    IPADDR_START=192.168.123.2 IPADDR_END=192.168.123.15 CLONENUM_START=1

    On restart that should create a sequence of interfaces eth0:1, eth0:2 etc. no need for lots of separate files.

    NOTE: substitute eth0 for your real internet Ethernet device (eth0 is normal for CentOS 6), and your first and last addresses as appropriate.

    This really look so simple, I think I'll delete the current files and try this one now. I didn't understand your last line though, what do you mean by substitute eth0 for your real internet Ethernet device and how to do so?

    @flatland_spider said:

    Was the device name incremented for each alias?

    If the devices show up in ip addr or ifconfig, they should be good.

    For reference: https://www.cyberciti.biz/faq/linux-creating-or-adding-new-network-alias-to-a-network-card-nic/

    Yes the device name was incremented, see the pic and let me know if its correct. I've incremented acc to device name..

    when I run ip addr I am only able to see 4 ips(it means upto eth0:2 all is correct)

  • rEDrED Member
    edited March 18

    I tried the conventional method as said above but it didn't create any files.. I am not sure If I used the Vim correctly..

    i copied the txt and pasted into "ifcfg-eth0-range0". Pressed "Esc" then ":wq".

    I refreshed filezilla to see any new files got created but there no files(I deleted the old files which I created and uploaded manually)...

    EDIT: I forgot to use service network restart

    DAMNN IT WORKED thanks a ton man!!!!

  • bsdguybsdguy Member

    forget about "lo". That's always the local interface (127.0.0.1).

    If you have multiple non-local interfaces and are not sure about which one to use, do sudo dmesg | grep eth and you'll find what the OS knows about. The relevant result lines look like this: [ 2.299703] e1000 0000:00:03.0 eth0: Intel(R) PRO/1000 Network Connection [ 2.759446] e1000 0000:00:08.0 eth1: Intel(R) PRO/1000 Network Connection [ 32.556293] e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: ...

    (emphasis is mine)

    Next you can first test by e.g. ifconfig eth0 1.2.3.4 netmask 255.255.255.0 using, of course your proper address and the netmask given by your provider (which is almost always the above).

    My favourite prime number is 42. - Really cool people have their home network on a plastic router and a 0.0.0.0/4. Could be /2 but it's always good to have some reserves ...

    Thanked by 1rED
  • I remember when I first figured out how to do this lol

  • FalzoFalzo Member

    Netcup KVM DE: 2vC 2GB 40GB SAS 2,99€ or 2xE5 6GB 320GB SAS 6,99€ | 5€ off 1st order: 36nc14892246254 / 36nc14892246257 UltraVPS.eu KVM in US/NL/DE, 15% off 6months: 2GB & SSD from 4,5€ or 1GB & HDD from 3€

  • msg7086msg7086 Member

    Is it just me that thinks OP should mention whatever distribution being used?

    With a systemd-based dist, it's as simple as editing the network file and let systemd-networkd take care of the rest.

  • WSSWSS Member

    He did. Eventually. CentOS 6.

    Starting udev and waiting for devices to settle...

  • bsdguybsdguy Member

    @msg7086 said: Is it just me that thinks OP should mention whatever distribution being used?

    With a systemd-based dist, it's as simple as editing the network file and let systemd-networkd take care of the rest.

    Same pre-shitstemd

    @WSS said: He did. Eventually. CentOS 6.

    Side question: Is centos systemd sullied?

    My favourite prime number is 42. - Really cool people have their home network on a plastic router and a 0.0.0.0/4. Could be /2 but it's always good to have some reserves ...

  • WSSWSS Member

    @bsdguy said: Side question: Is centos systemd sullied?

    Not 6, but it's also older than dirt.

    For those who aren't aware, systemd is written by the same turd who gave us pulseaudio- the reason so many people think Linux doesn't support audio. He's a pile of dogshit who thinks design, and POSIX is a bad idea.

    I hate you, Lennart Poettering. I know you Google yourself.

    Starting udev and waiting for devices to settle...

  • bsdguybsdguy Member

    @WSS

    I'm 99.9% certain that he a paid rat. If someone would kill him I'd throw a party.

    My favourite prime number is 42. - Really cool people have their home network on a plastic router and a 0.0.0.0/4. Could be /2 but it's always good to have some reserves ...

    Thanked by 2WSS Ole_Juul
  • WSSWSS Member

    I just want him to be unable to commit code. For him to sit there and watch people fix, then deprecate everything he's ever done would be the ultimate "FU".

    Starting udev and waiting for devices to settle...

    Thanked by 1vimalware
  • MasonRMasonR Member
    edited March 19

    Is there a way to assign additional IP addresses without using aliases? My main issue is if the main (non-aliased) IP gets DDoS'ed and null routed, basically the whole NIC is defunct until the null route is lifted. Only way I can see to remedy the situation is to use IPMI to assign a different IP as the primary unless someone knows some other way?

    Using Ubuntu, btw.

  • WSSWSS Member

    Pay for another NIC and port to plug it into?

    Starting udev and waiting for devices to settle...

  • MasonRMasonR Member

    @WSS said: Pay for another NIC and port to plug it into?

    Was hoping for a no-cost option :P but yeah that's a route I might consider

  • WSSWSS Member

    You're using a physical NIC one way or another. You can setup a virtual MAC address changing eth0 into a bridge, but it's still likely to get your port disabled/null routed, and with no default gateway available, you're kind of stuck.

    Starting udev and waiting for devices to settle...

    Thanked by 1MasonR
  • rEDrED Member
    edited March 19

    thanks guys... although my other dedi has 2 ip ranges and 2 diff netmasks and gateways

    so I am guessing I have to change the new ip-range filename so it doesn't match with the previous and start from no. of ips configured +1. Is this correct?

    this one is centos 6 64 as well

    EDIT: damn it worked as well haha, just did the above things as I said and worked perfectly.

    Thanks a lot guys!

    Cheers!!!!!

  • teamaccteamacc Member

    @WSS said: I hate you, Lennart Poettering. I know you Google yourself.

    I work for this company

  • rEDrED Member

    damn I did a OS reinstall and all SHIT is gone... Didn't knew that.. lesson learned.

    so gotta configure again right?

  • rED said: so gotta configure again right?

    No of course not, just run rm -rf / to restore the configuration.

    Seriously, get a basic grasp of how Linux works before exposing a dedicated server to the internet. Servers are not toys, they can be used for really bad things, and you could end up being responsible.

    Thanked by 2rED flatland_spider
  • rEDrED Member

    @jgillich said:

    rED said: so gotta configure again right?

    No of course not, just run rm -rf / to restore the configuration.

    Seriously, get a basic grasp of how Linux works before exposing a dedicated server to the internet. Servers are not toys, they can be used for really bad things, and you could end up being responsible.

    I am sorry but you are right, I really need to learn at least the basics of how this thing works and learn some basic commands, but I don't know where to start or what to search...

  • bsdguybsdguy Member

    @rED said: thanks guys... although my other dedi has 2 ip ranges and 2 diff netmasks and gateways

    Aliases usually are within the same network but that's not a must. One can indeed have aliases from different networks on 1 public interface. But from what I see here (re. your knowledge level) I'd strongly suggest to stay away from that.

    My favourite prime number is 42. - Really cool people have their home network on a plastic router and a 0.0.0.0/4. Could be /2 but it's always good to have some reserves ...

    Thanked by 1rED
  • rEDrED Member

    I wanted to try rm -rf / but it seems it wipes all data(I googled) and restores it to default and by default I had only 1 ip assigned so its not useful.

    So, I am getting the following error when trying to reconfig the range file, I did the exact same thing as I did before but not sure why this came up...

    : integer expression expecteds/ifup-aliases: line 323: [: 194 : integer expression expecteds/ifup-aliases: line 330: [: 194

    I checked again if the file has string or anything but all seemed okay.

  • FalzoFalzo Member

    rED said: I wanted to try rm -rf / but it seems it wipes all data(I googled) and restores it to default

    Netcup KVM DE: 2vC 2GB 40GB SAS 2,99€ or 2xE5 6GB 320GB SAS 6,99€ | 5€ off 1st order: 36nc14892246254 / 36nc14892246257 UltraVPS.eu KVM in US/NL/DE, 15% off 6months: 2GB & SSD from 4,5€ or 1GB & HDD from 3€

  • rEDrED Member

    @Falzo said:

    rED said: I wanted to try rm -rf / but it seems it wipes all data(I googled) and restores it to default

    100% sirius black

  • yum install -y easy-ip-manager && ip-add pool xxx.xxx.xxx.xxx --permanent && reboot

    Thanked by 1rED
  • rEDrED Member
    edited March 21

    @deadbeef said: yum install -y easy-ip-manager && ip-add pool xxx.xxx.xxx.xxx --permanent && reboot

    No package easy-ip-manager available.

    Thanked by 1deadbeef
  • @rED said:

    @deadbeef said: yum install -y easy-ip-manager && ip-add pool xxx.xxx.xxx.xxx --permanent && reboot

    No package easy-ip-manager available.

    It was a joke :D

  • rEDrED Member
    edited March 21

    @rED said:

    No package easy-ip-manager available.

    It was a joke :D

    lol ggwp

    Thanked by 1deadbeef
  • WSSWSS Member

    This is why managed service providers exist.

    Starting udev and waiting for devices to settle...

    Thanked by 1rED
  • rEDrED Member

    @WSS said: This is why managed service providers exist.

    Exactly, but I have learnt a lot which I never could have if I hadn't had bugdet issues haha..

Sign In or Register to comment.