# Internet issues with freebsd server



## tony33 (Nov 10, 2022)

Hi  I have followed a tutorial to setup  a aggregated link. I have two 1 gig ethernet ports on the server which I don't use.
I then have pci card with two 10 gig ethernet ports.  I have a commercial switch that supports link aggregation and I have that setup.
I then setup freebsd with this and it worked until recently I done a update on my ports.

Right now I get errors when I ping google.com  and ping 8.8.8.8.  for the ping 8.8.8.8 error says  there's not route to host.

I type in the ifconfig and look at my lagg0 interface and noticed the data is messed up.
when I boot them system or if I resart netif  it defaults to these settings which is wrong. 

for example :

lets say my gateway  is  34.233.213.164  and it's 8 ips. total. 
in this case lets say my static ip is 34.233.213.169 
my broadcast ip would be 34.233.213.171

So, in my rc.conf file I have it setup to use 34.233.213.169/31  as ip and submask or netmask 255.255.255.248.
I don't set broadcast ip. However, when I check ifconfig it sets the broadcast ip to 255.255.255.255 .
which in my opinion is wrong and I feel this is the issue. I have the ports  up. 
so, I do a ifconfig `ifconfig lagg0 34.233.213.169 34.233.213.171` Then enter and I would look at the ifconfig again.
It would show lagg0 now with a broadcast ip of 34.233.213.171 everything looks good but netmask is in hex I cannot read it.
Is there a way to convert netmask to ip format?  I just want to make sure everything has the right numbers. 

I try pinging the sanme thing posted above and I still get errors.  The resolv,conf does have ip addresses of the dns servers.
the issue I am having is routing.  when I type netstat -r  the routing table doesn't show a default gateway.
Even though I have set defaultrouter as 34.233.213.164 in rc.conf. 

I would like to know how can I get ifconfig to output the netmask in ipv4 format? Also 
how can I put in rc.conf setting to set the broadcast ip?
in the terminal I have done ifconfig  lagg0  followed by broadcast then 34.233.213.171 but it doesn't do anything.
If I  check ifconfig again it ould show no changes to the broadcast ip. 

In the rc.conf I have the lagg set with ipv4_addr_lagg0   on a different line. I forgot the exact wording but it worked before.
before when it worked it would automatically put broadcast ip 34.233.213.171 in lagg0.

Now when the lagg0 starts it's automatically set to 255.255.255.255  which is wrong. I would have to change it in teriminal.
and then restart routing. If  I restart netif it would set the lagg0 broadcast ip back to 255.255.255.255. 

Is there anything I should check. I don't get why the broadcast ip get's automatically assigned the wrong ip address. 
The ip's i used above is just an example and it's not my own ip. However, my ISP given me static ip's and they gave me the ip's of the gateway
and the broadcast ip. On my windows machines I normally don't have to assign the broadcast ip. just had to set ip, gateway and submask.
Any ideas on what I should try or look for? 

Thanks in Advance


----------



## SirDice (Nov 10, 2022)

tony33 said:


> I have it setup to use 34.233.213.169/31 as ip and submask or netmask 255.255.255.248.


Doesn't add up. A /31 would have a 255.255.255.254 netmask. If we assume 255.255.255.248 (that's a reasonable subnet mask) is correct then it would be a /29. Broadcast address would be 34.233.213.175. Now, assuming you're messing up the subnet masks and assume 34.233.213.171 is a correct broadcast address your actual subnet would be a /30 or 255.255.255.252. But a /30 would only be 4 IP addresses (2 hosts). So if you have 8, then has to be a /29 and your broadcast address is 34.233.213.175. I really recommend using an IP subnet calculator. 



tony33 said:


> I do a ifconfig `ifconfig lagg0 34.233.213.169 34.233.213.171`


Ehm, it's `ifconfig <interface> <IP address> <subnetmask>`. Using 34.233.213.171 would be an invalid subnet mask, thus it defaults to /32 or 255.255.255.255.


----------



## tony33 (Nov 13, 2022)

SirDice said:


> Doesn't add up. A /31 would have a 255.255.255.254 netmask. If we assume 255.255.255.248 (that's a reasonable subnet mask) is correct then it would be a /29. Broadcast address would be 34.233.213.175. Now, assuming you're messing up the subnet masks and assume 34.233.213.171 is a correct broadcast address your actual subnet would be a /30 or 255.255.255.252. But a /30 would only be 4 IP addresses (2 hosts). So if you have 8, then has to be a /29 and your broadcast address is 34.233.213.175. I really recommend using an IP subnet calculator.
> 
> 
> Ehm, it's `ifconfig <interface> <IP address> <subnetmask>`. Using 34.233.213.171 would be an invalid subnet mask, thus it defaults to /32 or 255.255.255.255.


It's actually my network is /29 but  I wanted to assign 2 ip's to my server.  I know /32 is a single ip and 31 denotes 2.  ok I think that's where I am mistaken. I might need to change the subnet mask.
Also would the broadcast ip change?  The actual network is /29 but want to assign 2 ip's for my server.


----------



## Jose (Nov 13, 2022)

tony33 said:


