# How to set up multiple external IP addresses to server?



## hockey97 (Feb 8, 2013)

Hi, I just got 5 external IP addresses. However, have trouble setting them up. Here is how my network is set up:


```
ISP cable modem --> router --> switch.
```

I have an ethernet switch.  My router is a NAT type and I don't think I can map multiple external IP addresses to internal ones. I am thinking I can do something like this:


```
ISP cable modem --> switch --> router.
```

Is that possible? I already tried but when I do it like that I get no internet connection. How can I map those 5 IP addresses to my server?


----------



## kpa (Feb 9, 2013)

How did your ISP assign those 5 addresses to you? Without knowing the details I can just make a guess that you were given an 8 address /29 subnet (first and last address reserved for network and broadcast addresses and one for gw address giving 5 usable addresses) that is forwarded to your router and you're supposed to assign one of the addresses as an alias address to the LAN interface of the router as the gateway address and use the rest of the usable addresses as aliases on LAN hosts.

Or you could assign the gateway address as the main address on the LAN interface of the router and use just the public routable addresses as LAN addresses.


----------



## hockey97 (Feb 9, 2013)

kpa said:
			
		

> How did your ISP assign those 5 addresses to you? Without knowing the details I can just make a guess that you were given an 8 address /29 subnet (first and last address reserved for network and broadcast addresses and one for gw address giving 5 usable addresses) that is forwarded to your router and you're supposed to assign one of the addresses as an alias address to the LAN interface of the router as the gateway address and use the rest of the usable addresses as aliases on LAN hosts.
> 
> Or you could assign the gateway address as the main address on the LAN interface of the router and use just the public routable addresses as LAN addresses.




Well, I was e-mailed by them giving me a block of 5 ip addresses. I can count 5 actual static ip addresses. I have a linsys router that only allows me to setup one static ip address from my ISP. I am new to this. 

When you say gw do you mean? Gateway?  Those they give me another ip. 

They gave me 5 actual static ip addresses. They gave me a submask  and a gateway address and that isn't counted as part of the ip given. I think these are shared.

Right now I have freebsd 8.1 on my server. All computer including my server gets an ip address. I create a static ip internally for my server which is given 2 internal static ips.

So, you're saying I need to go onto my server and set it up to have an alias address  to be exactly the ip's that my ISP gave me to be set as an alias?


I don't know how they assigned me the IP's. They never told me. They just said that my modem has been bridged. So I don't need to worry about the modem. I just need to hardcode my router with the static ip that I want my personal computers to use.

I own this router: Linksys WRT300N V1.1.

I was told that I need to have one to one NAT to allow public ip addressesing to internal computers. I was told my router doesn't have this. So, I need to buy a new router that has these features. Is this true? If not then can you explain what you mean by aliases addressing. 

I only know the basics and intermediate aspects of networking. I don't know more then what I experienced. This is the first time I am getting more then one IP address. I thought I could just set those ip addresses to my computers / servers inside my network behind the router. I thought I would have to set them up manually by going to network connections and using the external ip address and the other information that my ISP provided me with. I thought that would be good enough. I tried it and nothing happened. 

I already changed my 2 domain names to point to 2 static ips that I just got assigned. So the domain names are set. I then changed my server to use those same ip addresses. Nothing happened and I had to set the server back to those 2 static internal ip addresses.


----------



## kpa (Feb 9, 2013)

There are number of ways to assign a block of public routable addresses. What I'm thinking of is that your ISP has set up a static route for the /29 netblock on their router that points to the static IP address they gave you for the WAN address of your router.

Post the information they gave you, censor the addresses if you must.


----------



## hockey97 (Feb 9, 2013)

kpa said:
			
		

> There are number of ways to assign a block of public routable addresses. What I'm thinking of is that your ISP has set up a static route for the /29 netblock on their router that points to the static IP address they gave you for the WAN address of your router.
> 
> Post the information they gave you, censor the addresses if you must.



I gave you a PM with the e-mail they sent me. It contains the block all the info they sent me.

What do I need to do to get my servers assigned those IP addresses?


I just got off the phone and gotten an e-mail from my internet provider this is what they told me:

"It depends on how you want your network configured. In most cases, youâ€™d allocate one IP address in your router settings. We do not assist in this set up, as every business is different. I would suggest you reach out to your IT vendor to verify you are creating the best need for your business"

They won't tell me how they're forwarding those ip addresses to me and they won't tell me anything on how to setup my static ips.

I thought I can hookup my modem to my switch hub and then connect my servers directly to the hub and then use the static ip addresses. Then in this hub I can then connect the hub to my router where my personal computers could share the same external ip address. 

I thought I could do that but when I actually do it... the computers won't get any internet connection. It would only work  if I connect the modem to my router and then have my router get connected to my switch hub but all computers will share one single external ip address. 

I need at least my servers to have 2 external static ip address assigned to them. I need it because I own 2 domain names and I need both domains to have their own PTR record.


----------



## hockey97 (Feb 11, 2013)

Here is the cable modem I own:

http://www.motorola.com/Video-Solut.../ci.Motorola_SURFboard_SB6120_US-EN.resources

I can't connect a switch to this and connect my router to the switch. It just wont work.

I read that this modem has DHCP server internally. It's not wireless but has it internally. They said it can work as a internet gateway or as a DHCP server if there is no internet connection it resorts to be a DHCP server.


----------



## J65nko (Feb 12, 2013)

