# What do I to have more than one IP address in my computer?



## Sivan! (May 22, 2022)

While trying to understand if it is possible for me to have more than one IP address in my computer (I don't even have one that is static at the moment), I found the discussions on this thread which seems to say:



> Not only is this possible, it is very common. A single network card can do this in a couple of ways; it can answer for multiple IP addresses with a single MAC address (assigning multiple addresses to a NIC in most operating systems will do this), or with multiple MAC addresses (virtualization platforms behave in this way).
> ....
> this is called *ip aliasing* and how you set it up is dependent upon your Operating system..





> A network card may have multiple IP addresses. This is a concept called multihoming. There are other variants of multihoming as well.





> Linux is the only OS I know of that makes you setup a *subinterface*. Windows and the *BSDs do not*.



1. Does this mean that it is possible to have multiple IP addresses mapped to a single MAC address in linux for not in BSD? Or that BSD achieves it by methods other than by setting up subinterfaces?

2. For whatever rationale or in the complete absence of it, if I have one computer (a desktop) and have two or more static IP addresses, can I make forum posts from one IP while sending and receiving email messages from another IP address? (I understand that a Virtual Machine would make it possible, but the question is *not* about hardware or network virtualization)


----------



## zirias@ (May 22, 2022)

Sivan! said:


> Does this mean that it is possible to have multiple IP addresses mapped to a single MAC address in linux for not in BSD?


No. It means with BSD, you don't need this strange construct of "subinterfaces" in order to assign aliases to the same interface.

For everything else, I'm not sure you should worry about that now. Maybe read a book about networking and IP? No offense meant, but I just have the feeling I would need to write a book for a good answer here...


----------



## Sivan! (May 22, 2022)

Zirias said:


> No. It means with BSD, you don't need this strange construct of "subinterfaces" in order to assign aliases to the same interface.
> 
> For everything else, I'm not sure you should worry about that now. Maybe read a book about networking and IP? No offense meant, but I just have the feeling I would need to write a book for a good answer here...



Zirias Yes, please do. It will certainly be useful for many.


----------



## SirDice (May 22, 2022)

Beg, steal or borrow a copy of "TCP/IP Illustrated, Volume 1" by Stevens. It will tell you everything you need to know about TCP/IP, in all its gory details.


----------



## mer (May 22, 2022)

SirDice said:


> Beg, steal or borrow a copy of "TCP/IP Illustrated, Volume 1" by Stevens.


"I know nothing about IP, TCP, networking, what is a good introductory volume"?


----------



## SirDice (May 22, 2022)

mer said:


> "I know nothing about IP, TCP, networking, what is a good introductory volume"?


This one, it's a really good book. It starts off with the basics and progressively dives into the gnarly details when there's a need for it.


----------



## Sivan! (May 22, 2022)

SirDice said:


> Beg, steal or borrow a copy of "TCP/IP Illustrated, Volume 1" by Stevens. It will tell you everything you need to know about TCP/IP, in all its gory details.



Ordered a printed book, will receive it in four days if the postman delivers it. In the meantime, borrowed a copy from the Internet archive for an hour to flip through. Thank you.


----------



## mer (May 22, 2022)

SirDice yep, and it fits nicely next to my copy of vol2, vol 1&2 of Unix network programming, tcp/ip guide by Kozierok 
The best thing about these classics:
They still apply.  New protocols typically fit existing models, IPV6 is an extension, so spending money on a printed copy is a long term investment.


----------



## SirDice (May 22, 2022)

I have volume 1, 2 and 3. But I see there's a second edition (mine are first edition and probably 20 years old now), Stevens unfortunately passed away but Kevin Fall updated the whole series. Maybe I should order those too.


----------



## Sivan! (May 22, 2022)

SirDice said:


> I have volume 1, 2 and 3. But I see there's a second edition (mine are first edition and probably 20 years old now), Stevens unfortunately passed away but Kevin Fall updated the whole series. Maybe I should order those too.



The edition in the archive says 


> Worldwide Internet, or the Internet, a Wide Area Network (WAN) of more than _*one million computers ...*_


----------



## Bobi B. (May 22, 2022)

Regarding the syntax: To assign a secondary IP (`10.11.10.20` to network interface `igb0`) use ifconfig(8) like this:

```
ifconfig igb0 inet 192.168.10.20/24
ifconfig igb0 inet 10.11.10.20/24 alias
```
omitting `alias` will replace 1st IP address; be careful when working remotely. To remove it:

```
ifconfig igb0 inet 10.11.10.20/24 -alias
```
For startup configuration via /etc/rc.conf (rc.conf(5)):

```
ifconfig_igb0="inet 192.168.10.20/24"
ifconfig_igb0_alias0="inet 10.11.10.20/24"
```


----------



## _al (May 22, 2022)

SirDice said:


> Maybe I should order those too.


I  read the new edition of TCP/IP Illustrated volume 1.
Not the same level as Stevens' book. However, I recommend them all.


----------



## Geezer (May 23, 2022)

https://www.isi.edu/~hussain/TEACH/Spring2014/notes/Steven00a.pdf


----------

