-2

I basically want my Mac to work as a network switch so that I can share the internet from a wired connection wirelessly with no DHCP service.

Is it possible?

Hennes
  • 65,142

1 Answers1

1

Yes it is possible. I have no Mac or OS X here to test with but:

1) With no DHCP you will have to set the IPs manually.
2) You will need to enable IP forwarding and configure the routing table.

Think if it like this:


Wireless client:
IP: 172.16.0.2 /24
DG: 172.16.0.1

Wireless client:                        Your MAC
IP: 172.16.0.3 /24        Wireless NIC with    Wired NIC ------ Internet
DG: 172.16.0.1            IP: 172.16.0.1/24    SomeOtherIP          
                                               E.g. 192.168.1.12
Wireless client:
IP: 172.16.0.4 /24
DG: 172.16.0.1

Note that I used different subnets so your mac knows how to route the traffic.

Once more: I have no OS X to test this with. However I recall answering a similar question in the past and OS X seems to use the syntax:

Assuming EN1 to be the wireless interface use ifconfig en1 172.16.0.1 netmask 255.255.255.0 to configure wireless NIC with a static IP. Then /sbin/route add -net 172.16.0.0 -netmask 255.255.255.0 -interface en1 to tell it that all traffic for the 172.16.0.0/24 network must go out over EN1`.

On the clients configure the same network (172.16.0.0/24) and set the default gateway to the IP of the Macs wireless card.

You should not be able to reach the Mac from the wireless clients and vice versa.

To actually reach the internet behind the Mac you will also need to enable IP forwarding. You do this with opening a shell and typing sudo sysctl -w net.inet.ip.forwarding=1.

Note that all the commands I gave result in temporary changed. They will be gone after a reboot. This is a a good thing for testing things out. Once it works you might want to make it permanent.

Hennes
  • 65,142