You mentioned that the Motorola cable modem has been bridged. Assuming that you indeed  have been given a /29 subnet of 8 addresses .....
From https://tools.ietf.org/html/rfc1878:

```
FF.FF.FF.00   /24     255.255.255.0      256         1 C
   FF.FF.FF.80   /25     255.255.255.128    128       1/2 C
   FF.FF.FF.C0   /26     255.255.255.192     64       1/4 C
   FF.FF.FF.E0   /27     255.255.255.224     32       1/8 C
   FF.FF.FF.F0   /28     255.255.255.240     16      1/16 C
   [color=blue]FF.FF.FF.F8   /29     255.255.255.248      8      1/32 C[/color]
   FF.FF.FF.FC   /30     255.255.255.252      4      1/64 C
   FF.FF.FF.FE   /31     255.255.255.254      2     1/128 C
   FF.FF.FF.FF   /32     255.255.255.255   This is a single host route
```
Of these 8, you cannot use the first (the network address) and the last (the broadcast address). That leaves 6. If we subtract the gateway address you have 5 left.

The following diagram assumes you have 111.111.111.0/29

```
111.111.111.111.0 : network address
111.111.111.111.1 : gateway address
111.111.111.111.2 - 111.111.111.111.6 : the 5 addresses
111.111.111.111.7 : broadcast address
```

In stead of the black box router you get an old PC with 2 network cards which you configure as a firewall and router.

The external NIC of this firewall/router will get those 5 IPs.
You assign the first address 111.111.111.111.2 with netmask 255.255.255.248. The remaining ones need a 255.255.255.255 netmask.
The internal NIC gets one of the RFC 1918 reserved addresses, just like your servers. I picked 10.0.0.0/24 addresses.


```
INTERNET
              |
              |
+-------------|------------+
|       coax interface     |
|                          |
|         cable modem      |
|          bridged         |
|                          |
|    ethernet interface    |
|     (no IP address)      |
+-------------|------------+
              |
              |
+-------------|------------+
|     111.111.111.2/29     | 
|     111.111.111.3/32     | 
|     111.111.111.4/32     | 
|     111.111.111.5/32     | 
|     111.111.111.6/32     | 
|       external NIC       |
|                          |
|         FreeBSD          |
|         pf router        |
|                          |
|        internal NIC      |
|       10.0.0.0.1/24 i    |
+-------------|------------+
              |
              |
       +------|-----+
       |   switch   |
       +-|--------|-+ 
         |        |
         |    10.0.0.22
         |    server-2
         |
     10.0.0.11 
      server-1
```
You need a pf.conf that redirects incoming port 80 traffic for 111.111.111.2/29 to 10.0.0.11.
Likewise port 80 traffic for 111.111.111.3 will redirected by pf to the second server at 10.0.0.22.

Problem solved


----------



## hockey97 (Feb 12, 2013)

Nevermind guys. I used the switch and after spending the whole day today and yesterday playing with it. I notice that port one the physical port on the switch would have it's led on when I plugin the cable to the uplink port. I then plugged a computer into port one but I  just notice when I don't plug anything in port one I still see the active led link blinking.

I just made the servers and router to not use port 1 and just use the rest of the others. Now it's working.

Now another problem. When I setup my server which has freebsd 8.1 I have I think gnome on it. like an OS type looking on the server.

I can use a gui to make changes to the Ethernet ports o the server.  I got 2 ports.

However, I can enter the static ip address and the submask you know the 255.255.255.0 etc.

Anyways when I put in the gateway address . I then click close  the ip address and submask would be saved but the gateway won't be there anymore. I can do this all night and it keeps disappearing.

Anyone know why? My computers on my network is fine and I can get internet via my router.

I have the switch inbetween my modem and router. It now finally works.


I just now need to know why the gatway keeps disappearing.   


Ya, you guys are right it's a 8 block ip. I know understand what you mean by it.

one for broadcast, one for gatway etc.


----------



## kpa (Feb 12, 2013)

Don't use the GUI for setting up the IP address or gateway, set them directly in /etc/rc.conf
(using em0 as example interface)


```
ifconfig_em0="inet xxx.xxx.213.186 netmask 255.255.255.248"
defaultrouter="xxx.xxx.213.185"
```

Also set up nameservers in /etc/resolv.conf


```
domain mydomain.tld
nameserver xxx.xxx.217.2
nameserver xxx.xxx.217.3
nameserver xxx.xxx.217.5
```


----------



## hockey97 (Feb 12, 2013)

kpa said:
			
		

> Don't use the GUI for setting up the IP address or gateway, set them directly in /etc/rc.conf
> (using em0 as example interface)
> 
> 
> ...



Thanks guys got it to work. Ya, I changed the rc.config file it was set to default gateway to my router. I just changed it to the one my ISP provided and it all now works after I restarted my server. Everything works.

Thanks   :stud


----------



## hockey97 (Feb 12, 2013)

hey guys I got one more question.

How can I setup to use 2 or more ip address on the same server or computer?


----------



## gqgunhed (Feb 12, 2013)

ifconfig() shows:

`# ifconfig alias [original NIC] [additional ip-address] netmask 255.255.255.[b]255[/b]`


----------



## SirDice (Feb 12, 2013)

Or, in /etc/rc.conf:

```
ifconfig_<int>_alias0="inet 1.2.3.4 netmask 255.255.255.255"
ifconfig_<int>_alias1="inet 2.3.4.5 netmask 255.255.255.255"
```


----------

