How to configure FreeBSD PC to Mac using an Ethernet crossover cable to access the Internet?

I have:
a router - with an internal IP address 192.168.1.1 and is connected to the Internet.
a Mac - has the IP address of 192.168.1.10. Internet works, of course.
a PC with FreeBSD 13 installed.

I have connected the FreeBSD PC to the Mac using an Ethernet crossover cable. I have assigned 192.168.1.20 to the Mac Ethernet service and 192.168.1.30 to the FreeBSD PC, and it works - both can ping to each other.

How do I configure the PC to "go out" to the Intenet?

I have tried several methods, like turning on macOS' Internet Sharing, and also like setting to a different address for the FreeBSD (172.16.1.20 for the Mac and 172.16.1.30) - none worked. What am I missing? Is there something wrong with my connection? Or I need to download/use NAT software?
 
use the second setup
sudo sysctl net.inet.ip.forwarding=1 on the mac
use 172.16.1.20(the mac) as default_router on freebsd
create nat.txt as below on the mac
Code:
#replace en0 with the interface the mac is connected to the net (wifi?)
fbsd_net = "172.16.1.0/24"  
nat on en0  from $fbsd_net to any ->  (en0)

sudo pfctl -f /Users/you/nat.txt -e
also check if the netmask for 172... is /24 or replace with real value

if you can add static routes on your 192.168.1.1 router then you may get it to work without the pf stuff
on the mac
just add a static route on the router for for your freebsd ip/32 via the mac 192.168.1.10
the default route on bsd and sysctl on the mac stay the same
 
a router - with an internal IP address 192.168.1.1 and is connected to the Internet.
a Mac - has the IP address of 192.168.1.10. Internet works, of course.
a PC with FreeBSD 13 installed.
I suggest just buying a cheap 10 port gigabit switch. These aren't expensive.

I have tried several methods, like turning on macOS' Internet Sharing, and also like setting to a different address for the FreeBSD (172.16.1.20 for the Mac and 172.16.1.30) - none worked. What am I missing? Is there something wrong with my connection? Or I need to download/use NAT software?
We do not support MacOS here, so we really can't help you with that part.
 
a router - with an internal IP address 192.168.1.1 and is connected to the Internet.
Mac OS user here, how is the Mac connected to the router, cable, wifi? On the Mac, 'Internet Sharing', have you chosen the connection from which the Mac is connected to the router to be used by other computers (Share your connection from)?

We do not support MacOS here,
I hope it's ok to give a pointer.
 
You're going to need at least two ethernet connections on the Mac. Or one wired and one wireless connection. Really the simplest way to solve this problem is to get a small gigabit switch. You can get these for about $20.
 
imacs and minis and older laptops have both lan and wifi. i just used a similar setup running a pi zero tethered over usb (serial console + lan)
apple's internet sharing didn't do anything for whatever reason
 
Thank you, guys, for your tips! I'm going to try them...

Yup, the Mac accesses the Internet on a Wi-Fi, and it is connected to the FreeBSD PC via a crossover Ethernet cable.

The reason why I'm doing this (using a crossover Ethernet cable) instead buying a cheap switch is the router is far away and I don't want to see ugly lines across my room. :) Hopefully, I can resolve this problem soon...
 
Thank you, guys, for your tips! I'm going to try them...

Yup, the Mac accesses the Internet on a Wi-Fi, and it is connected to the FreeBSD PC via a crossover Ethernet cable.

The reason why I'm doing this (using a crossover Ethernet cable) instead buying a cheap switch is the router is far away and I don't want to see ugly lines across my room. :) Hopefully, I can resolve this problem soon...
you can consider some of these
 
Those powerline adapters don't always work well. It very much depends on the state of the wiring in your house. I live in a really old house and the wiring is shoddy at best. Never got a good connection with any of the powerline adapters I tried. It worked fine from one end of a single extension cord to the other end but I couldn't get it to work through the wall outlets from one room to another. Ended up using a Wifi bridge to connect my upstairs room to my home network for the TV and mediaplayer there.
 
I second the suggestion of T-Daemon. Internet Sharing form a Mac connected via WiFi should just work. Go to the System Settings -> Sharing, put a check mark into Internet Sharing.
Bildschirmfoto 2021-06-01 um 09.07.06.png


This adds a bridge to the network adapters like this one (see ifconfig in Terminal.app):
Code:
bridge100: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
    options=3<RXCSUM,TXCSUM>
    ether 3e:07:54:27:71:64
    inet 192.168.2.1 netmask 0xffffff00 broadcast 192.168.2.255
    inet6 fe80::3c07:54ff:fe27:7164%bridge100 prefixlen 64 scopeid 0xe
    Configuration:
        id 0:0:0:0:0:0 priority 0 hellotime 0 fwddelay 0
        maxage 0 holdcnt 0 proto stp maxaddr 100 timeout 1200
        root id 0:0:0:0:0:0 priority 0 ifcost 0 port 0
        ipfilter disabled flags 0x2
    member: en0 flags=3<LEARNING,DISCOVER>
            ifmaxaddr 0 port 6 priority 0 path cost 0
    nd6 options=201<PERFORMNUD,DAD>
    media: autoselect
    status: active

In the Network Panel, you need to verify that WiFi comes before Ethernet, otherwise your Mac tries to go into the internet via Ethernet, which would be a dead-end. You can set the order by clicking on the tiny gear symbol below the list of available connections.

On FreeBSD you need to change the IP settings to match that of the bridge adapter.
 
Another option which (is admittedly a little cheesy) is creating a socks5 proxy on your mac (or internet connected machine).

Code:
$ ssh -D0.0.0.0:9999 -o ExitOnForwardFailure=yes -o ServerAliveInterval=15 -N "127.0.0.1"

It works by ssh to localhost but using -D to create a proxy listening on port 9999 on all addresses that other machines on the network can connect to. Note you do not need to enable GatewayPorts in your mac sshd_config for this.

This proxy approach is really handy for trapping creepy operating systems like Windows (and potentially macOS) behind to stop overconsumption of bandwidth due to telemetry and faux "updates". You can just allow applications that you trust (i.e git, ssh, irssi) through.

That is if you don't want to set up a larger proxy like squid, etc. I mainly use this as a quick 'n dirty approach to accessing the Pirate Bay or getting through some academic journal paywalls.
 
Back
Top