Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Share internet connections on a 192.168.x.x network Network
At the office and connected via AirPort, I get an address on the 192.168.2.x network. Unfortunately, if I attempt to use internet connection sharing (in the Sharing Preferences panel), this conflicts with the built-in 192.168.2.x addressing scheme that OS X uses. Here's a workaround...

Set your internal IP address on en0 (built-in Ethernet) to whatever non-routable address you like -- i.e. 192.168.x.x or 172.16.x.x or 10.x.x.x. Then cut and paste the following into your favorite Terminal-based text editor. Save it as simple_natd.
#!/bin/bash
interface="$1"
if [ "$interface" = "" ] ; then
  echo "I need an interface to NAT on"
  exit 1
fi
echo "you may need to run 'ipfw flush'"
natd=`ps awux |grep -v grep|grep -v $0|grep natd|awk '{print $2}'`
kill -9 $natd
sleep 1
sysctl -w net.inet.ip.forwarding=1
alias_ip=$(ifconfig $interface | grep inet | grep -v inet6 | \
 awk '{print $2}' | head -1)
/usr/sbin/natd -alias_address $alias_ip -interface $interface -use_sockets \
 -same_ports -unregistered_only -dynamic -clamp_mss
#ipfw -f flush
ipfw add divert natd ip from any to any via "$interface"
Run the simple_natd script in terminal to enable NAT for computers on your built-in ethernet (en0) network from your network connection on the Airport card (en1):
sudo bash simple_natd en1
Remember to make the script executable first. A much more elegant solution would be to change the network and range that the internal DHCP server uses when starting Internet connection sharing. However, after months of random searching, I have been unable to find how that is possible.
    •    
  • Currently 2.50 / 5
  You rated: 3 / 5 (6 votes cast)
 
[54,384 views]  

Share internet connections on a 192.168.x.x network | 14 comments | Create New Account
Click here to return to the 'Share internet connections on a 192.168.x.x network' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Confused...
Authored by: lullabud on Apr 04, '05 01:33:45PM

I'm not sure how this is any different from just changing the interface in the "Share your connection from" drop-down box in the internet sharing preference pane and then selecting the network to share to in the "To computers using" box.

As long as you select your Internet connection in the first box and a network that doesn't have a DHCP server for the second box you should be fine.



