I am trying to add multiple IP addresses to my en0 interface on my macbook with macOS sierra 10.13.3 version, but it is not working as expected.
sudo ifconfig en0 alias 10.0.0.1 255.255.255.255
sudo ifconfig en0 alias 10.0.0.2 255.255.255.255
sudo ifconfig en0 alias 10.0.0.3 255.255.255.255
After doing this, 10.0.0.1 resolves. I can ping.
But not 10.0.0.2 & 10.0.0.3.
Is this a known limitation or bug?
Any additional steps need to be done to make this work?
Probably a restriction?
I am able to circumvent this problem by using loopback interface.
sudo ifconfig lo0 alias 127.0.0.2 0xff000000
sudo ifconfig lo0 alias 127.0.0.3 0xff000000
and this enabled me to successfully setup port forwarding on same port across IPs on my machine.
But would be nice to know why it didn't work on en0.
Related
I am trying to get working my raspberry pi. I did sudo apt-get update && sudo apt-get upgrade and now the wifi stopped working.
I also plugged in the camera if that's not a problem.
dmesg doesn't show anything about wlan0.
if I do sudo ifdown wlan0 && sudo ifup wlan0 I get this:
ifdown: interface wlan0 not configured
wpa_supplicant: /sbin/wpa_supplicant daemon failed to start
run-parts: /etc/network/if-pre-up.d/wpasupplicant exited with return code 1
Failed to bring up wlan0.
I didn't touch the /etc/network/interfaces file so it's as default like this:
interfaces(5) file used by ifup(8) and ifdown(8)
# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d
auto lo
iface lo inet loopback
iface eth0 inet manual
auto wlan0
iface wlan0 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
allow-hotplug wlan1
iface wlan1 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
Any ideas what should be wrong?
EDIT
Also if I do ifconfig, wlan0 is not there
If it helps, here is a working configuration which allows pi3 to use wireless connection automatically if a wired one is not available:
auto lo
iface lo inet loopback
iface eth0 inet dhcp
allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
#this line must always be here
iface default inet dhcp
I am using macOS 10.12 and I want to do ip:port mapping
ex. 127.0.0.1:32769 to 10.0.0.1
then I can add 10.0.0.1 somedomain.com to my /etc/hosts
I did some search, and got solutions to this question on this post:
https://serverfault.com/questions/102416/iptables-equivalent-for-mac-os-x/673551#673551
but the command in this post works for only the newest one.
every time I use this command the system replies me:
$ sudo ifconfig lo0 10.0.0.2 alias
$ echo "rdr pass on lo0 inet proto tcp from any to 10.0.0.2 port 80 -> 127.0.0.1 port 32771" | sudo pfctl -ef -
pfctl: Use of -f option, could result in flushing of rules
present in the main ruleset added by the system at startup.
See /etc/pf.conf for further details.
No ALTQ support in kernel
ALTQ related functions disabled
pfctl: pf already enabled
how can I prevent flushing rules?
or is there any ways to get this work easier?
Thanks a lot
I wrote the following BASH script to change my MAC address back to the normal one after I am done using a spoofed MAC address:
sudo ifconfig en1 ether 00:11:22:33:44:55
It works. However, the following code doesn't work:
mac=$(cat /volumes/KYLE-OSX/mac.txt)
sudo ifconfig en1 ether $mac
I am given the following error message:
ifconfig: can't set link-level netmask or broadcast
I am unable to predict what the MAC address is going to be, so I need to be able to use any possible MAC address in the 'sudo ifconfig en1 ether' statement.
The fundamental problem was diagnosed in comments already -- the file contains more than just the MAC address. Here's a simple workaround for that.
mac=$(grep -Eo '\<[0-9a-f]{2}(:[0-9a-f]{2}){5}\>' /Volumes/KYLE-OSX/mac.txt)
I have been handicapped by the GUI and always seem to ask of help when it comes to the command line.
On Mac OS X only I need a command line to get the mac address of the wifi currently in use.
Help!
ifconfig en1 gets the interface details for wifi, the mac is on a line starting with ether, and is the second word on that line so:
ifconfig en1 | awk '/ether/{print $2}'
I think the best and easiest way to get the information is using this command:
networksetup -listallhardwareports
It will return a nice list of devices like this:
Hardware Port: USB 10/100/1000 LAN
Device: en6
Ethernet Address: 00:e0:4c:...
Hardware Port: Wi-Fi
Device: en0
Ethernet Address: 80:e6:50:...
Hardware Port: Bluetooth PAN
Device: en3
Ethernet Address: 80:e6:50:...
Hardware Port: Thunderbolt 1
Device: en1
Ethernet Address: 72:00:05:...
Hardware Port: Thunderbolt 2
Device: en2
Ethernet Address: 72:00:05:...
Hardware Port: Thunderbolt Bridge
Device: bridge0
Ethernet Address: 72:00:05:...
VLAN Configurations
===================
networksetup -getmacaddress <interface>
Wifi mac address is normally can be found in en0. So you may try this command on Terminal
ifconfig en0 | awk '/ether/{print $2}'
ifconfig should do the trick, it'll display a bunch of info including your MAC address. Alternatively it'll be in your network settings under system preferences.
EDIT
On a computer with just a wireless connection, en0 will have your wifi settings. The tag labeled with ether will most likely be your MAC address.
If you have both a wired and wireless connection, it'll be under ether in the en1 tag
Source: http://m.iclarified.com/entry/index.php?enid=30929
This will easily give you the specific Mac Address for your Wifi Interface
networksetup -listallhardwareports | grep Wi-Fi -A 3 | awk '/Ethernet Address:/{print $3}'
I have MySQL running locally on my host machine and for reasons™ I can't run it inside of my Vagrant machine. I know that there's a way to address this issue with iptables by forwarding all traffic to 3306 on the guest to the host's IP address and port, but this complicates things a lot for me as I'll have to play around with iptables rules and probably get into TCP masquerading, which would be nice to avoid.
Is there a way in Vagrant (VirtualBox VM) to forward a host TCP port to the guest so that the guest can access 127.0.0.1:3306 and have all traffic forwarded to host:3306 seamlessly? If not, how exactly would I set this up in iptables?
According to this answer, Docker provides a way to do this natively without having to screw around with IP tables rules. Does VirtualBox and Vagrant provide a way to mimic this functionality?
I have two solutions, one involving iptables hacking and one more straightforward using SSH.
Tunnel a Host Port to the Guest over SSH
When connecting to the guest using vagrant ssh, pass the port along as an argument:
vagrant ssh -- -R 3306:localhost:3306
This will forward the local port 3306 to the remote machine at port 3306.
iptables Hackery
We can use iptables on the guest to forward all traffic to a local port on the guest to a remote port on the host. We need to ensure that the host and guest have more or less static IP addresses in relation to each other to ensure that everything works fine. We'll also need to open a port on the host's firewall to allow the guest to do this.
Give the Guest a Static IP
In your Vagrantfile, set a static IP address for the guest:
config.vm.network "private_network", ip: "10.10.10.10"
Now, when you hit 10.10.10.10, you'll always* be hitting your guest.
Configure iptables in the Guest
Found in this awesome answer in Server Fault:
$ remote_ip=10.0.2.2
$ mysql_port=3306
$ sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport $mysql_port \
-j DNAT --to $remote_ip:$mysql_port
$ sudo iptables -N INET-PRIV
$ sudo iptables -A FORWARD -i eth0 -o eth1 -j INET-PRIV
$ sudo iptables -A FORWARD -j drop
$ sudo iptables -A INET-PRIV -p tcp -d $remote_ip --dport $mysql_port \
-j ACCEPT
$ sudo iptables -A INET-PRIV -j DROP
Then, enable port forwarding:
$ echo "1" | sudo tee /proc/sys/net/ipv4/ip_forward
First, test it out, then when you're sure it works, run:
$ sudo iptables-save
I'm not sure that /proc/sys/net/ipv4/ip_forward will remember settings on boot, so you might want to add that to a startup script.
Which Should I Use?
SSH is definitely easier to do, but there's a bit of a performance overhead of having to encrypt that port's traffic and forward it back to the host.
iptables feels like black magic, but once you get it working, it's really nice and fairly seamless.
Port forwarding (using NAT back network backend) doesn't seem to fit the use case well.
In your use case, Public Network (Bridged Networking) is a better choice. Create a 2nd network in Vagrantfile and do a vagrant reload.
Vagrant.configure("2") do |config|
config.vm.network "public_network"
end
Basically this will add an extra virtual NIC in the VM, and it'll get an IP from the same DHCP server in your network. Get its IP by using ifconfig -a or ip addr.
The host <=> VM will be able to communicate. VM should be able to connect to mysql running on the host via port 3306.
HTH