INTRO
Ladies, gentlemen, and cyber friends,
recently I've had to install FreeBSD on a PC that did not have a wireless NIC,
and the router was so inconveniently placed that connecting directly via cable was out of the question.
So, I decided to connect to the Wi-Fi through my FreeBSD laptop and then share its internet connection with the PC over the ethernet port.
This is a guide on how you can configure such a setup with two FreeBSD devices.
STEP 1: PREPARE THE LAPTOP
First, enable IP forwarding (you may need root privilages):
sysctl net.inet.ip.forwarding=1
Then, assign an IP address to your ethernet NIC (you may need root privilages);
In my case, the LAN connected to the router had the standard IP: 192.168.100.0/24
So, I decided to assign the ethernet interface (re0) to another LAN, with IP: 192.168.101.1/24
ifconfig re0 192.168.101.1/24
The next step is to prepare a firewall rule that will perform NAT; We will be using pf.
Perhaps now is a good time to mention that my wireless interface is called wlan0.
So, I placed the following config in /etc/pf.conf:
Finally, enable the firewall (you may need root privilages):
service pf onestart
I used onestart because I didn't enable the service. If you did, then 'start' should be used instead.
STEP 2: PREPARE THE PC
First, assign an address on the same local network for the ethernet interface, as the one on the laptop;
In this case, my PC's interface was called rge0 (you may need root privilages):
ifconfig rge0 192.168.101.2/24
Next, we will want to set the laptop as the default gateway (you may need root privilages):
route add default 192.168.101.1
Finally, update the DNS resolver; I like to use 8.8.8.8, because it's easy to remember (you may need root privilages):
Inside /etc/resolv.conf place:
VERIFY THE CONNECTION
ping freebsd.org
And that would be all!
If this doesn't work, try:
ping 8.8.8.8
If this doesn't work, try:
ping 192.168.101.1
If the first one failed, it could be a problem with the DNS resolver.
If the second one failed, it could be a problem with the pf config.
If the third one failed, then it could be a problem with the interface addresses,
or it could be a faulty cable.
Ladies, gentlemen, and cyber friends,
recently I've had to install FreeBSD on a PC that did not have a wireless NIC,
and the router was so inconveniently placed that connecting directly via cable was out of the question.
So, I decided to connect to the Wi-Fi through my FreeBSD laptop and then share its internet connection with the PC over the ethernet port.
This is a guide on how you can configure such a setup with two FreeBSD devices.
STEP 1: PREPARE THE LAPTOP
First, enable IP forwarding (you may need root privilages):
sysctl net.inet.ip.forwarding=1
Then, assign an IP address to your ethernet NIC (you may need root privilages);
In my case, the LAN connected to the router had the standard IP: 192.168.100.0/24
So, I decided to assign the ethernet interface (re0) to another LAN, with IP: 192.168.101.1/24
ifconfig re0 192.168.101.1/24
The next step is to prepare a firewall rule that will perform NAT; We will be using pf.
Perhaps now is a good time to mention that my wireless interface is called wlan0.
So, I placed the following config in /etc/pf.conf:
ext_if = "wlan0"int_if = "re0"set skip on lonat on $ext_if from $int_if:network to any -> ($ext_if)pass allFinally, enable the firewall (you may need root privilages):
service pf onestart
I used onestart because I didn't enable the service. If you did, then 'start' should be used instead.
STEP 2: PREPARE THE PC
First, assign an address on the same local network for the ethernet interface, as the one on the laptop;
In this case, my PC's interface was called rge0 (you may need root privilages):
ifconfig rge0 192.168.101.2/24
Next, we will want to set the laptop as the default gateway (you may need root privilages):
route add default 192.168.101.1
Finally, update the DNS resolver; I like to use 8.8.8.8, because it's easy to remember (you may need root privilages):
Inside /etc/resolv.conf place:
nameserver 8.8.8.8VERIFY THE CONNECTION
ping freebsd.org
And that would be all!
If this doesn't work, try:
ping 8.8.8.8
If this doesn't work, try:
ping 192.168.101.1
If the first one failed, it could be a problem with the DNS resolver.
If the second one failed, it could be a problem with the pf config.
If the third one failed, then it could be a problem with the interface addresses,
or it could be a faulty cable.