# Can't connect to Internet without DHCP



## Scooby-Doo (Nov 15, 2012)

Hello all.
I have just started using and learning FreeBSD just for fun.  It has been going fine but now I have a little problem connecting to the Internet. I can connect just fine when I have


```
ifconfig_bge0="DHCP"
```

in my /etc/rc.conf file. But I have come across several examples that don't do this and instead sets the IP address and related stuff manually in this file. So this is what I did:

With DHCP enabled, I performed


```
# ifconfig
```

From the result, I took the IP address and netmask: xxx.yy.213.212 and 255.255.255.255

I also performed


```
# netstat -rn
```

From the output, I took the first entry in the "Gateway" column (xxx.yy.212.1), which I assumed is the default router.

I then opened up the /etc/rc.conf file, removed the ifconfig_bge0="DHCP" line and entered the following lines:


```
ifconfig_bge0="inet xxx.yy.213.212  netmask 255.255.255.255"
defaultrouter="xxx.yy.212.1"
hostname="scooby.phub.net.cable.myISP.com"
```

The entry for the hostname was what was given to me in the DHCP configuration screen when I first installed the system. At that time (in the DHCP configuration screen), the "Domain" field was automatically filled in with "phub.net.cable.myISP.com". When I tried to enter my desired hostname (Scooby) in the "Host" field, it would be automatically prefixed to the domain, so my host name ended up being "scooby.phub.net.cable.myISP.com", and that is the response I get from using the hostname(1) command.

With these changes and after rebooting, there is no Internet access. I can ping my IP address but I cannot ping the default router address or anything else.

I guess this is a very basic issue but I don't know what the problem is. Anyone have any advice?


----------



## Uniballer (Nov 15, 2012)

Your router is xxx.yy.212.1
Your computer is xxx.yy.213.212
Your netmask is 255.255.255.255

The result is that your computer and the router are not in the same network.

You probably should set the netmask to 255.255.254.0 and leave the IP addresses as you have them so that the network logic will see the router as being in the same network as your computer.


----------



## Scooby-Doo (Nov 15, 2012)

Uniballer said:
			
		

> Your router is xxx.yy.212.1
> Your computer is xxx.yy.213.212
> Your netmask is 255.255.255.255
> 
> ...



Yes, that works! Thank you!


----------



## mix_room (Nov 16, 2012)

I would not recommend taking an IP assigned by DHCP and using it as though it were static. If your ISP assumes that all IPs are given out via DHCP, then they may very well give out your IP again. This will most likely break your internet connection, leaving you wondering what happened. 

If your ISP wants DHCP, use DHCP. If they give you an assigned IP, use that IP. 

If you want to play with IP-addressing, get a router so that you can run one of the private network, as mandated by RFC 1918


----------



## Uniballer (Nov 16, 2012)

I have to agree that playing with it to reach understanding is fine, but depending on your ISP to keep that IP address assigned to your system when you are not playing nice (i.e. requesting address assignment, renewing the DHCP lease, etc) is prone to failure.  And, unfortunately, you could mess up some other poor soul's Internet connection, too (he'll never be able to figure it out).  I would be very annoyed with any user who tried this in my network.


----------



## wblock@ (Nov 16, 2012)

The spec says that DHCP is supposed to ping an address before handing it out again.  This works with standards-compliant DHCP servers and networks, so you can often get away with using static addresses inside DHCP blocks.  However, some DHCP servers either allow turning off the ping safety check, are not standards compliant, or may not be able to complete a ping because big scary ICMP packets are blocked at the firewall.


----------



## Scooby-Doo (Nov 18, 2012)

mix_room said:
			
		

> I would not recommend taking an IP assigned by DHCP and using it as though it were static. If your ISP assumes that all IPs are given out via DHCP, then they may very well give out your IP again. This will most likely break your internet connection, leaving you wondering what happened.
> 
> If your ISP wants DHCP, use DHCP. If they give you an assigned IP, use that IP.
> 
> If you want to play with IP-addressing, get a router so that you can run one of the private network, as mandated by RFC 1918



OK, thanks. But now I have a follow-up question. Again, maybe it's really basic, but I would like to be certain in my understanding.

If I am connected directly to my cable modem (i.e., no router) with DHCP enabled, and I run


```
# ifconfig -a
```

the result for my network card is


```
inet xxx.yy.213.212 netmask 0xfffffe00
```

Is 0xfffffe00 = 255.255.254.0 the value I use to determine how many IP addresses I am allotted?

If this is true, then I have 512-2=510 usable IP addresses, and therefore possible hosts?

Do I use the result from "# ifconfig -a" above (i.e., xxx.yy.213.212) to calculate the range of IP addresses from which I can assign to a particular host?

