# How to connect to the internet?



## paldepind (Mar 23, 2010)

Hi 

I've decided to give FreeBSD a try after using different Linux distros for almost a year. But right now I'm having a very noob problem. I'm not able to connect to the internet via ethernet. I've only been able to find out how to configure it trough sysinstall but I'd like to configure it myself.

I'm not sure but I guess I need something like a deamon that automatically connects to the internet when it detects a plugged in 8P8C cable.

Right now that is my main problem, but later on I would also like to be able to connect to the internet using my Huawei E160 3G usb modem. Is this possible in FreeBSD?

Thanks in advance.


----------



## graudeejs (Mar 23, 2010)

in /etc/rc.conf

```
ifconfig_re0="inet 1.2.3.4 netmask 255.255.255.0"
defaultrouter="1.2.3.1"
```

replace re0 with your interface (you can find available interfaces by running ifconfig)

in /etc/resolv.conf

```
nameserver 1.2.3.1
nameserver 1.2.3.6
```

reboot

for more detailed info
ifconfig(8)
rc.conf(5)


----------



## paldepind (Mar 24, 2010)

Hmm.. It doesn't work.


----------



## aragon (Mar 24, 2010)

paldepind said:
			
		

> Hmm.. It doesn't work.


Hmm... that doesn't help us help you any further.  More information needed... ifconfig output, routing table, traceroutes, etc.


----------



## graudeejs (Mar 24, 2010)

did you replace appropriate values ?
If you use DHCP


```
ifconfig_re0="DHCP"
```


----------



## paldepind (Mar 24, 2010)

killasmurf86 said:
			
		

> did you replace appropriate values ?
> If you use DHCP
> 
> 
> ...


Doesn't work either. Although I know that I use DHCP.

Just to be sure. 
	
	



```
ping http://google.com
```
 is okay to use when testing if my internet connection works?



			
				aragon said:
			
		

> Hmm... that doesn't help us help you any further.  More information needed... ifconfig output, routing table, traceroutes, etc.


I'm not sure what information you want..


----------



## DutchDaemon (Mar 24, 2010)

paldepind said:
			
		

> Just to be sure.
> 
> 
> 
> ...



No. Use [cmd=]ping google.com[/cmd], and to be sure, also try [cmd=]ping 74.125.79.147[/cmd].


----------



## paldepind (Mar 24, 2010)

Pinging Google without http:// didn't work..

Honestly I can't understand why this is so hard to get running. In Arch Linux it was a piece of cake..


----------



## graudeejs (Mar 24, 2010)

In freebsd it's peace of cake as well, when you know what you do.
We don't know what you do, we don't see any logs etc, so we have to guess

are you using wired network?
show output of

```
# ifconfig
# dmesg
```
and show /var/log/messages


----------



## paldepind (Mar 24, 2010)

killasmurf86 said:
			
		

> In freebsd it's peace of cake as well, when you know what you do.
> We don't know what you do, we don't see any logs etc, so we have to guess


Well, you're probably right..



			
				killasmurf86 said:
			
		

> are you using wired network?
> show output of
> 
> ```
> ...


Yop, I'm using a wired connection.

Ifconfig = http://twistedpipedream.com/dropbox/ifconfig.JPG

Dmesg: http://twistedpipedream.com/dropbox/dmesg0.JPG and http://twistedpipedream.com/dropbox/dmesg1.JPG (it's a huge output but I got the relevant)

The messages file is HUGE. But if there's anything specific I will find it to you.

Btw, I hope it's that I just took some pictures instead of writing it all down..


----------



## ckester (Mar 24, 2010)

DutchDaemon said:
			
		

> No. Use [cmd=]ping google.com[/cmd], and to be sure, also try [cmd=]ping 74.125.79.147[/cmd].



To clarify, Dutch is recommending that you also try pinging the IP address because you might not have things correctly setup to work with your DNS server yet.  If pinging 74.125.79.147 works but pinging google.com does not, then we'll know we need to focus our attention on your DNS configuration.

If neither ping works, we need to check what driver you're using, whether the interface is up, and whether you're getting an IP from your DHCP server.  That's why killasmurf asked for the output from ifconfig.   

The dmesg output will give us some related info about what happened during bootup.

Another thing that will help us troubleshoot your problem would be to show us what you have in /etc/rc.conf.


----------



## ckester (Mar 24, 2010)

OK, I see from your ifconfig screenshot that your wired connection is using the re driver and that interface is up.  But you haven't received an IP from the DHCP server.

Do you have the following line in /etc/rc.conf?  If not, add it, then reboot.


```
ifconfig_re0="DHCP"
```

_
Added later:  I see you've already been asked this.  Sorry.   

Can you ping the DHCP server?

Is there anything in /etc/dhclient.conf other than comments?
_


----------



## paldepind (Mar 24, 2010)

ckester said:
			
		

> OK, I see from your ifconfig screenshot that your wired connection is using the re driver and that interface is up.  But you haven't received an IP from the DHCP server.


I found this in my /var/log/messages file: 
	
	



```
re0: Ethernet adress: 00:1e:68:d2:70:59
```
 I guess that means that I actually got an IP from the server..

When I pinged Google's IP I got this: 
	
	



```
74.125.79.147 (74.125.79.147): 56 data bytes
```
 but after that it just repeated printing out: 
	
	



```
ping: sendto: No route to host
```



			
				ckester said:
			
		

> Do you have the following line in /etc/rc.conf?  If not, add it, then reboot.
> 
> 
> ```
> ...


Yes. My rc.conf looks like this:

```
keymap="danish.iso"
ifconfig_re0="HDCP"
defaultroute="1.2.3.1"
```


