port forwarding in yosemite, a way to replace ipfw

login as root, or do the following in sudo.

create a file /etc/pf.anchors/com.pow, add following two lines with new line breaker at the end:

rdr pass on lo0 inet proto tcp from any to any port 80 -> 127.0.0.1 port 8080

rdr pass on lo0 inet proto tcp from any to any port 443 -> 127.0.0.1 port 8443

then, edit /etc/pf.conf file, add following two lines (with "pow") at the exact locations as below:

...
rdr-anchor "com.apple/*"
rdr-anchor "pow"
...
load anchor "com.apple" from "/etc/pf.anchors/com.apple"
load anchor "pow" from "/etc/pf.anchors/com.pow"

now you could issue following command to make the port forwarding activated. 

pfctl -ef /etc/pf.conf

to make sure this rule is auto loaded after system restart, need modify file /System/Library/LaunchDaemons/com.apple.pfctl.plist as

...
<string>pfctl</string>
                <string>-e</string>
                <string>-f</string>
<string>/etc/pf.conf</string>
...

done!

### Port Forwarding in Chrome Chrome itself doesn't have a built - in feature for port forwarding. However, for web - related scenarios where you might want to access a local service through Chrome, you can use browser extensions in combination with tools like SSH for port forwarding. For example, if you have set up an SSH tunnel on your local machine to forward a port from a remote server to your local system, you can then access the service in Chrome by navigating to the local port. Here is a simple example of setting up an SSH tunnel for port forwarding on a Linux or macOS system: ```bash ssh -L local_port:remote_host:remote_port username@remote_server ``` After the tunnel is established, you can open Chrome and access `http://localhost:local_port` to reach the service running on the remote server. ### Port Forwarding in SecureCRT SecureCRT is a popular terminal emulator that supports port forwarding. Here are the general steps to set up port forwarding in SecureCRT: 1. Open SecureCRT and establish an SSH connection to the remote server. 2. Navigate to the "Session Options" (usually found in the "Options" menu). 3. In the Session Options window, expand the "Connection" category and select "Port Forwarding". 4. Click the "Add" button to create a new port forwarding rule. - For local port forwarding, you need to specify the local port number on your machine, the remote host (the server you want to access through the tunnel), and the remote port. - For remote port forwarding, it's the opposite. You define a port on the remote server that will forward traffic to a local host and port. 5. After setting up the rule, click "OK" to save the configuration. Here is a simple Python script example that can be used in SecureCRT to automate some operations (this is more for advanced usage and assumes basic knowledge of SecureCRT scripting): ```python import securecrt def main(): crt.Screen.Send("ssh -L local_port:remote_host:remote_port username@remote_server\n") crt.Screen.WaitForString("password:") crt.Screen.Send("your_password\n") main() ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值