> ...I wanted to assign 2 ip's to my server...


Messing with the netmask is definitely not the way to go about this. If you want to assign two IP addresses to the same interface, what you're looking for is called an "IP alias":


			https://cr.yp.to/djbdns/ifconfig.html


----------



## tony33 (Nov 14, 2022)

Jose said:


> Messing with the netmask is definitely not the way to go about this. If you want to assign two IP addresses to the same interface, what you're looking for is called an "IP alias":
> 
> 
> https://cr.yp.to/djbdns/ifconfig.html


Yeah I know but I was talking to someone online and they said I can shorten it by using  /31  so to avoid what you were saying which I had it set it up originally like that. I wanted to condense it into one line.  So, ,they said do 34.233.213.169/31  because it would assign 34.233.213.169 and 34.233.213.170 to my lagg0 interface.  I found a few places online that said the same thing but it's very limited. So, I am not sure if it's ok to use that 34.233.213.169/31 and if  not then that's my issue.  I am thinking to put this back to where it was originally. I would use the alias.


----------



## gpw928 (Nov 14, 2022)

Conventional subnets need one IP address (all zeros in the host part) for the network address, one IP address for the broadcast address (all ones in the host part), plus at least two more IP addresses for hosts and/or routers.  So the usual minimum size for a functional subnet is two bits in the host part (four unique values for host addresses) and thus 30 bits in the network part, i.e. /30.

RFC 3021 documents the special case for /31 subnets where there are only two hosts in a point-to-point (PPP) link, and no need for broadcast or network addresses.


----------



## tony33 (Nov 15, 2022)

gpw928 said:


> Conventional subnets need one IP address (all zeros in the host part) for the network address, one IP address for the broadcast address (all ones in the host part), plus at least two more IP addresses for hosts and/or routers.  So the usual minimum size for a functional subnet is two bits in the host part (four unique values for host addresses) and thus 30 bits in the network part, i.e. /30.
> 
> RFC 3021 documents the special case for /31 subnets where there are only two hosts in a point-to-point (PPP) link, and no need for broadcast or network addresses.


Thanks. I already assigned one ip to my lagg0 and tried to test it by itself  I changed the rc.conf to use the single ip with a netmask  255.255.255.248.
my network is /29 there should be 8 ip's total but only 5 usable.  I also updated rc.conf with a broadcast ip  but the issue is that it mixes the ip with the netmask. example :

`ifconfig lagg0 34.233.213.169  34.233.213.171` This code works  and would make the changes. I would then run 
	
	



```
sevice netif restart
```
 and also do the same for routing.
when I do this  it would show broadcast ip to be 34.255.255.255.255   idon't know where it's getting this.  I even deleted all netmask configs and it still does this.

My network example is  34.233.213.164 to 34.233.213.171.   ISP gave me netmask of 255.255.255.248   I do set subnet mask and ip on my windows machines  and do know when setting  static all ip's of my network work with the same submask.  I can ue 34.233.213.165 to 34.233.213.170  with submask 255.255.255.248 and it works. gateway be 34.233.213.164.

I just want to make sure if my lagg0 is configured properly. I need to know what commands to run to see ip, submask, gateway.

also do I need to enable local unbound and routed? I am using 2 aggregated links.

also the link below is what I used to follow to setup the aggregated links. 

Also I noticed there's ipv6 being assigned to my nicks.  so - ix0  and ix1 these two get ipv6 automatically assigned an ipv6. I don't have it setup.
the rc.conf has 2 linkes to not allow all nics to be assigned ipv6. Is there anything I can do or run to check and make sure t here's no ip assigned on those nicks.

I was told the lagg0  is the only interface that needs to have 2 ip's assigned. the ix0 and ix1 shouldn't have any ip's assigned to them.


----------



## VladiBG (Nov 15, 2022)

You can't have network from .164 to 171 with netmask 255.255.255.248 the network is 34.233.213.160/29 netmask 255.255.255.248 first host is .161 last host is .166 and broadcast .167

So my guess is your ISP is using PPP so he can utilize all IPs from bigger network segment like 34.233.213.160/28 netmask 255.255.255.240 first host .161 last host .174 and broadcast .175


----------



## tony33 (Nov 17, 2022)

VladiBG said:


> You can't have network from .164 to 171 with netmask 255.255.255.248 the network is 34.233.213.160/29 netmask 255.255.255.248 first host is .161 last host is .166 and broadcast .167
> 
> So my guess is your ISP is using PPP so he can utilize all IPs from bigger network segment like 34.233.213.160/28 netmask 255.255.255.240 first host .161 last host .174 and broadcast .175


I don't know what my ISP does on their end. I am just saying this is the info they gave me. I can see in arin that my network is 34.233.213.164/29   it is reassigned.

My isp told me flat out my gateway is 34.233.213.165, My broadcast ip is 34.233.213.171  these are examples. I pay for 8 ip's.

one is used for gateway and one is used for broadcast ip. I can only use 5 ip's.  They gave me the range and told me the submask to use.
In windows I only put ip's ending 166 - 170 I can use these for my machines. 