Is any of this correct? :\


----------



## Uniballer (Nov 18, 2012)

Scooby-Doo said:
			
		

> ```
> inet xxx.yy.213.212 netmask 0xfffffe00
> ```
> 
> ...



No.  DHCP assigned you one IP address (xxx.yy.213.212) from the xxx.yy.212.0/23 network.  That network has the number of IP addresses you calculated, but they are being used by the ISP and other users per your ISP's policies.  Please don't mess with other addresses.


----------



## Scooby-Doo (Nov 18, 2012)

Uniballer said:
			
		

> No.  DHCP assigned you one IP address (xxx.yy.213.212) from the xxx.yy.212.0/23 network.  That network has the number of IP addresses you calculated, but they are being used by the ISP and other users per your ISP's policies.  Please don't mess with other addresses.



Nah, I'm certainly not going to mess around with what I'm not supposed to. All I really wanted was to be able to receive mail on my machine. I was just following the FreeBSD Handbook, Section 29.6.1:

"...in order to have mail delivered directly to your host, it must have a permanent static IP address..."

So that was just what I was trying to do. But mix_room says I should not take a DHCP-assigned IP address and arbitrarily use it as a static address.

So what exactly do I do? Am I supposed to call my ISP? I wish I didn't 'cause then I'll be on hold forever. 
If I have to, what exactly should I ask for?


----------



## Uniballer (Nov 18, 2012)

Scooby-Doo said:
			
		

> All I really wanted was to be able to receive mail on my machine.



Dynamic DNS may be an option for you, depending on what your ISP is doing.

Your ISP could be blocking incoming connections to your SMTP port (TCP 25).  If they are then your only option is to contact them and get them to allow it.  They might require you to purchase a higher tier service (e.g. "business class").


----------



## zspider (Nov 18, 2012)

Uniballer said:
			
		

> Dynamic DNS may be an option for you, depending on what your ISP is doing.
> 
> Your ISP could be blocking incoming connections to your SMTP port (TCP 25).  If they are then your only option is to contact them and get them to allow it.  They might require you to purchase a higher tier service (e.g. "business class").



I'll explain why Scooby-Doo.

The reason being is that they don't want to get blacklisted from sending mail because of poorly run mail servers sending spam that looks like it's coming from the ISP. So they just don't allow it on home internet connections.


----------



## JamesElstone (Nov 18, 2012)

Hi Scooby-Doo,

If you want to have your host to directly receive mail then you will need as a minimum:


Domain name (yearly cost with registar / internet hosting company / dynamic DNS provider) 
DNS server (own or rented from domain provider, dynamic DNS provider or other)
confirmed no firewall restrictions from ISP on port TCP 25 (smtp)
your firewall setup to receive port 25 from anybody
Either:
[*]A confirmed static IP address from your ISP (usually a business / premium service)
[*]Dynamic DNS service to forward DNS "MX" records as well as "A" records​
I would also recommend some sort of mail filter, as the amount of viagra spam out there is impressive these days...

On your comment of 





> If this is true, then I have 512-2=510 usable IP addresses, and therefore possible hosts?


510 nodes are the maximum number of nodes (or 509 neighbours you could say) on your network segment or broadcast domain, in your case assigned by the DHCP server.  The following websites are very good at explaining subnetting at the beginning of a learning curve:
http://www.yale.edu/pclt/COMM/TCPIP.HTM
http://www.cisco.com/en/US/tech/tk365/technologies_tech_note09186a00800a67f5.shtml

Also for information you can check who is in administrative control of a public IP address by looking it up with the relevant IP Registar WhoIs service, see http://www.iana.org/assignments/ipv4-address-space/ipv4-address-space.xml.  For example: IP 69.147.83.34 is hosted in the USA global area, and the IP is issued by ARIN, and for adminsitrative details see here: http://whois.arin.net/rest/net/NET-69-147-64-0-1/pft.

Now don't flame me but noting that you mention you have 





> started using and learning FreeBSD




I might have got the wrong end of the stick from the thread:r, but you don't need to complete section 29.6.1 in the handbook to get your e-mail from your ISP...  As an alternative, you could ask your ISP for an e-mail account and read section 29.11 (Mail User Agents) further on in the handbook...
Many domain hosting companies can offer e-mail accounts at a domain name of your choice at a low rate, and collect your e-mail via POP3 / IMAP protocol, which can be simpler that approaching a domestic based ISP service, but not as fun as hosting your own.  This give you a choice of "hosting your own" at a later date or a fall back position if your host is down, and ISPs tend not to block POP3/IMAP protocols as much.

FreeBSD is enjoyable, and would recommend hosting your own to learn how it all works and also the joys of Networking... :stud

James.


----------

