Editing
FreeBSD Reference
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
= Manually adding and subtracting IPs from a machine = UPDATE: there are easy scripts to do all this now, see [[VPS_Management#ipadd|ipadd]] and [[VPS_Management#ipdel|ipdel]] So, let's say you want to add an IP to an existing FreeBSD system. Presumably there are other IPs already bound to the network card, so any additional ones you configure would be aliases. You would run a command like this: ifconfig em0 alias 69.55.228.10 netmask 255.255.255.0 ALWAYS triple-check these commands !!!! If you run this command without the "alias" as the third word, you will replace the existing IP on that system with this new one, and since sshd is only bound to the original IP, your session will end, and the machine will effectively be totally offline. There is no way to get it back - you would have to call the datacenter and have them powercycle it. Also, take note of the device- in this example we used em0, but perhaps on the server you'll have bge0 or possibly the nic's are reversed and the public nic is bge1. Always run <tt>ifconfig</tt> once first to see what's going on. Now, as is true with /etc/rc.conf, if the ip you were adding was part of a subnet that already had some IPs configured on this machine, you would alter the netmask to be 255.255.255.255: ifconfig em0 alias 69.55.228.10 netmask 255.255.255.255 Now, if you wanted to remove an IP from the system, you would first run: ifconfig -a to see all the IPs currently configured, and then you would run: ifconfig em0 -alias 69.55.228.10 netmask 255.255.255.255 notice the subtle addition of the minus sign in front of the word alias. The Ip and subnet mask in this line should match what you see in the output of `ifconfig -a` - so if it is 255.255.255.255 already, you should remove it as such, and if it is 255.255.255.0, then you should remove it like that. After adding a new IP, you need to add an alias line to /etc/rc.conf β you can just add a new alias line at the bottom of the list and make sure the alias # is the next number in the list. However, if you remove an IP, then you need to remove a line from /etc/rc.conf - and that means that you need to watch for two things: a) the alias numbers _must_ be sequential, in order, and starting with 0 - so if you remove a line from the middle, you will need to renumber every line after it. b) if you remove an IP that was the first IP of a subnet to be used on this system (which would have a subnet mask of 255.255.255.0, then you need to find the next IP of that subnet and change that netmask to 255.255.255.0, because now it is the first one in that subnet. Keep in mind that when the system is up and running, and you are adding and subtracting IPs, /etc/rc.conf plays no role - you simply are editing it and reflecting the new changes for the _next time the system boots_. So, if you forget to add or subract the IP from /etc/rc.conf, or if you get the alias numbers out of order, you will not know until the next reboot. REMINDER: always triple-check ifconfig commands you are running - if you forget that alias word, the main IP of the system will go away, you will have no access to that system, and I think all the other IPs on the system stop functioning as well. You must immediately reboot the system. So, what happens if you do mess up /etc/rc.conf, don't notice it, and then reboot sometime later with it ? Well, it depends - if it contains an IP that should have been removed, then perhaps there is no problem - it just has one extra IP. However if you moved that IP to a different server, then there will be an IP conflict. You may not notice this yourself - every other IP, and the machine itself will work fine ... but know that if you get emails telling you that sometimes their site responds and sometimes it doesn't, or sometimes they get their site and sometimes they get another site, then this should clue you in that perhaps there is an IP conflict. But, if the opposite occurs - if there are IPs that should be in /etc/rc.conf and are not _OR_ if out of order alias numbers cause some portion of the IPs that should have been configured to not be, then you have a problem. Two things: a) any time a freebsd system comes up, it would be wise to run `ifconfig -a` and compare it to what you see in /etc/rc.conf - just as a sanity check - this is before you run any quad or safe scripts. If there is indeed a mismatch, the fastest thing to do is simply fix what is wrong in /etc/rc.conf and reboot the system. b) if there are IPs missing and you do not notice until some or all of the systems are up, then you need to manually add the IPs that are missing. There is strong indication that you can add an IP to a jail _after_ the jail has started. Meaning that, the jail command for that system has already run, it is up and running, but simply cannot be contacted because the IP it is supposed to be running under does not exist. I do not recommend doing this though ... although sshd and sendmail seem to function immediately after configuring the IP that that jail should have, it is not clear that other server daemons do. So the best thing to do is just do that /etc/rc.conf and `ifconfig -a` comparison after the system boots, and before you run any quad/safe scripts.
Summary:
Please note that all contributions to JCWiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
JCWiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information