----------



## graudeejs (Mar 24, 2010)

lol, 
*ifconfig_re0="[red]HD[/red]CP"* << should be DHCP
*defaultroute="1.2.3.1"* << remove if you use DHCP (btw, 1.2.3.1 was supposed to be default route IP, not just random example number that I gave)


----------



## Beastie (Mar 24, 2010)

paldepind said:
			
		

> I found this in my /var/log/messages file:
> 
> 
> 
> ...


Not at all. That's a MAC address not an IP address, and it's stored inside the adapter not assigned from the outside.



			
				paldepind said:
			
		

> When I pinged Google's IP I got this:
> 
> 
> 
> ...


Remove the defaultroute line. Your ISP should hopefully get you one.
When you fix the "HDCP" typo, don't forget to reboot.


----------



## volatilevoid (Mar 24, 2010)

*Ethernet address* is your MAC address, not your IP. When running `# ifconfig`, your IP will be the value next to *inet*.

Can I increase the quality of YouTube videos when using HDCP instead of DHCP?


----------



## graudeejs (Mar 24, 2010)

set it to DHCP and reboot, see if that works, then change it to HDCP, it's first time I hear about HDCP, maybe it's some linux stuff?


----------



## ckester (Mar 24, 2010)

paldepind said:
			
		

> I found this in my /var/log/messages file:
> 
> 
> 
> ...



Nope.  That's the MAC address for your NIC, not an IP address from DHCP.

Assuming the HDCP typo killasmurf caught was a transciption error and not actually in your rc.conf, the thing you need to focus on now is your defaultroute.   What's the topology of your network?  If this is a home network, are you using a cable modem or firewall/router?

_I type too slow!  Someone already explained the MAC address. _


----------



## volatilevoid (Mar 24, 2010)

killasmurf86 said:
			
		

> set it to DHCP and reboot, see if that works, then change it to HDCP, it's first time I hear about HDCP, maybe it's some linux stuff?



HDCP is short for High-bandwidth Digital Content Protection.


----------



## Beastie (Mar 24, 2010)

killasmurf86 said:
			
		

> change it to HDCP, it's first time I hear about HDCP, maybe it's some linux stuff?


High-bandwidth Digital Content Protection is "quite" different from the Dynamic Host Configuration Protocol.


----------



## ckester (Mar 24, 2010)

volatilevoid said:
			
		

> HDCP is short for High-bandwidth Digital Content Protection.



No wonder it doesn't work!

We want IP = internet protocol, not IP = intellectual property.


----------



## graudeejs (Mar 24, 2010)

So when Will you do what I said?


----------



## graudeejs (Mar 24, 2010)

huuh, already mixed volatilevoid with paldepind :r


----------



## paldepind (Mar 24, 2010)

killasmurf86 said:
			
		

> lol,
> *ifconfig_re0="[red]HD[/red]CP"* << should be DHCP
> *defaultroute="1.2.3.1"* << remove if you use DHCP (btw, 1.2.3.1 was supposed to be default route IP, not just random example number that I gave)


OMFG! It was just typo.

I'm so sorry that I took your guys time just because of a stupid typo. Thanks a lot for your help anyway.. There's clearly a lot of stuff about networking that I know nothing about.

Btw, it works perfectly now  Thanks again!


----------



## ckester (Mar 24, 2010)

To learn more about networking and other configuration details with FreeBSD, I highly recommend Michael Lucas's book Absolute FreeBSD.   It's gotten me out a tight spot more often than I can count.  :e


----------



## paldepind (Mar 24, 2010)

ckester said:
			
		

> To learn more about networking and other configuration details with FreeBSD, I highly recommend Michael Lucas's book Absolute FreeBSD.   It's gotten me out a tight spot more often than I can count.  :e


Thanks! I was actually looking for some books about FreeBSD and that one sure looks great. It's definitely going to be placed pretty high on my "things to buy when I get some money" list


----------



## graudeejs (Mar 24, 2010)

paldepind said:
			
		

> OMFG! It was just typo.
> 
> I'm so sorry that I took your guys time just because of a stupid typo. Thanks a lot for your help anyway.. There's clearly a lot of stuff about networking that I know nothing about.
> 
> Btw, it works perfectly now  Thanks again!



We all make mistakes sometimes.
For example, I made mistake it this post.

I said *defaultroute*, when it should be *defaultrouter*
lol
I noticed just now


----------



## kinisia (Feb 5, 2015)

What if I am sharing a connection through NAT with my local?  I am emulating FreeBSD but it seems not connected. No ping, no fetch, anything.


----------



## junovitch@ (Feb 5, 2015)

kinisia said:


> What if I am sharing a connection through NAT with my local?  I am emulating FreeBSD but it seems not connected. No ping, no fetch, anything.


Are you using VirtualBox or and equivalent?  Just run `dhclient em0` assuming em0 is the NIC shown in `ifconfig`.  You can make that configuration permanent with an /etc/rc.conf entry like below:

```
ifconfig_em0="DHCP"
```


----------



## kinisia (Feb 6, 2015)

junovitch said:


> Are you using VirtualBox or and equivalent?  Just run `dhclient em0` assuming em0 is the NIC shown in `ifconfig`.  You can make that configuration permanent with an /etc/rc.conf entry like below:
> 
> ```
> ifconfig_em0="DHCP"
> ```



Yeah, iI noticed that iI have put inside rc.conf this:

```
ifconfig_ed0="DHCP"
```
Actually, launching an ifconfig(8) my device was em0. Thus, was not working. Changing it all is fine now. Human bugs are not trackable


----------