[ Reply to This | # ]
Share internet connections on a 192.168.x.x network
Authored by: AJB on Apr 04, '05 04:46:27PM
...this conflicts with the built-in 192.168.2.x addressing scheme that OS X uses

Uses for what?

Is this a solution for a problem that does not exist? I've been using OS X since the beta, and my job is IP networking. I am unaware of OS X using a built in addressing scheme, in the 192.168 range or any other.

Please explain



[ Reply to This | # ]
Share internet connections on a 192.168.x.x network
Authored by: iDG on Apr 04, '05 05:05:17PM
The internet sharing component (/usr/libexec/InternetSharing) is apparently hardcoded for a 192.168.2.x network:
it will add an alias 192.168.2.1 on the "internal" interface and will create a 192.168.2 entry in the netinfo /config/dhcp/subnets... There seems to be no way to change that. Unless, ofcourse, if you can disable Internet Sharing and manually (or via a script) launch bootpd (which will obey to the configuration in /config/dhcp), natd and place the divert rule in ipfw as this hint suggests...

[ Reply to This | # ]
Share internet connections on a 192.168.x.x network
Authored by: digitol on Apr 04, '05 06:00:00PM

Interesting... I just did this for a freind last week... had one computer connected to the internet via a router hard-wired.. then turned on that computer's share internet via airport option.. to a wireless laptop, to which the IP address on the now internet connected laptop is 169.X.X.x ! So not sure what the authors hint is about.



[ Reply to This | # ]
Share internet connections on a 192.168.x.x network
Authored by: pmbuko on Apr 04, '05 06:58:32PM

the 169.X.X.X range is known as the "local link" address space. Most adapters default to this range when they cannot locate a DHCP server. Rendezvous also uses this range.



[ Reply to This | # ]
Share internet connections on a 192.168.x.x network
Authored by: jamiebah on Apr 04, '05 07:30:24PM

Rendezvous uses 224.x.x.x



[ Reply to This | # ]
Share internet connections on a 192.168.x.x network
Authored by: kevinv on Apr 04, '05 09:31:27PM

The 224 subnet is reserved for multi-cast, which Rendezvous uses.

http://www.iana.org/assignments/multicast-addresses



[ Reply to This | # ]
Share internet connections anyway you want to with...
Authored by: webbix on Apr 04, '05 10:04:52PM

Not sure I understand the hint any better than others. However, if you do want to run an OS X mac as a router with more advanced settings than available via the sharing prefpane I suggest 'SunShield' which can be found here <http://www.sunprotectingfactory.com/sunShield/shield_news.html>. A comment on VersionTracker from 03/2005 notes an interface issue but I did not seem to see this with 10.3.8 on my TiBook.

It offers a prefpane for firewall, routing and saved sets. I use it rarely but it has worked well even when using my internal Airport and a PC Card Orinico Gold to share a wireless connection to other wireless clients. As always, your mileage may vary.



[ Reply to This | # ]
Share internet connections on a 192.168.x.x network
Authored by: tomf40ph on Apr 13, '05 05:14:44PM

Thanks for the information. I was wondering why I could not use Internet Connection Sharing when I have done it hundreds of times before on a wide variety of routers and networks. A particular Belkin router was set to 192.168.2.1 which conflicts with the Mac OS X Internet Connection Sharing default routing address. It only occurs with that exact IP address. Changing the router's built-in address or following the steps outlined here solves the conflict.



[ Reply to This | # ]
Share internet connections on a 192.168.x.x network
Authored by: mlibbey on Jul 10, '05 11:06:20PM
>Set your internal IP address on en0 (built-in Ethernet) to whatever non-routable address you like -- i.e. 192.168.x.x or 172.16.x.x or 10.x.x.x.

How? Internet Sharing is giving out 10.0.2.x, and I'd prefer it to give out 10.0.1.x addresses. Why? Perhaps a silly reason, but I'm using Internet Sharing as a stopgap until Apple fixes 10.4the massive packet loss and neetwork problems with airport express... and I have my Tivo set to grab a manual address: 10.0.1.33 from the airport network, and don't want to go change it.

[ Reply to This | # ]

Share internet connections on a 192.168.x.x network
Authored by: rajulkabir on Mar 03, '06 07:06:21PM

Ran into a similar problem this week. I'm staying at a hotel that provides wifi with 192.168.2.* addresses, and I wanted to use my VoIP box connected via my iBook's ethernet port. Unfortunately, due to Apple Internet Sharing's inflexible setup, there was an address conflict.

The hint above gets you part of the way, but does not provide DHCP or DNS out the sharing port. So it's not very helpful for dumb devices like the VoIP box that expect to be spoon-fed everything via DHCP.

I puttered around for a while and eventually came up with a working procedure. It's ugly, and probably only useful for someone comfortable at the command line, but it does get the job done.

In this case I am assuming you will use 10.168.2.* for your shared network (to avoid conflict with 192.168.2.* and minimize typing). Also I am assuming you are receiving internet via en1 (airport) and want to share it via en0 (ethernet).

  1. Turn on internet sharing
  2. Copy the file /etc/com.apple.named.conf.proxy to your home directory
  3. Edit your copy of the file, change the 'listen-on' directive to point to 10.168.2.1 instead of 192.168.2.1 (don't change anything else)
  4. Start up Netinfo Manager
  5. Duplicate /config/dhcp/subnets/192.168.2
  6. Edit your duplicate, changing every instance of 192 to 10
  7. Save changes
  8. Turn off internet sharing
  9. Open a shell prompt and get yourself to root (sudo bash or whatever you prefer)
  10. /sbin/ifconfig en0 10.168.2.1 netmask 255.255.255.0 broadcast 10.168.2.255
  11. /usr/libexec/bootpd -P -D
  12. /usr/sbin/natd -interface en1 -use_sockets -same_ports -unregistered_only -dynamic -clamp_mss -enable_natportmap -natportmap_interface en0
    (this is showing up with awkward line breaks; in every case the - (hyphen) should immediately precede the following letter, with no intervening spaces.
  13. /sbin/ipfw add 100 divert natd ip from any to any via en1
  14. /usr/sbin/named -c ~/com.apple.named.conf.proxy
  15. /usr/sbin/sysctl -w net.inet.ip.forwarding=1

Good luck.

[ Reply to This | # ]

Share internet connections on a 192.168.x.x network
Authored by: jcovert on May 13, '06 05:43:36PM

The above hint with all the bootpd and caching named (etc.) setup was really helpful. One thing though.

The author suggested /usr/libexec/bootpd -P -D

I found that even though I had deleted the 192.168.2 subnet from Netinfo, bootpd was still listening on the WiFi (en1) interface, and though it didn't seem to be trying to give out addresses, when it noticed the other DHCP server running, it would exit. So after a while, when my clients on en0 would request a new lease, the server was gone.

I solved this by adding -i en0 to the command line.

Also, I'm not sure what "-P" is, and when I started using -i en0 I also started using "-B" instead, to disable bootp and only use DHCP.

Thanks again for the excellent work above.

/john



[ Reply to This | # ]
Share internet connections on a 192.168.x.x network
Authored by: Bobson on Apr 30, '06 02:31:06PM

This hint's also useful for sharing a connection from built-in firewire to built-in ethernet and vice versa, since they use the same address scheme.

To add to it a bit: You may have to assign a fake IP address to the port that you want to be doing the serving (such as 192.168.123.1) and make it its own gateway. Then on the machines you want to add to the network, you just stick them on the same subnet (192.168.123.10) and set the gateway/broadcast address to the natd-ing machine (.1)



[ Reply to This | # ]
Share internet connections on a 192.168.x.x network
Authored by: pfftdives on Jun 10, '06 01:09:40PM
Hi there. My home net uses 192.168.2.x and so when i tried to use parallels in host-only networking mode, and Internet Sharing, nothing would work because 192.168.2.0/24 is HARDCODED :( I used your script, it worked very well, THANK YOU.
My next step though, was i want to let the parallels system also ride my mac's vpn tunnel (juniper's network connect vpn - uses jnc0 interface) so that i wouldnt need to run two VPN clients. So here's my script - 99% of it is yours. The difference is i'm running two natds, two divert rules, and ... it works very very well. My only frustration now is that i cant get parallels to NOT hand out DHCP to the host-only adapter, and to have it use osx's bootpd, so i have to manually assign my IP/DNS on the parallels host (windows XP if anyone cares). Here's my current script. Any tips on parallels not-dhcping are greatly appreciated!
---
#!/bin/sh
# turns up natd/divert for parallels host
# all credit goes to tejinashi http://www.macosxhints.com/article.php?story=20050331194834746
#
/sbin/ifconfig en2 192.168.90.254 netmask 255.255.255.0 broadcast 192.168.90.255
/usr/libexec/bootpd -P -D
/usr/sbin/natd -interface en1 -use_sockets -same_ports -unregistered_only -dynamic -clamp_mss -enable_natportmap -natportmap_interface en2
/usr/sbin/natd -interface jnc0 -use_sockets -same_ports -unregistered_only -dynamic -clamp_mss -enable_natportmap -natportmap_interface en2 -port 8999
/sbin/ipfw add 99 divert 8999 ip from any to 10.9.0.0/16 via jnc0
/sbin/ipfw add 100 divert natd ip from any to any via en1
/usr/sbin/named -c ~/com.apple.named.conf.proxy
/usr/sbin/sysctl -w net.inet.ip.forwarding=1

thanks again!


[ Reply to This | # ]