I know it works and it's correct info. before I used this info directly on the enternet nicks and it worked. 
Right now, I turned off lagg0 and directly assigned the ip's to the nics and it didn't work. 
I move the physical ethernet cords to my other switch it worked. I am right now looking into that other switch to see why this is the case. There's no vlan setups.

However, on my other switch when I directly assigned ip's to the nics it worked.
So, I then changed the config back to lagg0 and again it didn't work. I did the [CODE ifconfig [/CODE] 
and It shows the netmask to be 34.255.255.255.255  which is wrong. I manually ran the ifconfig and 
assigned the ip,broadcast ip 34.233.213.171 and netmask 255.255.255.248  and still didn't work.
I then looked at the ethernet nics and found ipv6  are assigned even doing in the [CODE rc.conf[/CODE]
I  have it setup to disable ipv6. The nics aren't supposed to have any ip assigned.  Only the lagg0 interface should have them.
So, I manually ran the inet6 command to delete it.  I put all 3 interfaces down and put it back up.

After doing all this  it now works.

The issue is that my ethernet nics are getting an ipv6 assigned automatically even though it's not configured to do so. 
I need to figure out why and what is assigning them ipv6.

that's one issue and the other if I ran netif restart  it will set things back to the what I had changed from.
Again the lagg0 would get a netmask of 34.255.255.255.255  which is wrong.

I don't want to have to manually set things up every time.

Got any times on what I should run to see where these figures are coming from?


----------



## VladiBG (Nov 17, 2022)

Contact your ISP and ask them to give you in CIRD subnet for your network because you can't have .171 as broadcast.





						IP Subnet Calculator
					

This IP subnet calculator covers both IPv4 and IPv6 protocols, providing information such as IP address, network address, subnet mask, IP range, and more.




					www.calculator.net


----------



## Bryce Alexander (Nov 17, 2022)

Let's take this back to the basics, the subnet mask is simply an identifier that tells your local machine the range of IP's that are reachable within your local network. That means it can address them directly. Anything outside that range would need to be sent to the default router. I will find internal IPs by sending arp requests to the broadcast IP. If you have an address that the ISP is providing that is outside the subnet mask you were given, then it is legitimate to adjust your own mask to include the larger range.

To adjust the range of your local network's mask, use a subnet calculator like the one that VladiBG provided.

As to setting up your LAGG, you do not need to give the individual interfaces IP addresses, only the LAGG0 interface needs an IP address. The FreeBSD handbook gives an example in Chapter 29.6


----------



## tony33 (Nov 23, 2022)

Bryce Alexander said:


> Let's take this back to the basics, the subnet mask is simply an identifier that tells your local machine the range of IP's that are reachable within your local network. That means it can address them directly. Anything outside that range would need to be sent to the default router. I will find internal IPs by sending arp requests to the broadcast IP. If you have an address that the ISP is providing that is outside the subnet mask you were given, then it is legitimate to adjust your own mask to include the larger range.
> 
> To adjust the range of your local network's mask, use a subnet calculator like the one that VladiBG provided.
> 
> As to setting up your LAGG, you do not need to give the individual interfaces IP addresses, only the LAGG0 interface needs an IP address. The FreeBSD handbook gives an example in Chapter 29.6


Yes, and the ip network given are examples.  I didn't give legit ip address and ranges because it will publically leak my ip address and my business name which will  leak both my business offices and my home address. It's privacy concern.

The ip I am using works. Right now I used the inet6  delete command to remove the ip version 6 addresses. After removing them it works. I understand how lagg0 works.
That is why I have no clue where the ethernet interfaces are getting a ipv6 from because in rc.conf file I have it disabled.  No matter  what if I restart netif  it will assigned back a static ipv6 for 2 ether net ports. Which I don't want.  I don't have a clue on what and where the assignments are coming from. 

the ip used and submask used are correct but I gave fake ones for examples.  I made changes to the rc.conf and used /29 notation and took out the netmask and gateway data and it works.
It automatically does the netmask and gateway. That works but now just gotta figure out where the ipv6 are coming from and I know they're static because it's the same ip addresses being assigned. df


----------



## tanis (Nov 25, 2022)

I would suggest the following regarding the IP issue:


```
$ pkg install gnu-ipcalc
$ ipcalc 34.233.213.164/29
Address:       34.233.213.164
Network:       34.233.213.160/29
Netmask:       255.255.255.248 = 29
Broadcast:     34.233.213.167

Address space: Internet
HostMin:       34.233.213.161
HostMax:       34.233.213.166
Hosts/Net:     6
```

That should give you the ability to determine your ip address range based on whatever your ISP assigned to you.

Regarding the link aggregation and the two IP address these are actually two things which are in technological terms not dependent on each other.

For link aggregation see, static aggregation groups, and LACP (Dynamic, Static). This works like a piece of cake with FreeBSD and is a rather easy configuration.

For assigning a subnet to an interface, this sounds awefully a lot like the Linux AnyIP feature which, as far as I'm aware of it, is not supported by FreeBSD. Perhaps in the future?!


----------



## VladiBG (Nov 26, 2022)

Next time just say my IP is A.B.C.D instead of providing some inaccurate fake address.


----------

